From 85ca0ac5ce149448ec775905b84faeda61fb1c25 Mon Sep 17 00:00:00 2001 From: Dieter Beck Date: Mon, 5 Aug 2024 09:21:51 +0200 Subject: [PATCH] Update PHPUnit (9 --> 10) (#800) * Bump PHPUnit version * Apply cs-fixer * Update rule sets regarding PHP and PHPUnit --- .php-cs-fixer.php | 3 ++- composer.json | 2 +- src/DependencyInjection/KnpPaginatorExtension.php | 2 +- tests/Pagination/SlidingPaginationTest.php | 13 +++++-------- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 7a82405..bbea938 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -11,7 +11,8 @@ '@Symfony' => true, '@Symfony:risky' => true, '@PHP80Migration:risky' => true, - '@PHPUnit84Migration:risky' => true, + '@PHP81Migration' => true, + '@PHPUnit100Migration:risky' => true, 'ordered_imports' => true, 'declare_strict_types' => false, 'native_function_invocation' => ['include' => ['@all']], diff --git a/composer.json b/composer.json index 53b8c95..fad0d54 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ }, "require-dev": { "phpstan/phpstan": "^1.11", - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^10.5 || ^11.3", "symfony/expression-language": "^6.4 || ^7.0", "symfony/templating": "^6.4 || ^7.0" }, diff --git a/src/DependencyInjection/KnpPaginatorExtension.php b/src/DependencyInjection/KnpPaginatorExtension.php index 04989d1..5a1b629 100644 --- a/src/DependencyInjection/KnpPaginatorExtension.php +++ b/src/DependencyInjection/KnpPaginatorExtension.php @@ -7,8 +7,8 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Extension\Extension; +use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; final class KnpPaginatorExtension extends Extension { diff --git a/tests/Pagination/SlidingPaginationTest.php b/tests/Pagination/SlidingPaginationTest.php index e4d74ad..acb5435 100644 --- a/tests/Pagination/SlidingPaginationTest.php +++ b/tests/Pagination/SlidingPaginationTest.php @@ -5,6 +5,7 @@ namespace Knp\Bundle\PaginatorBundle\Tests\Pagination; use Knp\Bundle\PaginatorBundle\Pagination\SlidingPagination; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; /** @@ -19,9 +20,7 @@ protected function setUp(): void $this->pagination = new SlidingPagination([]); } - /** - * @dataProvider getPageLimitData - */ + #[DataProvider('getPageLimitData')] public function testGetPageCount(int $expected, int $totalItemCount, int $itemsPerPage, ?int $pageLimit): void { $this->pagination->setTotalItemCount($totalItemCount); @@ -31,9 +30,7 @@ public function testGetPageCount(int $expected, int $totalItemCount, int $itemsP $this->assertSame($expected, $this->pagination->getPageCount()); } - /** - * @dataProvider getSortedData - */ + #[DataProvider('getSortedData')] public function testSorted(bool $expected, string $sort, string $direction, $key): void { $this->pagination->setPaginatorOptions([ @@ -46,7 +43,7 @@ public function testSorted(bool $expected, string $sort, string $direction, $key $this->assertSame($expected, $this->pagination->isSorted($key)); } - public function getPageLimitData(): array + public static function getPageLimitData(): array { return [ 'Normal' => [5, 120, 25, null], @@ -56,7 +53,7 @@ public function getPageLimitData(): array ]; } - public function getSortedData(): \Generator + public static function getSortedData(): \Generator { yield [true, 'title', 'asc', null]; yield [true, 'title', 'asc', 'title'];