diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 4a3e8ace..6be5d587 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -3,4 +3,3 @@ | Is bugfix? | ✔️/❌ | New feature? | ✔️/❌ | Breaks BC? | ✔️/❌ -| Fixed issues | comma-separated list of tickets # fixed by the PR, if any diff --git a/.github/workflows/bc.yml_ b/.github/workflows/bc.yml_ index 35b3a862..00041a9f 100644 --- a/.github/workflows/bc.yml_ +++ b/.github/workflows/bc.yml_ @@ -1,15 +1,33 @@ on: - - pull_request - - push + pull_request: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + - 'infection.json.dist' + - 'phpunit.xml.dist' + - 'psalm.xml' + push: + branches: ['master'] + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + - 'infection.json.dist' + - 'phpunit.xml.dist' + - 'psalm.xml' name: backwards compatibility + jobs: - roave_bc_check: - name: Roave BC Check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: fetch tags - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - - name: Roave BC Check - uses: docker://nyholm/roave-bc-check-ga + roave_bc_check: + uses: yiisoft/actions/.github/workflows/bc.yml@master + with: + os: >- + ['ubuntu-latest'] + php: >- + ['8.1'] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bf09d1be..9abb293d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ on: - 'psalm.xml' push: - branches: [ 'master' ] + branches: ['master'] paths-ignore: - 'docs/**' - 'README.md' @@ -26,7 +26,8 @@ jobs: phpunit: uses: yiisoft/actions/.github/workflows/phpunit.yml@master with: + ini-values: pcov.directory=$GITHUB_WORKSPACE, pcov.exclude=#^(?!($GITHUB_WORKSPACE/config/|$GITHUB_WORKSPACE/src/)).*# os: >- ['ubuntu-latest'] php: >- - ['8.0', '8.1', '8.2'] + ['8.1', '8.2', '8.3'] diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index 220a77a8..a857bce6 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -11,7 +11,7 @@ on: - 'psalm.xml' push: - branches: [ 'master' ] + branches: ['master'] paths-ignore: - 'docs/**' - 'README.md' @@ -31,4 +31,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.0', '8.1', '8.2'] + ['8.1', '8.2', '8.3'] diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml index d54b180a..a6873e2e 100644 --- a/.github/workflows/mutation.yml +++ b/.github/workflows/mutation.yml @@ -9,7 +9,7 @@ on: - 'psalm.xml' push: - branches: [ 'master' ] + branches: ['master'] paths-ignore: - 'docs/**' - 'README.md' @@ -27,6 +27,6 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.0', '8.1', '8.2'] + ['8.3'] secrets: STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index bd79331d..35411d0a 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -20,4 +20,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.2'] + ['8.3'] diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 7a1e25ab..e33eca86 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -10,7 +10,7 @@ on: - 'phpunit.xml.dist' push: - branches: [ 'master' ] + branches: ['master'] paths-ignore: - 'docs/**' - 'README.md' @@ -29,4 +29,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.0', '8.1', '8.2'] + ['8.1', '8.2', '8.3'] diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 3507ee4b..2b695c2e 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -10,7 +10,7 @@ build: environment: php: - version: 8.0.18 + version: 8.1.26 ini: xdebug.mode: coverage diff --git a/composer.json b/composer.json index b4f1e0fe..3f7fbd6c 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": "^8.0", + "php": "^8.1", "psr/container": "^1.0|^2.0", "psr/log": "^2.0|^3.0", "symfony/console": "^5.4|^6.0", @@ -35,14 +35,14 @@ "yiisoft/injector": "^1.0" }, "require-dev": { - "maglnet/composer-require-checker": "^4.2", - "phpunit/phpunit": "^9.5", + "maglnet/composer-require-checker": "^4.7", + "phpunit/phpunit": "^10.5", "rector/rector": "^0.19.0", - "roave/infection-static-analysis-plugin": "^1.16", + "roave/infection-static-analysis-plugin": "^1.34", "spatie/phpunit-watcher": "^1.23", - "vimeo/psalm": "^4.30|^5.8", + "vimeo/psalm": "^5.20", "yiisoft/test-support": "^3.0", - "yiisoft/yii-debug": "dev-master|dev-php80" + "yiisoft/yii-debug": "dev-master" }, "suggest": { "ext-pcntl": "Need for process signals" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d8adf3b0..6da3c15a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,26 +1,34 @@ - - + - - - ./src - - + + + + - + ./tests/Unit - + ./tests/Integration + + + + ./src + ./config + + diff --git a/rector.php b/rector.php index c80d86e9..90fea6ba 100644 --- a/rector.php +++ b/rector.php @@ -6,6 +6,7 @@ use Rector\Config\RectorConfig; use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; +use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; use Rector\Set\ValueObject\LevelSetList; return static function (RectorConfig $rectorConfig): void { @@ -19,11 +20,12 @@ // define sets of rules $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_80, + LevelSetList::UP_TO_PHP_81, ]); $rectorConfig->skip([ ClosureToArrowFunctionRector::class, JsonThrowOnErrorRector::class, + ReadOnlyPropertyRector::class, ]); }; diff --git a/src/Enum/JobStatus.php b/src/Enum/JobStatus.php index 50c46151..beca6c3c 100644 --- a/src/Enum/JobStatus.php +++ b/src/Enum/JobStatus.php @@ -8,9 +8,9 @@ class JobStatus { - public const WAITING = 1; - public const RESERVED = 2; - public const DONE = 3; + final public const WAITING = 1; + final public const RESERVED = 2; + final public const DONE = 3; protected int $status; diff --git a/tests/App/FakeHandler.php b/tests/App/FakeHandler.php index 8c0024f1..b2d2e49c 100644 --- a/tests/App/FakeHandler.php +++ b/tests/App/FakeHandler.php @@ -31,7 +31,7 @@ public static function staticExecute(MessageInterface $message): void self::$processedMessages[] = $message; } - public function executeWithException(MessageInterface $message): void + public function executeWithException(MessageInterface $message): never { throw new RuntimeException('Test exception'); } diff --git a/tests/TestCase.php b/tests/TestCase.php index d9f09e8b..8f64bd8c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -163,12 +163,12 @@ protected function getMessageHandlers(): array { return [ 'simple' => fn () => $this->executionTimes++, - 'exceptional' => function () { + 'exceptional' => function (): never { $this->executionTimes++; throw new RuntimeException('test'); }, - 'retryable' => function () { + 'retryable' => function (): never { $this->executionTimes++; throw new RuntimeException('test'); diff --git a/tests/Unit/JobStatusTest.php b/tests/Unit/JobStatusTest.php index d52bfc42..f0343745 100644 --- a/tests/Unit/JobStatusTest.php +++ b/tests/Unit/JobStatusTest.php @@ -4,6 +4,7 @@ namespace Yiisoft\Queue\Tests\Unit; +use PHPUnit\Framework\Attributes\DataProvider; use Yiisoft\Queue\Enum\JobStatus; use Yiisoft\Queue\Exception\InvalidStatusException; use Yiisoft\Queue\Tests\TestCase; @@ -11,7 +12,7 @@ final class JobStatusTest extends TestCase { - public function getStatusPairs(): array + public static function getStatusPairs(): array { return [ 'waiting' => [ @@ -41,9 +42,7 @@ public function getStatusPairs(): array ]; } - /** - * @dataProvider getStatusPairs - */ + #[DataProvider('getStatusPairs')] public function testInstanceValue(string $statusName, string $positiveMethod, array $negatives): void { $status = JobStatus::$statusName(); diff --git a/tests/Unit/Middleware/Consume/InvalidMiddlewareDefinitionExceptionTest.php b/tests/Unit/Middleware/Consume/InvalidMiddlewareDefinitionExceptionTest.php index b706bbff..756c616d 100644 --- a/tests/Unit/Middleware/Consume/InvalidMiddlewareDefinitionExceptionTest.php +++ b/tests/Unit/Middleware/Consume/InvalidMiddlewareDefinitionExceptionTest.php @@ -4,6 +4,7 @@ namespace Yiisoft\Queue\Tests\Unit\Middleware\Consume; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; use Yiisoft\Queue\Middleware\InvalidMiddlewareDefinitionException; @@ -11,7 +12,7 @@ final class InvalidMiddlewareDefinitionExceptionTest extends TestCase { - public function dataBase(): array + public static function dataBase(): array { return [ [ @@ -33,16 +34,14 @@ public function dataBase(): array ]; } - /** - * @dataProvider dataBase - */ + #[DataProvider('dataBase')] public function testBase(mixed $definition, string $expected): void { $exception = new InvalidMiddlewareDefinitionException($definition); self::assertStringEndsWith('. Got ' . $expected . '.', $exception->getMessage()); } - public function dataUnknownDefinition(): array + public static function dataUnknownDefinition(): array { return [ [42], @@ -50,9 +49,7 @@ public function dataUnknownDefinition(): array ]; } - /** - * @dataProvider dataUnknownDefinition - */ + #[DataProvider('dataUnknownDefinition')] public function testUnknownDefinition(mixed $definition): void { $exception = new InvalidMiddlewareDefinitionException($definition); diff --git a/tests/Unit/Middleware/Consume/MiddlewareDispatcherTest.php b/tests/Unit/Middleware/Consume/MiddlewareDispatcherTest.php index 383db050..15d1356c 100644 --- a/tests/Unit/Middleware/Consume/MiddlewareDispatcherTest.php +++ b/tests/Unit/Middleware/Consume/MiddlewareDispatcherTest.php @@ -4,6 +4,7 @@ namespace Yiisoft\Queue\Tests\Unit\Middleware\Consume; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Yiisoft\Test\Support\Container\SimpleContainer; @@ -103,7 +104,7 @@ public function testMiddlewareStackInterrupted(): void $this->assertSame('first', $request->getMessage()->getData()); } - public function dataHasMiddlewares(): array + public static function dataHasMiddlewares(): array { return [ [[], false], @@ -111,9 +112,7 @@ public function dataHasMiddlewares(): array ]; } - /** - * @dataProvider dataHasMiddlewares - */ + #[DataProvider('dataHasMiddlewares')] public function testHasMiddlewares(array $definitions, bool $expected): void { self::assertSame( diff --git a/tests/Unit/Middleware/Consume/MiddlewareFactoryTest.php b/tests/Unit/Middleware/Consume/MiddlewareFactoryTest.php index 5278acb3..d61919cb 100644 --- a/tests/Unit/Middleware/Consume/MiddlewareFactoryTest.php +++ b/tests/Unit/Middleware/Consume/MiddlewareFactoryTest.php @@ -4,6 +4,7 @@ namespace Yiisoft\Queue\Tests\Unit\Middleware\Consume; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Yiisoft\Test\Support\Container\SimpleContainer; @@ -131,7 +132,7 @@ public function testInvalidMiddlewareWithWrongCallable(): void ); } - public function invalidMiddlewareDefinitionProvider(): array + public static function invalidMiddlewareDefinitionProvider(): array { return [ 'wrong string' => ['test'], @@ -145,9 +146,7 @@ public function invalidMiddlewareDefinitionProvider(): array ]; } - /** - * @dataProvider invalidMiddlewareDefinitionProvider - */ + #[DataProvider('invalidMiddlewareDefinitionProvider')] public function testInvalidMiddleware(mixed $definition): void { $this->expectException(InvalidMiddlewareDefinitionException::class); diff --git a/tests/Unit/Middleware/FailureHandling/Implementation/ExponentialDelayMiddlewareTest.php b/tests/Unit/Middleware/FailureHandling/Implementation/ExponentialDelayMiddlewareTest.php index 7629cb8f..5d24f46a 100644 --- a/tests/Unit/Middleware/FailureHandling/Implementation/ExponentialDelayMiddlewareTest.php +++ b/tests/Unit/Middleware/FailureHandling/Implementation/ExponentialDelayMiddlewareTest.php @@ -6,6 +6,7 @@ use Exception; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\DataProvider; use Yiisoft\Queue\Message\Message; use Yiisoft\Queue\Middleware\FailureHandling\FailureHandlingRequest; use Yiisoft\Queue\Middleware\FailureHandling\Implementation\ExponentialDelayMiddleware; @@ -16,11 +17,8 @@ class ExponentialDelayMiddlewareTest extends TestCase { - public function constructorRequirementsProvider(): array + public static function constructorRequirementsProvider(): array { - $queue = $this->createMock(QueueInterface::class); - $middleware = $this->createMock(DelayMiddlewareInterface::class); - return [ [ true, @@ -30,8 +28,6 @@ public function constructorRequirementsProvider(): array 0.001, 1, 0.01, - $middleware, - $queue, ], ], [ @@ -42,8 +38,6 @@ public function constructorRequirementsProvider(): array PHP_INT_MAX, PHP_INT_MAX, PHP_INT_MAX, - $middleware, - $queue, ], ], [ @@ -54,8 +48,6 @@ public function constructorRequirementsProvider(): array 0, 1, 0.01, - $middleware, - $queue, ], ], [ @@ -66,8 +58,6 @@ public function constructorRequirementsProvider(): array 0, 1, 0.01, - $middleware, - $queue, ], ], [ @@ -78,8 +68,6 @@ public function constructorRequirementsProvider(): array 0, 0, 0.01, - $middleware, - $queue, ], ], [ @@ -90,8 +78,6 @@ public function constructorRequirementsProvider(): array 0, 0.01, 0, - $middleware, - $queue, ], ], [ @@ -102,8 +88,6 @@ public function constructorRequirementsProvider(): array PHP_INT_MAX, PHP_INT_MAX, PHP_INT_MAX, - $middleware, - $queue, ], ], [ @@ -114,8 +98,6 @@ public function constructorRequirementsProvider(): array PHP_INT_MAX, 0, PHP_INT_MAX, - $middleware, - $queue, ], ], [ @@ -126,18 +108,17 @@ public function constructorRequirementsProvider(): array PHP_INT_MAX, PHP_INT_MAX, 0, - $middleware, - $queue, ], ], ]; } - /** - * @dataProvider constructorRequirementsProvider - */ + #[DataProvider('constructorRequirementsProvider')] public function testConstructorRequirements(bool $success, array $arguments): void { + $arguments[] = $this->createMock(DelayMiddlewareInterface::class); + $arguments[] = $this->createMock(QueueInterface::class); + if (!$success) { $this->expectException(InvalidArgumentException::class); } diff --git a/tests/Unit/Middleware/FailureHandling/Implementation/SendAgainMiddlewareTest.php b/tests/Unit/Middleware/FailureHandling/Implementation/SendAgainMiddlewareTest.php index b0393412..57dc4eb9 100644 --- a/tests/Unit/Middleware/FailureHandling/Implementation/SendAgainMiddlewareTest.php +++ b/tests/Unit/Middleware/FailureHandling/Implementation/SendAgainMiddlewareTest.php @@ -6,6 +6,7 @@ use Exception; use PHPUnit\Framework\Assert; +use PHPUnit\Framework\Attributes\DataProvider; use RuntimeException; use Yiisoft\Queue\Message\Message; use Yiisoft\Queue\Message\MessageInterface; @@ -23,10 +24,10 @@ class SendAgainMiddlewareTest extends TestCase private const EXPONENTIAL_STRATEGY_DELAY_INITIAL = 1; private const EXPONENTIAL_STRATEGY_DELAY_MAXIMUM = 5; private const EXPONENTIAL_STRATEGY_EXPONENT = 2; - public const KEY_EXPONENTIAL_ATTEMPTS = ExponentialDelayMiddleware::META_KEY_ATTEMPTS . '-test'; - public const KEY_EXPONENTIAL_DELAY = ExponentialDelayMiddleware::META_KEY_DELAY . '-test'; + final public const KEY_EXPONENTIAL_ATTEMPTS = ExponentialDelayMiddleware::META_KEY_ATTEMPTS . '-test'; + final public const KEY_EXPONENTIAL_DELAY = ExponentialDelayMiddleware::META_KEY_DELAY . '-test'; - public function queueSendingStrategyProvider(): array + public static function queueSendingStrategyProvider(): array { return [ /*[ @@ -138,9 +139,7 @@ public function queueSendingStrategyProvider(): array ]; } - /** - * @dataProvider queueSendingStrategyProvider - */ + #[DataProvider('queueSendingStrategyProvider')] public function testQueueSendingStrategies( string $strategyName, bool $suites, diff --git a/tests/Unit/Middleware/FailureHandling/InvalidMiddlewareDefinitionExceptionTest.php b/tests/Unit/Middleware/FailureHandling/InvalidMiddlewareDefinitionExceptionTest.php index ef39bc8d..4eea3685 100644 --- a/tests/Unit/Middleware/FailureHandling/InvalidMiddlewareDefinitionExceptionTest.php +++ b/tests/Unit/Middleware/FailureHandling/InvalidMiddlewareDefinitionExceptionTest.php @@ -4,6 +4,7 @@ namespace Yiisoft\Queue\Tests\Unit\Middleware\FailureHandling; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; use Yiisoft\Queue\Middleware\InvalidMiddlewareDefinitionException; @@ -11,7 +12,7 @@ final class InvalidMiddlewareDefinitionExceptionTest extends TestCase { - public function dataBase(): array + public static function dataBase(): array { return [ [ @@ -33,16 +34,14 @@ public function dataBase(): array ]; } - /** - * @dataProvider dataBase - */ + #[DataProvider('dataBase')] public function testBase(mixed $definition, string $expected): void { $exception = new InvalidMiddlewareDefinitionException($definition); self::assertStringEndsWith('. Got ' . $expected . '.', $exception->getMessage()); } - public function dataUnknownDefinition(): array + public static function dataUnknownDefinition(): array { return [ [42], @@ -50,9 +49,7 @@ public function dataUnknownDefinition(): array ]; } - /** - * @dataProvider dataUnknownDefinition - */ + #[DataProvider('dataUnknownDefinition')] public function testUnknownDefinition(mixed $definition): void { $exception = new InvalidMiddlewareDefinitionException($definition); diff --git a/tests/Unit/Middleware/FailureHandling/MiddlewareFactoryTest.php b/tests/Unit/Middleware/FailureHandling/MiddlewareFactoryTest.php index 58e78f48..571ca037 100644 --- a/tests/Unit/Middleware/FailureHandling/MiddlewareFactoryTest.php +++ b/tests/Unit/Middleware/FailureHandling/MiddlewareFactoryTest.php @@ -5,6 +5,7 @@ namespace Yiisoft\Queue\Tests\Unit\Middleware\FailureHandling; use Exception; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use RuntimeException; @@ -115,7 +116,7 @@ public function testCreateWithTestCallableMiddleware(): void ); } - public function invalidMiddlewareDefinitionProvider(): array + public static function invalidMiddlewareDefinitionProvider(): array { return [ 'wrong string' => ['test'], @@ -129,9 +130,7 @@ public function invalidMiddlewareDefinitionProvider(): array ]; } - /** - * @dataProvider invalidMiddlewareDefinitionProvider - */ + #[DataProvider('invalidMiddlewareDefinitionProvider')] public function testInvalidMiddleware(mixed $definition): void { $this->expectException(InvalidMiddlewareDefinitionException::class); diff --git a/tests/Unit/Middleware/Push/InvalidMiddlewareDefinitionExceptionTest.php b/tests/Unit/Middleware/Push/InvalidMiddlewareDefinitionExceptionTest.php index 00fc2100..9cb940cf 100644 --- a/tests/Unit/Middleware/Push/InvalidMiddlewareDefinitionExceptionTest.php +++ b/tests/Unit/Middleware/Push/InvalidMiddlewareDefinitionExceptionTest.php @@ -4,6 +4,7 @@ namespace Yiisoft\Queue\Tests\Unit\Middleware\Push; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use stdClass; use Yiisoft\Queue\Middleware\InvalidMiddlewareDefinitionException; @@ -11,7 +12,7 @@ final class InvalidMiddlewareDefinitionExceptionTest extends TestCase { - public function dataBase(): array + public static function dataBase(): array { return [ [ @@ -33,16 +34,14 @@ public function dataBase(): array ]; } - /** - * @dataProvider dataBase - */ + #[DataProvider('dataBase')] public function testBase(mixed $definition, string $expected): void { $exception = new InvalidMiddlewareDefinitionException($definition); self::assertStringEndsWith('. Got ' . $expected . '.', $exception->getMessage()); } - public function dataUnknownDefinition(): array + public static function dataUnknownDefinition(): array { return [ [42], @@ -50,9 +49,7 @@ public function dataUnknownDefinition(): array ]; } - /** - * @dataProvider dataUnknownDefinition - */ + #[DataProvider('dataUnknownDefinition')] public function testUnknownDefinition(mixed $definition): void { $exception = new InvalidMiddlewareDefinitionException($definition); diff --git a/tests/Unit/Middleware/Push/MiddlewareDispatcherTest.php b/tests/Unit/Middleware/Push/MiddlewareDispatcherTest.php index 5eb8dc27..713bab4a 100644 --- a/tests/Unit/Middleware/Push/MiddlewareDispatcherTest.php +++ b/tests/Unit/Middleware/Push/MiddlewareDispatcherTest.php @@ -4,6 +4,7 @@ namespace Yiisoft\Queue\Tests\Unit\Middleware\Push; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Yiisoft\Test\Support\Container\SimpleContainer; @@ -111,7 +112,7 @@ public function testMiddlewareStackInterrupted(): void $this->assertSame('first', $request->getMessage()->getData()); } - public function dataHasMiddlewares(): array + public static function dataHasMiddlewares(): array { return [ [[], false], @@ -119,9 +120,7 @@ public function dataHasMiddlewares(): array ]; } - /** - * @dataProvider dataHasMiddlewares - */ + #[DataProvider('dataHasMiddlewares')] public function testHasMiddlewares(array $definitions, bool $expected): void { self::assertSame( diff --git a/tests/Unit/Middleware/Push/MiddlewareFactoryTest.php b/tests/Unit/Middleware/Push/MiddlewareFactoryTest.php index c5a3b673..c68bc6db 100644 --- a/tests/Unit/Middleware/Push/MiddlewareFactoryTest.php +++ b/tests/Unit/Middleware/Push/MiddlewareFactoryTest.php @@ -4,6 +4,7 @@ namespace Yiisoft\Queue\Tests\Unit\Middleware\Push; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Yiisoft\Test\Support\Container\SimpleContainer; @@ -106,7 +107,7 @@ public function testCreateWithTestCallableMiddleware(): void ); } - public function invalidMiddlewareDefinitionProvider(): array + public static function invalidMiddlewareDefinitionProvider(): array { return [ 'wrong string' => ['test'], @@ -120,9 +121,7 @@ public function invalidMiddlewareDefinitionProvider(): array ]; } - /** - * @dataProvider invalidMiddlewareDefinitionProvider - */ + #[DataProvider('invalidMiddlewareDefinitionProvider')] public function testInvalidMiddleware(mixed $definition): void { $this->expectException(InvalidMiddlewareDefinitionException::class); diff --git a/tests/Unit/WorkerTest.php b/tests/Unit/WorkerTest.php index 4187358f..c9ae1d6b 100644 --- a/tests/Unit/WorkerTest.php +++ b/tests/Unit/WorkerTest.php @@ -97,7 +97,7 @@ public function testJobExecutedWithStaticDefinitionHandler(): void $logger = new SimpleLogger(); $handler = new FakeHandler(); $container = new SimpleContainer([FakeHandler::class => $handler]); - $handlers = ['simple' => [FakeHandler::class, 'staticExecute']]; + $handlers = ['simple' => FakeHandler::staticExecute(...)]; $queue = $this->createMock(QueueInterface::class); $worker = $this->createWorkerByParams($handlers, $logger, $container);