From ed8f464c20ebc27ee8a15ca2457eb38dd73ffe9b Mon Sep 17 00:00:00 2001 From: Reliq Date: Sat, 16 Mar 2024 16:52:25 +0100 Subject: [PATCH] laravel 11 upgrade (#6) * remove deprecated phpunit --verbose option * drop support for laravel <11 * + php 8.3 --- .github/workflows/test.yml | 4 +- composer.json | 14 +++--- phpunit.xml | 15 +++---- tests/Unit/Helper/HtmlTest.php | 16 +++---- tests/Unit/ResultTest.php | 6 +-- tests/Unit/Service/ConfigProviderTest.php | 15 +------ tests/Unit/Service/DescendantsFinderTest.php | 45 +++++++++----------- tests/Unit/Service/VersionProviderTest.php | 30 +------------ 8 files changed, 49 insertions(+), 96 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cbc1443..545dba3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,10 +9,10 @@ jobs: fail-fast: false max-parallel: 10 matrix: - laravel-version: ['^8.0', '^9.0', '^10.0'] + laravel-version: ['^11.0'] preference: ['stable'] experimental: [false] - php-version: ['8.2'] + php-version: ['8.2', '8.3'] exclude: - laravel-version: ^10.0 php-version: 8.0 diff --git a/composer.json b/composer.json index 52a32e1..c51e7c6 100644 --- a/composer.json +++ b/composer.json @@ -20,18 +20,18 @@ ], "require": { "php": "^8.2", - "illuminate/support": "^8.0 || ^9.0 || ^10.0", - "monolog/monolog": "1.24 - 3", + "illuminate/support": "^11.0", + "monolog/monolog": "^3.5", "ext-json": "*", - "spatie/laravel-sitemap": "^6.0", + "spatie/laravel-sitemap": "^7.0", "anhskohbo/no-captcha": "^3.1||dev-master" }, "require-dev": { "roave/security-advisories": "dev-latest", - "phpunit/phpunit": "^9.3", + "phpunit/phpunit": "^11.0", "phpro/grumphp": "^2.0", "phpspec/prophecy-phpunit": "^2.0", - "orchestra/testbench": "6 - 8", + "orchestra/testbench": "^9.0", "laravel/pint": "^1.13", "yieldstudio/grumphp-laravel-pint": "^1.0" }, @@ -50,8 +50,8 @@ }, "scripts": { "test": "phpunit", - "test:ci": "phpunit --verbose --coverage-clover=./build/coverage.xml", - "test:unit": "phpunit --testsuite=Unit --verbose --coverage-clover=./build/coverage.xml" + "test:ci": "phpunit --coverage-clover=./build/coverage.xml", + "test:unit": "phpunit --testsuite=Unit --coverage-clover=./build/coverage.xml" }, "config": { "allow-plugins": { diff --git a/phpunit.xml b/phpunit.xml index 047444c..babd8ed 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,18 +1,12 @@ - - - - src/ - + + - - tests - tests/Unit @@ -25,4 +19,9 @@ + + + src/ + + diff --git a/tests/Unit/Helper/HtmlTest.php b/tests/Unit/Helper/HtmlTest.php index f1ceed2..c51d37c 100644 --- a/tests/Unit/Helper/HtmlTest.php +++ b/tests/Unit/Helper/HtmlTest.php @@ -5,17 +5,16 @@ namespace ReliqArts\Tests\Unit\Helper; use Exception; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use ReliqArts\Contract\HtmlHelper; use ReliqArts\Helper\Html; use ReliqArts\Tests\TestCase; /** - * Class HtmlTest. - * - * @coversDefaultClass \ReliqArts\Helper\Html - * * @internal */ +#[CoversClass(Html::class)] final class HtmlTest extends TestCase { private HtmlHelper $subject; @@ -28,18 +27,15 @@ protected function setUp(): void } /** - * @covers ::stripTags - * - * @dataProvider stripTagsDataProvider - * * @throws Exception */ - public function testStripTags(string $html, string $expectedResult, string $allowedTags = null): void + #[DataProvider('stripTagsDataProvider')] + public function testStripTags(string $html, string $expectedResult, ?string $allowedTags = null): void { self::assertSame($expectedResult, $this->subject->stripTags($html, $allowedTags)); } - public function stripTagsDataProvider(): array + public static function stripTagsDataProvider(): array { return [ 'simple' => [ diff --git a/tests/Unit/ResultTest.php b/tests/Unit/ResultTest.php index 19e7344..978a096 100644 --- a/tests/Unit/ResultTest.php +++ b/tests/Unit/ResultTest.php @@ -5,16 +5,14 @@ namespace ReliqArts\Tests\Unit; use Exception; +use PHPUnit\Framework\Attributes\CoversClass; use ReliqArts\Result; use ReliqArts\Tests\TestCase; /** - * Class ResultTest. - * - * @coversDefaultClass \ReliqArts\Result - * * @internal */ +#[CoversClass(Result::class)] final class ResultTest extends TestCase { private Result $subject; diff --git a/tests/Unit/Service/ConfigProviderTest.php b/tests/Unit/Service/ConfigProviderTest.php index c47f607..e41f8a7 100644 --- a/tests/Unit/Service/ConfigProviderTest.php +++ b/tests/Unit/Service/ConfigProviderTest.php @@ -6,6 +6,7 @@ use Exception; use Illuminate\Contracts\Config\Repository; +use PHPUnit\Framework\Attributes\CoversClass; use Prophecy\Exception\Doubler\DoubleException; use Prophecy\Exception\Doubler\InterfaceNotFoundException; use Prophecy\Exception\Prophecy\ObjectProphecyException; @@ -14,13 +15,7 @@ use ReliqArts\Service\ConfigProvider; use ReliqArts\Tests\TestCase; -/** - * Class ConfigProviderTest. - * - * @coversDefaultClass \ReliqArts\Service\ConfigProvider - * - * @internal - */ +#[CoversClass(ConfigProvider::class)] final class ConfigProviderTest extends TestCase { use ProphecyTrait; @@ -46,9 +41,6 @@ protected function setUp(): void } /** - * @covers ::__construct - * @covers ::get - * * @throws Exception */ public function testGet(): void @@ -69,9 +61,6 @@ public function testGet(): void } /** - * @covers ::__construct - * @covers ::get - * * @throws Exception */ public function testGetWhenKeyIsEmpty(): void diff --git a/tests/Unit/Service/DescendantsFinderTest.php b/tests/Unit/Service/DescendantsFinderTest.php index cd67e13..74a8a05 100644 --- a/tests/Unit/Service/DescendantsFinderTest.php +++ b/tests/Unit/Service/DescendantsFinderTest.php @@ -10,23 +10,20 @@ use Exception; use Illuminate\Support\Collection; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use ReliqArts\Contract\DescendantsFinder as DescendantsFinderContract; use ReliqArts\Service\DescendantsFinder; use ReliqArts\Tests\TestCase; use stdClass; -/** - * @coversDefaultClass \ReliqArts\Service\DescendantsFinder - */ +#[CoversClass(DescendantsFinder::class)] final class DescendantsFinderTest extends TestCase { /** - * @covers ::findDescendantsInCollection - * - * @dataProvider dataProvider - * * @throws Exception */ + #[DataProvider('dataProvider')] public function testFindDescendants( int $parentId, Collection $collection, @@ -44,22 +41,22 @@ public function testFindDescendants( } } - public function dataProvider(): array + public static function dataProvider(): array { - $item1 = $this->getItem(1); - $item2 = $this->getItem(2, 1); - $item3 = $this->getItem(3, 1); - $item4 = $this->getItem(4); - $item5 = $this->getItem(5, 4); - $item6 = $this->getItem(6, 7); - $item7 = $this->getItem(7, 5); - $item8 = $this->getItem(8, 7); - $item9 = $this->getItem(9, 8, 'foo'); - $item10 = $this->getItem(10, 9, 'foo'); - $item11 = $this->getItem(11, 8, 'foo'); - $item12 = $this->getItem(12, 12); - $item13 = $this->getItem(13, 12); - $item14 = $this->getItem(14, 14); + $item1 = self::getItem(1); + $item2 = self::getItem(2, 1); + $item3 = self::getItem(3, 1); + $item4 = self::getItem(4); + $item5 = self::getItem(5, 4); + $item6 = self::getItem(6, 7); + $item7 = self::getItem(7, 5); + $item8 = self::getItem(8, 7); + $item9 = self::getItem(9, 8, 'foo'); + $item10 = self::getItem(10, 9, 'foo'); + $item11 = self::getItem(11, 8, 'foo'); + $item12 = self::getItem(12, 12); + $item13 = self::getItem(13, 12); + $item14 = self::getItem(14, 14); $collection = collect( [ @@ -129,9 +126,9 @@ public function dataProvider(): array ]; } - private function getItem( + private static function getItem( int $id, - int $parentId = null, + ?int $parentId = null, string $parentIdAttributeName = DescendantsFinderContract::DEFAULT_PARENT_ID_ATTRIBUTE ): stdClass { $item = new stdClass(); diff --git a/tests/Unit/Service/VersionProviderTest.php b/tests/Unit/Service/VersionProviderTest.php index 2b8889c..f687908 100644 --- a/tests/Unit/Service/VersionProviderTest.php +++ b/tests/Unit/Service/VersionProviderTest.php @@ -10,6 +10,7 @@ use Exception; use Illuminate\Contracts\Filesystem\FileNotFoundException; +use PHPUnit\Framework\Attributes\CoversClass; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; @@ -20,12 +21,9 @@ use ReliqArts\Tests\TestCase; /** - * Class VersionProviderTest. - * - * @coversDefaultClass \ReliqArts\Service\VersionProvider - * * @internal */ +#[CoversClass(VersionProvider::class)] final class VersionProviderTest extends TestCase { use ProphecyTrait; @@ -71,10 +69,6 @@ static function ($key) { } /** - * @covers ::__construct - * @covers ::cleanText - * @covers ::getBuildNumber - * * @throws Exception */ public function testGetBuildNumber(): void @@ -94,11 +88,6 @@ public function testGetBuildNumber(): void } /** - * @covers ::__construct - * @covers ::cleanText - * @covers ::getBuildNumber - * @covers ::logWarning - * * @throws Exception */ public function testGetBuildNumberWhenBuildNumberFileDoesNotExist(): void @@ -130,10 +119,6 @@ static function ($message) use ($buildFile) { } /** - * @covers ::__construct - * @covers ::cleanText - * @covers ::getVersionNumber - * * @throws Exception */ public function testGetVersionNumber(): void @@ -153,11 +138,6 @@ public function testGetVersionNumber(): void } /** - * @covers ::__construct - * @covers ::cleanText - * @covers ::getVersionNumber - * @covers ::logWarning - * * @throws Exception */ public function testGetVersionNumberWhenVersionNumberFileDoesNotExist(): void @@ -189,12 +169,6 @@ static function ($message) use ($versionFile) { } /** - * @covers ::__construct - * @covers ::cleanText - * @covers ::getBuildNumber - * @covers ::getVersion - * @covers ::getVersionNumber - * * @throws Exception */ public function testGetVersion(): void