Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ jobs:
matrix:
php: [ "8.0", "8.1", "8.2", "8.3", "8.4" ]
composer_flags: [ "", "--prefer-lowest" ]
symfony_version: [ "^5.4", "^6.4" ]
symfony_version: [ "^5.4", "^6.4", "^7.3" ]
exclude:
# Symfony 6 requires PHP 8.1+
- php: "8.0"
symfony_version: "^6.4"
# Symfony 7 requires PHP 8.2+
- php: "8.0"
symfony_version: "^7.3"
- php: "8.1"
symfony_version: "^7.3"

name: PHP ${{ matrix.php }} SF ${{ matrix.symfony_version }} ${{ matrix.composer_flags}}
env:
PHP: ${{ matrix.os }}
Expand All @@ -38,7 +45,7 @@ jobs:
run: |
composer self-update
if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi;
if [ "$SYMFONY_VERSION" = "^6.4" ]; then composer remove --dev "friendsofsymfony/oauth-server-bundle" --no-update; fi;
if [ "$SYMFONY_VERSION" != "^5.4" ]; then composer remove --dev "friendsofsymfony/oauth-server-bundle" --no-update; fi;
COMPOSER_MEMORY_LIMIT=-1 composer update --prefer-dist --no-interaction $COMPOSER_FLAGS
- name: Static analysis
run: |
Expand Down
2 changes: 1 addition & 1 deletion EventListener/RateLimitAnnotationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function onKernelController(ControllerEvent $event): void
}

// Skip if we aren't the main request
if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
if ($event->getRequestType() !== HttpKernelInterface::MAIN_REQUEST) {
return;
}

Expand Down
10 changes: 5 additions & 5 deletions Tests/EventListener/RateLimitAnnotationListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testReturnedWhenNoControllerFound(): void
$kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')->getMock();
$request = new Request();

$event = new ControllerEvent($kernel, static function() {}, $request, HttpKernelInterface::MASTER_REQUEST);
$event = new ControllerEvent($kernel, static function() {}, $request, HttpKernelInterface::MAIN_REQUEST);

$listener->onKernelController($event);
}
Expand All @@ -81,7 +81,7 @@ public function testReturnedWhenNoAttributesFound(): void
public function testDelegatesToPathLimitProcessorWhenNoAttributesFound(): void
{
$request = new Request();
$event = $this->createEvent(HttpKernelInterface::MASTER_REQUEST, $request);
$event = $this->createEvent(HttpKernelInterface::MAIN_REQUEST, $request);

$listener = $this->createListener($this->once());

Expand Down Expand Up @@ -109,7 +109,7 @@ public function testDispatchIsCalledWithAttributes(): void
$listener = $this->createListener($this->exactly(2));

$event = $this->createEvent(
HttpKernelInterface::MASTER_REQUEST,
HttpKernelInterface::MAIN_REQUEST,
null,
new MockControllerWithAttributes()
);
Expand All @@ -119,7 +119,7 @@ public function testDispatchIsCalledWithAttributes(): void

public function testDispatchIsCalledIfThePathLimitProcessorReturnsARateLimit(): void
{
$event = $this->createEvent(HttpKernelInterface::MASTER_REQUEST);
$event = $this->createEvent(HttpKernelInterface::MAIN_REQUEST);

$listener = $this->createListener($this->exactly(2));
$rateLimit = new RateLimit(
Expand Down Expand Up @@ -315,7 +315,7 @@ public function testFindBestMethodMatchMatchingMultipleAnnotations(): void
}

protected function createEvent(
int $requestType = HttpKernelInterface::MASTER_REQUEST,
int $requestType = HttpKernelInterface::MAIN_REQUEST,
?Request $request = null,
?MockController $controller = null,
): ControllerEvent
Expand Down
29 changes: 22 additions & 7 deletions Tests/Service/Storage/PsrCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,27 @@ public function testCreateRate()
{
$item = $this->getMockBuilder('Psr\\Cache\\CacheItemInterface')
->getMock();
$item->expects($this->once())
->method('set')
->willReturn(true);
$item->expects($this->once())
->method('expiresAfter')
->willReturn(true);

/**
* psr/cache 3.0 changed the return type of set() and expiresAfter() to return self.
* @TODO NEXT_MAJOR: Remove this check and the first conditional block when psr/cache <3 support is dropped.
*/
$psrCacheVersion = \Composer\InstalledVersions::getVersion('psr/cache');
if (version_compare($psrCacheVersion, '3.0', '<')) {
$item->expects($this->once())
->method('set')
->willReturn(true);
$item->expects($this->once())
->method('expiresAfter')
->willReturn(true);
} else {
$item->expects($this->once())
->method('set')
->willReturnSelf();
$item->expects($this->once())
->method('expiresAfter')
->willReturnSelf();
}

$client = $this->getMockBuilder('Psr\\Cache\\CacheItemPoolInterface')
->getMock();
Expand Down Expand Up @@ -121,4 +136,4 @@ public function testResetRate()
$storage = new PsrCache($client);
$this->assertTrue($storage->resetRate('foo'));
}
}
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
],
"require": {
"php": "^8.0",
"symfony/framework-bundle": "^5.4.2|^6.4"
"symfony/framework-bundle": "^5.4.2|^6.4|^7.3"
},
"require-dev": {
"symfony/phpunit-bridge": ">=5.4",
"psr/simple-cache": "^1.0|^2.0",
"doctrine/cache": "^1.5",
"psr/cache": "^1.0|^2.0",
"psr/cache": "^1.0|^2.0|^3.0",
"predis/predis": "^1.1|^2.0",
"friendsofsymfony/oauth-server-bundle": "^1.5|^2.0@dev",
"phpstan/phpstan": "^2.1"
Expand Down