From c306394fc60c731c97768bc66c02918c2314a080 Mon Sep 17 00:00:00 2001 From: David Maicher Date: Mon, 6 Oct 2025 09:31:18 +0200 Subject: [PATCH] bump dependencies --- .github/workflows/ci.yml | 16 ++--- composer.json | 29 ++++----- src/NodeVisitor/NodeFilter.php | 2 +- tests/Functional/AppKernel.php | 19 ++++-- tests/NodeVisitor/NodeActivatorTest.php | 32 +++++---- tests/NodeVisitor/NodeFilterTest.php | 65 +++++++------------ tests/NodeVisitor/NodeRoutePropagatorTest.php | 27 +++----- tests/phpunit.xml | 38 +++++------ 8 files changed, 101 insertions(+), 127 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f80c21..d52d8f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,17 +10,13 @@ jobs: fail-fast: false matrix: include: - - php: 7.4 + - php: 8.1 composer-flags: --prefer-lowest - - php: 7.4 - SYMFONY_REQUIRE: 5.4.* - - php: 8.0 - php: 8.1 SYMFONY_REQUIRE: 6.4.* - - php: 8.2 - SYMFONY_REQUIRE: 7.1.* - - php: 8.3 - SYMFONY_REQUIRE: 7.1.* + - php: 8.4 + SYMFONY_REQUIRE: 7.3.* + - php: 8.4 stability: dev steps: @@ -62,7 +58,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: "8.2" + php-version: "8.4" - name: Install dependencies run: composer update --prefer-dist @@ -80,7 +76,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: "8.2" + php-version: "8.4" - name: Install dependencies run: composer update --prefer-dist diff --git a/composer.json b/composer.json index 01c52f2..e26cd43 100644 --- a/composer.json +++ b/composer.json @@ -12,23 +12,22 @@ } ], "require": { - "php": "^7.4 || ^8.0", - "symfony/framework-bundle": "^5.4 || ^6.4 || ^7.1", - "symfony/twig-bundle": "^5.4 || ^6.4 || ^7.1", - "twig/twig": "^1.35 || ^2.4.4 || ^3.0" + "php": ">=8.1", + "symfony/framework-bundle": "^6.4 || ^7.3", + "symfony/twig-bundle": "^6.4 || ^7.3", + "twig/twig": "^2.4.4 || ^3.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.27", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.5", - "phpstan/phpstan-symfony": "^1.0", - "phpunit/phpunit": "^8.5 || ^9.5", - "symfony/browser-kit": "^5.4 || ^6.4 || ^7.1", - "symfony/css-selector": "^5.4 || ^6.4 || ^7.1", - "symfony/expression-language": "^5.4 || ^6.4 || ^7.1", - "symfony/phpunit-bridge": "^7.1", - "symfony/security-bundle": "^5.4 || ^6.4 || ^7.1", - "symfony/yaml": "5.4 || ^6.4 || ^7.1" + "friendsofphp/php-cs-fixer": "^v3.88.2", + "phpstan/extension-installer": "^1.4.3", + "phpstan/phpstan": "^2.1.30", + "phpstan/phpstan-symfony": "^2.0.8", + "phpunit/phpunit": "^10.5.58", + "symfony/browser-kit": "^6.4 || ^7.3", + "symfony/css-selector": "^6.4 || ^7.3", + "symfony/expression-language": "^6.4 || ^7.3", + "symfony/security-bundle": "^6.4 || ^7.3", + "symfony/yaml": "^6.4 || ^7.3" }, "autoload": { "psr-4": { diff --git a/src/NodeVisitor/NodeFilter.php b/src/NodeVisitor/NodeFilter.php index 9b33346..40c8d93 100644 --- a/src/NodeVisitor/NodeFilter.php +++ b/src/NodeVisitor/NodeFilter.php @@ -24,7 +24,7 @@ final class NodeFilter implements NodeVisitorInterface public function __construct( TokenStorageInterface $tokenStorage, - AuthorizationCheckerInterface $authChecker + AuthorizationCheckerInterface $authChecker, ) { $this->tokenStorage = $tokenStorage; $this->authChecker = $authChecker; diff --git a/tests/Functional/AppKernel.php b/tests/Functional/AppKernel.php index 59ec6f1..89293d9 100644 --- a/tests/Functional/AppKernel.php +++ b/tests/Functional/AppKernel.php @@ -2,7 +2,13 @@ namespace Tests\Functional; +use DAMA\MenuBundle\DAMAMenuBundle; +use Psr\Log\NullLogger; +use Symfony\Bundle\FrameworkBundle\FrameworkBundle; +use Symfony\Bundle\SecurityBundle\SecurityBundle; +use Symfony\Bundle\TwigBundle\TwigBundle; use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel; class AppKernel extends Kernel @@ -10,10 +16,10 @@ class AppKernel extends Kernel public function registerBundles(): iterable { return [ - new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), - new \Symfony\Bundle\SecurityBundle\SecurityBundle(), - new \Symfony\Bundle\TwigBundle\TwigBundle(), - new \DAMA\MenuBundle\DAMAMenuBundle(), + new FrameworkBundle(), + new SecurityBundle(), + new TwigBundle(), + new DAMAMenuBundle(), ]; } @@ -27,4 +33,9 @@ public function registerContainerConfiguration(LoaderInterface $loader): void $loader->load(__DIR__.'/config.yml'); $loader->load(__DIR__.'/config.php'); } + + protected function build(ContainerBuilder $container): void + { + $container->register('logger', NullLogger::class); + } } diff --git a/tests/NodeVisitor/NodeActivatorTest.php b/tests/NodeVisitor/NodeActivatorTest.php index 6585fcf..f4fc18e 100644 --- a/tests/NodeVisitor/NodeActivatorTest.php +++ b/tests/NodeVisitor/NodeActivatorTest.php @@ -1,33 +1,31 @@ node = new Node(); } - /** - * @dataProvider getTestData - * - * @param string $route - */ - public function testVisit($route, array $routes, $requestRoute, $expectedIsActive): void + #[DataProvider('getTestData')] + public function testVisit(?string $route, array $routes, $requestRoute, $expectedIsActive): void { $this->node->setRoute($route); $this->node->setAdditionalActiveRoutes($routes); - $requestStack = $this->getRequestStackMock($requestRoute); + $requestStack = $this->getRequestStack($requestRoute); $activator = new NodeActivator($requestStack); $activator->visit($this->node); @@ -35,7 +33,7 @@ public function testVisit($route, array $routes, $requestRoute, $expectedIsActiv $this->assertEquals($expectedIsActive, $this->node->isActive()); } - public function getTestData() + public static function getTestData(): array { return [ [null, [], 'some_route', false], @@ -45,13 +43,13 @@ public function getTestData() ]; } - private function getRequestStackMock($requestRoute) + private function getRequestStack(string $requestRoute): RequestStack { - $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); - $request->expects($this->any())->method('get')->with('_route')->will($this->returnValue($requestRoute)); + $request = new Request(); + $request->attributes->set('_route', $requestRoute); - $requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->getMock(); - $requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue($request)); + $requestStack = new RequestStack(); + $requestStack->push($request); return $requestStack; } diff --git a/tests/NodeVisitor/NodeFilterTest.php b/tests/NodeVisitor/NodeFilterTest.php index 78d6534..11eca0b 100644 --- a/tests/NodeVisitor/NodeFilterTest.php +++ b/tests/NodeVisitor/NodeFilterTest.php @@ -1,11 +1,15 @@ authChecker = $this->createMock(AuthorizationCheckerInterface::class); $this->filter = new NodeFilter($this->tokenStorage, $this->authChecker); $this->node = new Node(); - $this->parent = $this->getMockBuilder(Node::class)->getMock(); + $this->parent = $this->createMock(Node::class); $this->node->setParent($this->parent); + $this->token = $this->createMock(TokenInterface::class); } - /** - * @dataProvider getTestData - */ - public function testVisit(array $permissions, $getTokenReturn, $isGrantedReturn, $expectsFiltered): void + #[DataProvider('getTestData')] + public function testVisit(array $permissions, bool $hasToken, $isGrantedReturn, $expectsFiltered): void { $this->node->setRequiredPermissions($permissions); $this->tokenStorage ->expects($this->any()) ->method('getToken') - ->will($this->returnValue($getTokenReturn)) + ->willReturn($hasToken ? $this->token : null) ; $this->authChecker ->expects($this->any()) ->method('isGranted') - ->will($this->returnValue($isGrantedReturn)) + ->willReturn($isGrantedReturn) ; if ($expectsFiltered) { @@ -84,10 +69,8 @@ public function testVisit(array $permissions, $getTokenReturn, $isGrantedReturn, } } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testRemoveParentIfNoActiveChildren(bool $remove): void { $tree = (new NodeFactory())->create(); @@ -117,14 +100,14 @@ public function testRemoveParentIfNoActiveChildren(bool $remove): void $this->assertCount($remove ? 0 : 1, $tree->getChildren()); } - public function getTestData() + public static function getTestData(): array { return [ - [[], $this->createMock(TokenInterface::class), true, false], - [['FOO'], $this->createMock(TokenInterface::class), true, false], - [['FOO'], $this->createMock(TokenInterface::class), false, true], - [['FOO'], null, true, true], - [[new Expression('something')], null, true, true], + [[], true, true, false], + [['FOO'], true, true, false], + [['FOO'], true, false, true], + [['FOO'], false, true, true], + [[new Expression('something')], false, true, true], ]; } } diff --git a/tests/NodeVisitor/NodeRoutePropagatorTest.php b/tests/NodeVisitor/NodeRoutePropagatorTest.php index 74a0387..4280721 100644 --- a/tests/NodeVisitor/NodeRoutePropagatorTest.php +++ b/tests/NodeVisitor/NodeRoutePropagatorTest.php @@ -1,28 +1,19 @@ parent->addChild($this->node); } - /** - * @dataProvider getTestData - */ + #[DataProvider('getTestData')] public function testVisit($childRoute, $parentRoute, $expectedParentRoute): void { $this->node->setRoute($childRoute); @@ -45,7 +34,7 @@ public function testVisit($childRoute, $parentRoute, $expectedParentRoute): void $this->assertEquals($expectedParentRoute, $this->parent->getRoute()); } - public function getTestData() + public static function getTestData(): array { return [ [null, 'some_route', 'some_route'], diff --git a/tests/phpunit.xml b/tests/phpunit.xml index 29e17bc..c3a2af7 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -1,26 +1,24 @@ - - - - - - + + - - ./Tests + + ./tests/ - - - ./ - - ./tests - ./vendor - - - + + + src + + - - - + + +