diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 86439ed..92e613d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: coverage: xdebug - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Validate composer.json and composer.lock run: composer validate @@ -28,11 +28,11 @@ jobs: - name: Prepare Composer cache vars id: composer run: | - echo "::set-output name=cache_dir::$(composer config cache-files-dir)" - echo "::set-output name=cache_key::composer-$(date +'%Y-%m-%d')-${{ matrix.php }}${{ matrix.composer }}-" + echo "cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + echo "cache_key=composer-$(date +'%Y-%m-%d')-${{ matrix.php }}${{ matrix.composer }}-" >> $GITHUB_OUTPUT - name: Cache Composer dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.composer.outputs.cache_dir }} key: ${{ steps.composer.outputs.cache_key }}${{ hashFiles('**/composer.json') }} diff --git a/composer.json b/composer.json index 8f2db26..b4e4dba 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "require-dev": { "phpstan/phpstan": "^1.9", "squizlabs/php_codesniffer": "^3.7", - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^10.5|11.0.*" }, "suggest": { "ext-curl": "To send requests using cURL" diff --git a/phpstan.neon b/phpstan.neon index b6538de..76a88f6 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,3 +6,10 @@ parameters: - tests reportUnmatchedIgnoredErrors: false + ignoreErrors: + - + message: '#return type has no value type specified in iterable type array.#' + path: tests/*Test.php + - + message: '#with no value type specified in iterable type array.#' + path: tests/*Test.php diff --git a/phpunit.xml b/phpunit.xml index 81ab980..19a0020 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,22 +1,33 @@ + + + + + + + - - tests + + tests - + - src + src - + diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 4620648..0c09d52 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -7,6 +7,7 @@ use Kyto\Alibaba\Client; use Kyto\Alibaba\Exception\ResponseException; use Kyto\Alibaba\Util\Clock; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -37,10 +38,7 @@ public function tearDown(): void ); } - /** - * @dataProvider requestDataProvider - * @param mixed[] $responseData - */ + #[DataProvider('requestDataProvider')] public function testRequest(bool $isSuccess, string $endpoint, array $responseData): void { $timestamp = '2024-04-30 18:17:25'; @@ -86,10 +84,7 @@ public function testRequest(bool $isSuccess, string $endpoint, array $responseDa self::assertSame($responseData, $actual); } - /** - * @return mixed[] - */ - public function requestDataProvider(): array + public static function requestDataProvider(): array { return [ 'success' => [true, '/some/endpoint', ['successful' => 'response']], diff --git a/tests/Factory/CategoryFactoryTest.php b/tests/Factory/CategoryFactoryTest.php index e21ba71..6a53686 100644 --- a/tests/Factory/CategoryFactoryTest.php +++ b/tests/Factory/CategoryFactoryTest.php @@ -6,6 +6,7 @@ use Kyto\Alibaba\Factory\CategoryFactory; use Kyto\Alibaba\Model\Category; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class CategoryFactoryTest extends TestCase @@ -24,20 +25,14 @@ public function tearDown(): void ); } - /** - * @dataProvider createCategoryDataProvider - * @param mixed[] $data - */ + #[DataProvider('createCategoryDataProvider')] public function testCreateCategory(array $data, Category $expected): void { $actual = $this->categoryFactory->createCategory($data); self::assertEquals($expected, $actual); } - /** - * @return \Generator - */ - public function createCategoryDataProvider(): \Generator + public static function createCategoryDataProvider(): \Generator { $data = [ 'result' => [ diff --git a/tests/Util/ClockTest.php b/tests/Util/ClockTest.php index a896faa..4a36a44 100644 --- a/tests/Util/ClockTest.php +++ b/tests/Util/ClockTest.php @@ -5,6 +5,7 @@ namespace Kyto\Alibaba\Tests\Util; use Kyto\Alibaba\Util\Clock; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ClockTest extends TestCase @@ -23,9 +24,7 @@ public function tearDown(): void ); } - /** - * @dataProvider nowDataProvider - */ + #[DataProvider('nowDataProvider')] public function testNow(?string $timezoneName, ?\DateTimeZone $timezone): void { $actual = $this->clock->now($timezoneName); @@ -37,10 +36,7 @@ public function testNow(?string $timezoneName, ?\DateTimeZone $timezone): void ); } - /** - * @return mixed[] - */ - public function nowDataProvider(): array + public static function nowDataProvider(): array { return [ 'default timezone' => [null, null],