diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f5bbee0f..48cb4f16c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: - php-version: '7.1' + php-version: '7.4' coverage: none extensions: mongodb, redis, :xdebug ini-values: memory_limit=2048M @@ -63,7 +63,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: - php-version: '7.1' + php-version: '7.4' coverage: none extensions: mongodb, redis, :xdebug ini-values: memory_limit=2048M @@ -78,27 +78,10 @@ jobs: tests: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: php: ['7.4'] include: - - php: 7.1 - symfony_version: 4.3.* - unit_tests: true - functional_tests: false - rdkafka_tests: false - prepare_container: false - - php: 7.2 - symfony_version: 4.3.* - unit_tests: true - functional_tests: false - rdkafka_tests: false - prepare_container: false - - php: 7.2 - symfony_version: 5.0.* - unit_tests: true - functional_tests: false - rdkafka_tests: false - prepare_container: false - php: 7.3 symfony_version: 4.3.* unit_tests: true diff --git a/.gitignore b/.gitignore index 2bd575f69..e92454ae9 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ var .php_cs .php_cs.cache composer.lock +.phpunit.result.cache diff --git a/composer.json b/composer.json index 21cf655c1..b1ba9ff8b 100644 --- a/composer.json +++ b/composer.json @@ -9,12 +9,12 @@ "phpstan": "bin/phpstan analyse --memory-limit=512M -c phpstan.neon" }, "require": { - "php": "^7.1.3", + "php": "^7.3", "ext-amqp": "^1.9.3", "ext-gearman": "^2.0", "ext-mongodb": "^1.5", - "ext-rdkafka": "^3.0.3", + "ext-rdkafka": "^3.0.3|^4.0|^5.0", "queue-interop/amqp-interop": "^0.8", "queue-interop/queue-interop": "^0.7|^0.8", @@ -41,7 +41,8 @@ "datadog/php-datadogstatsd": "^1.3" }, "require-dev": { - "phpunit/phpunit": "^7.5", + "ext-pcntl": "*", + "phpunit/phpunit": "^9.5", "phpstan/phpstan": "^0.12", "queue-interop/queue-spec": "^0.6", "symfony/browser-kit": "^3.4|^4", @@ -60,7 +61,9 @@ "doctrine/mongodb-odm-bundle": "^3.5|^4", "alcaeus/mongo-php-adapter": "^1.0", "kwn/php-rdkafka-stubs": "^1.0.2 | ^2.0", - "friendsofphp/php-cs-fixer": "^2" + "friendsofphp/php-cs-fixer": "^2", + "dms/phpunit-arraysubset-asserts": "^0.2.1", + "phpspec/prophecy-phpunit": "^2.0" }, "autoload": { "psr-4": { diff --git a/docs/bundle/functional_testing.md b/docs/bundle/functional_testing.md index 7e81f8eaa..ca475a2e4 100644 --- a/docs/bundle/functional_testing.md +++ b/docs/bundle/functional_testing.md @@ -57,7 +57,7 @@ class FooTest extends WebTestCase /** @var \Symfony\Bundle\FrameworkBundle\Client */ private $client; - public function setUp() + public function setUp(): void { $this->client = static::createClient(); } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 43abe1afc..1cd38e68b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,7 +2,7 @@ - - + + . - - ./vendor - - - + + + ./vendor + + diff --git a/pkg/amqp-bunny/Tests/AmqpConnectionFactoryTest.php b/pkg/amqp-bunny/Tests/AmqpConnectionFactoryTest.php index 56d819206..da54dfc0d 100644 --- a/pkg/amqp-bunny/Tests/AmqpConnectionFactoryTest.php +++ b/pkg/amqp-bunny/Tests/AmqpConnectionFactoryTest.php @@ -5,12 +5,14 @@ use Enqueue\AmqpBunny\AmqpConnectionFactory; use Enqueue\AmqpTools\RabbitMqDlxDelayStrategy; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\ConnectionFactory; use PHPUnit\Framework\TestCase; class AmqpConnectionFactoryTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementConnectionFactoryInterface() { diff --git a/pkg/amqp-bunny/composer.json b/pkg/amqp-bunny/composer.json index 8c8d053be..01d6a8c4a 100644 --- a/pkg/amqp-bunny/composer.json +++ b/pkg/amqp-bunny/composer.json @@ -6,14 +6,14 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "queue-interop/amqp-interop": "^0.8", "queue-interop/queue-interop": "^0.8", "bunny/bunny": "^0.4", "enqueue/amqp-tools": "^0.10" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "enqueue/null": "0.10.x-dev", "queue-interop/queue-spec": "^0.6" diff --git a/pkg/amqp-ext/Tests/AmqpConnectionFactoryTest.php b/pkg/amqp-ext/Tests/AmqpConnectionFactoryTest.php index 0bceae358..7ea58f947 100644 --- a/pkg/amqp-ext/Tests/AmqpConnectionFactoryTest.php +++ b/pkg/amqp-ext/Tests/AmqpConnectionFactoryTest.php @@ -6,12 +6,14 @@ use Enqueue\AmqpExt\AmqpContext; use Enqueue\AmqpTools\RabbitMqDlxDelayStrategy; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\ConnectionFactory; use PHPUnit\Framework\TestCase; class AmqpConnectionFactoryTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementConnectionFactoryInterface() { @@ -34,6 +36,6 @@ public function testShouldCreateLazyContext() $this->assertInstanceOf(AmqpContext::class, $context); $this->assertAttributeEquals(null, 'extChannel', $context); - $this->assertInternalType('callable', $this->readAttribute($context, 'extChannelFactory')); + self::assertIsCallable($this->readAttribute($context, 'extChannelFactory')); } } diff --git a/pkg/amqp-ext/Tests/AmqpContextTest.php b/pkg/amqp-ext/Tests/AmqpContextTest.php index bcf3b2200..4c4ab4298 100644 --- a/pkg/amqp-ext/Tests/AmqpContextTest.php +++ b/pkg/amqp-ext/Tests/AmqpContextTest.php @@ -9,6 +9,7 @@ use Enqueue\Null\NullQueue; use Enqueue\Null\NullTopic; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Amqp\Impl\AmqpMessage; use Interop\Amqp\Impl\AmqpQueue; use Interop\Amqp\Impl\AmqpTopic; @@ -20,6 +21,7 @@ class AmqpContextTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementQueueInteropContextInterface() { diff --git a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php index ee73345e9..a90b1d306 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php @@ -14,15 +14,15 @@ */ class AmqpCommonUseCasesTest extends TestCase { - use RabbitmqAmqpExtension; use RabbitManagementExtensionTrait; + use RabbitmqAmqpExtension; /** * @var AmqpContext */ private $amqpContext; - public function setUp() + protected function setUp(): void { $this->amqpContext = $this->buildAmqpContext(); @@ -30,7 +30,7 @@ public function setUp() $this->removeExchange('amqp_ext.test_exchange'); } - public function tearDown(): void + protected function tearDown(): void { $this->amqpContext->close(); } @@ -128,7 +128,7 @@ public function testProduceAndReceiveOneMessageSentDirectlyToTemporaryQueue() public function testProduceAndReceiveOneMessageSentDirectlyToTopic() { $topic = $this->amqpContext->createTopic('amqp_ext.test_exchange'); - $topic->setType(AMQP_EX_TYPE_FANOUT); + $topic->setType(\AMQP_EX_TYPE_FANOUT); $this->amqpContext->declareTopic($topic); $queue = $this->amqpContext->createQueue('amqp_ext.test'); @@ -153,7 +153,7 @@ public function testProduceAndReceiveOneMessageSentDirectlyToTopic() public function testConsumerReceiveMessageFromTopicDirectly() { $topic = $this->amqpContext->createTopic('amqp_ext.test_exchange'); - $topic->setType(AMQP_EX_TYPE_FANOUT); + $topic->setType(\AMQP_EX_TYPE_FANOUT); $this->amqpContext->declareTopic($topic); @@ -176,7 +176,7 @@ public function testConsumerReceiveMessageFromTopicDirectly() public function testConsumerReceiveMessageWithZeroTimeout() { $topic = $this->amqpContext->createTopic('amqp_ext.test_exchange'); - $topic->setType(AMQP_EX_TYPE_FANOUT); + $topic->setType(\AMQP_EX_TYPE_FANOUT); $this->amqpContext->declareTopic($topic); diff --git a/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php index 220554859..51d5a7c54 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php @@ -21,22 +21,22 @@ */ class AmqpConsumptionUseCasesTest extends TestCase { - use RabbitmqAmqpExtension; use RabbitManagementExtensionTrait; + use RabbitmqAmqpExtension; /** * @var AmqpContext */ private $amqpContext; - public function setUp() + protected function setUp(): void { $this->amqpContext = $this->buildAmqpContext(); $this->removeQueue('amqp_ext.test'); } - public function tearDown(): void + protected function tearDown(): void { $this->amqpContext->close(); } diff --git a/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php index 9e5dc4df3..66ae69241 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php @@ -15,15 +15,15 @@ */ class AmqpRpcUseCasesTest extends TestCase { - use RabbitmqAmqpExtension; use RabbitManagementExtensionTrait; + use RabbitmqAmqpExtension; /** * @var AmqpContext */ private $amqpContext; - public function setUp() + protected function setUp(): void { $this->amqpContext = $this->buildAmqpContext(); @@ -31,7 +31,7 @@ public function setUp() $this->removeQueue('rpc.reply_test'); } - public function tearDown(): void + protected function tearDown(): void { $this->amqpContext->close(); } diff --git a/pkg/amqp-ext/composer.json b/pkg/amqp-ext/composer.json index 5bc1b3f07..203908160 100644 --- a/pkg/amqp-ext/composer.json +++ b/pkg/amqp-ext/composer.json @@ -6,14 +6,14 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "ext-amqp": "^1.9.3", "queue-interop/amqp-interop": "^0.8", "queue-interop/queue-interop": "^0.8", "enqueue/amqp-tools": "^0.10" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "enqueue/null": "0.10.x-dev", "queue-interop/queue-spec": "^0.6", diff --git a/pkg/amqp-lib/Tests/AmqpConnectionFactoryTest.php b/pkg/amqp-lib/Tests/AmqpConnectionFactoryTest.php index 9db9f6288..1a2cf4e4d 100644 --- a/pkg/amqp-lib/Tests/AmqpConnectionFactoryTest.php +++ b/pkg/amqp-lib/Tests/AmqpConnectionFactoryTest.php @@ -5,12 +5,14 @@ use Enqueue\AmqpLib\AmqpConnectionFactory; use Enqueue\AmqpTools\RabbitMqDlxDelayStrategy; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\ConnectionFactory; use PHPUnit\Framework\TestCase; class AmqpConnectionFactoryTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementConnectionFactoryInterface() { diff --git a/pkg/amqp-lib/composer.json b/pkg/amqp-lib/composer.json index a04900d1c..2d9d2515f 100644 --- a/pkg/amqp-lib/composer.json +++ b/pkg/amqp-lib/composer.json @@ -6,14 +6,14 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "php-amqplib/php-amqplib": "^2.10", "queue-interop/amqp-interop": "^0.8", "queue-interop/queue-interop": "^0.8", "enqueue/amqp-tools": "^0.10" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "enqueue/null": "0.10.x-dev", "queue-interop/queue-spec": "^0.6" diff --git a/pkg/amqp-tools/Tests/SignalSocketHelperTest.php b/pkg/amqp-tools/Tests/SignalSocketHelperTest.php index d869878c9..a44e42a70 100644 --- a/pkg/amqp-tools/Tests/SignalSocketHelperTest.php +++ b/pkg/amqp-tools/Tests/SignalSocketHelperTest.php @@ -3,10 +3,13 @@ namespace Enqueue\AmqpTools\Tests; use Enqueue\AmqpTools\SignalSocketHelper; +use Enqueue\Test\ReadAttributeTrait; use PHPUnit\Framework\TestCase; class SignalSocketHelperTest extends TestCase { + use ReadAttributeTrait; + /** * @var SignalSocketHelper */ @@ -16,7 +19,7 @@ class SignalSocketHelperTest extends TestCase private $backupSigIntHandler; - public function setUp() + protected function setUp(): void { parent::setUp(); @@ -25,16 +28,16 @@ public function setUp() $this->markTestSkipped('PHP 7.1+ needed'); } - $this->backupSigTermHandler = pcntl_signal_get_handler(SIGTERM); - $this->backupSigIntHandler = pcntl_signal_get_handler(SIGINT); + $this->backupSigTermHandler = pcntl_signal_get_handler(\SIGTERM); + $this->backupSigIntHandler = pcntl_signal_get_handler(\SIGINT); - pcntl_signal(SIGTERM, SIG_DFL); - pcntl_signal(SIGINT, SIG_DFL); + pcntl_signal(\SIGTERM, \SIG_DFL); + pcntl_signal(\SIGINT, \SIG_DFL); $this->signalHelper = new SignalSocketHelper(); } - public function tearDown(): void + protected function tearDown(): void { parent::tearDown(); @@ -43,11 +46,11 @@ public function tearDown(): void } if ($this->backupSigTermHandler) { - pcntl_signal(SIGTERM, $this->backupSigTermHandler); + pcntl_signal(\SIGTERM, $this->backupSigTermHandler); } if ($this->backupSigIntHandler) { - pcntl_signal(SIGINT, $this->backupSigIntHandler); + pcntl_signal(\SIGINT, $this->backupSigIntHandler); } } @@ -68,7 +71,7 @@ public function testShouldRegisterHandlerOnBeforeSocketAndBackupCurrentOne() { $handler = function () {}; - pcntl_signal(SIGTERM, $handler); + pcntl_signal(\SIGTERM, $handler); $this->signalHelper->beforeSocket(); @@ -76,9 +79,9 @@ public function testShouldRegisterHandlerOnBeforeSocketAndBackupCurrentOne() $handlers = $this->readAttribute($this->signalHelper, 'handlers'); - $this->assertInternalType('array', $handlers); - $this->assertArrayHasKey(SIGTERM, $handlers); - $this->assertSame($handler, $handlers[SIGTERM]); + self::assertIsArray($handlers); + $this->assertArrayHasKey(\SIGTERM, $handlers); + $this->assertSame($handler, $handlers[\SIGTERM]); } public function testRestoreDefaultPropertiesOnAfterSocket() @@ -94,12 +97,12 @@ public function testRestorePreviousHandlerOnAfterSocket() { $handler = function () {}; - pcntl_signal(SIGTERM, $handler); + pcntl_signal(\SIGTERM, $handler); $this->signalHelper->beforeSocket(); $this->signalHelper->afterSocket(); - $this->assertSame($handler, pcntl_signal_get_handler(SIGTERM)); + $this->assertSame($handler, pcntl_signal_get_handler(\SIGTERM)); } public function testThrowsIfBeforeSocketCalledSecondTime() @@ -115,7 +118,7 @@ public function testShouldReturnTrueOnWasThereSignal() { $this->signalHelper->beforeSocket(); - posix_kill(getmypid(), SIGINT); + posix_kill(getmypid(), \SIGINT); pcntl_signal_dispatch(); $this->assertTrue($this->signalHelper->wasThereSignal()); diff --git a/pkg/amqp-tools/composer.json b/pkg/amqp-tools/composer.json index 6cb280fd5..52c582954 100644 --- a/pkg/amqp-tools/composer.json +++ b/pkg/amqp-tools/composer.json @@ -6,13 +6,13 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "queue-interop/amqp-interop": "^0.8", "queue-interop/queue-interop": "^0.8", "enqueue/dsn": "^0.10" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "enqueue/null": "0.10.x-dev" }, diff --git a/pkg/async-command/Tests/RunCommandProcessorTest.php b/pkg/async-command/Tests/RunCommandProcessorTest.php index 3065ec315..7a7a36428 100644 --- a/pkg/async-command/Tests/RunCommandProcessorTest.php +++ b/pkg/async-command/Tests/RunCommandProcessorTest.php @@ -3,11 +3,14 @@ namespace Enqueue\AsyncCommand\Tests; use Enqueue\AsyncCommand\RunCommandProcessor; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\Processor; use PHPUnit\Framework\TestCase; class RunCommandProcessorTest extends TestCase { + use ReadAttributeTrait; + public function testShouldImplementProcessorInterface() { $rc = new \ReflectionClass(RunCommandProcessor::class); diff --git a/pkg/async-command/composer.json b/pkg/async-command/composer.json index a511f8b0e..24a24e80a 100644 --- a/pkg/async-command/composer.json +++ b/pkg/async-command/composer.json @@ -13,7 +13,7 @@ "symfony/process": "^4.3|^5" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "symfony/dependency-injection": "^4.3|^5", "symfony/config": "^4.3|^5", "symfony/http-kernel": "^4.3|^5", diff --git a/pkg/async-event-dispatcher/Tests/AsyncListenerTest.php b/pkg/async-event-dispatcher/Tests/AsyncListenerTest.php index c5a1c3567..f00635245 100644 --- a/pkg/async-event-dispatcher/Tests/AsyncListenerTest.php +++ b/pkg/async-event-dispatcher/Tests/AsyncListenerTest.php @@ -8,6 +8,7 @@ use Enqueue\Null\NullMessage; use Enqueue\Null\NullQueue; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\Context; use Interop\Queue\Producer; use PHPUnit\Framework\MockObject\MockObject; @@ -20,6 +21,7 @@ class AsyncListenerTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testCouldBeConstructedWithContextAndRegistryAndEventQueueAsString() { diff --git a/pkg/async-event-dispatcher/Tests/ContainerAwareRegistryTest.php b/pkg/async-event-dispatcher/Tests/ContainerAwareRegistryTest.php index 125550268..3be3b5f3c 100644 --- a/pkg/async-event-dispatcher/Tests/ContainerAwareRegistryTest.php +++ b/pkg/async-event-dispatcher/Tests/ContainerAwareRegistryTest.php @@ -6,12 +6,14 @@ use Enqueue\AsyncEventDispatcher\EventTransformer; use Enqueue\AsyncEventDispatcher\Registry; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Container; class ContainerAwareRegistryTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementRegistryInterface() { diff --git a/pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php b/pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php index d05a9add5..169d8ea5b 100644 --- a/pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php +++ b/pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php @@ -53,7 +53,7 @@ class UseCasesTest extends TestCase */ protected $asyncProcessor; - public function setUp() + protected function setUp(): void { (new Filesystem())->remove(__DIR__.'/queues/'); diff --git a/pkg/async-event-dispatcher/composer.json b/pkg/async-event-dispatcher/composer.json index dae5bb529..d4a72125b 100644 --- a/pkg/async-event-dispatcher/composer.json +++ b/pkg/async-event-dispatcher/composer.json @@ -6,13 +6,13 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "enqueue/enqueue": "^0.10", "queue-interop/queue-interop": "^0.8", "symfony/event-dispatcher": "^4.3|^5" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "symfony/dependency-injection": "^4.3|^5", "symfony/config": "^4.3|^5", "symfony/http-kernel": "^4.3|^5", diff --git a/pkg/dbal/Tests/DbalConnectionFactoryConfigTest.php b/pkg/dbal/Tests/DbalConnectionFactoryConfigTest.php index fb5cae5d5..dda690f9f 100644 --- a/pkg/dbal/Tests/DbalConnectionFactoryConfigTest.php +++ b/pkg/dbal/Tests/DbalConnectionFactoryConfigTest.php @@ -4,6 +4,7 @@ use Enqueue\Dbal\DbalConnectionFactory; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use PHPUnit\Framework\TestCase; /** @@ -12,6 +13,7 @@ class DbalConnectionFactoryConfigTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testThrowNeitherArrayStringNorNullGivenAsConfig() { diff --git a/pkg/dbal/Tests/DbalConnectionFactoryTest.php b/pkg/dbal/Tests/DbalConnectionFactoryTest.php index b4a6857f6..105466c26 100644 --- a/pkg/dbal/Tests/DbalConnectionFactoryTest.php +++ b/pkg/dbal/Tests/DbalConnectionFactoryTest.php @@ -5,12 +5,14 @@ use Enqueue\Dbal\DbalConnectionFactory; use Enqueue\Dbal\DbalContext; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\ConnectionFactory; use PHPUnit\Framework\TestCase; class DbalConnectionFactoryTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementConnectionFactoryInterface() { @@ -26,7 +28,7 @@ public function testShouldCreateLazyContext() $this->assertInstanceOf(DbalContext::class, $context); $this->assertAttributeEquals(null, 'connection', $context); - $this->assertAttributeInternalType('callable', 'connectionFactory', $context); + $this->assertIsCallable($this->readAttribute($context, 'connectionFactory')); } public function testShouldParseGenericDSN() diff --git a/pkg/dbal/Tests/DbalContextTest.php b/pkg/dbal/Tests/DbalContextTest.php index b89abae2e..0b793e6e7 100644 --- a/pkg/dbal/Tests/DbalContextTest.php +++ b/pkg/dbal/Tests/DbalContextTest.php @@ -9,6 +9,7 @@ use Enqueue\Dbal\DbalMessage; use Enqueue\Dbal\DbalProducer; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\Context; use Interop\Queue\Destination; use Interop\Queue\Exception\InvalidDestinationException; @@ -19,6 +20,7 @@ class DbalContextTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementContextInterface() { diff --git a/pkg/dbal/Tests/DbalSubscriptionConsumerTest.php b/pkg/dbal/Tests/DbalSubscriptionConsumerTest.php index 82787f19f..a3fad6e66 100644 --- a/pkg/dbal/Tests/DbalSubscriptionConsumerTest.php +++ b/pkg/dbal/Tests/DbalSubscriptionConsumerTest.php @@ -7,6 +7,7 @@ use Enqueue\Dbal\DbalConsumer; use Enqueue\Dbal\DbalContext; use Enqueue\Dbal\DbalSubscriptionConsumer; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\Consumer; use Interop\Queue\Queue; use Interop\Queue\SubscriptionConsumer; @@ -15,6 +16,8 @@ class DbalSubscriptionConsumerTest extends TestCase { + use ReadAttributeTrait; + public function testShouldImplementSubscriptionConsumerInterface() { $rc = new \ReflectionClass(DbalSubscriptionConsumer::class); diff --git a/pkg/dbal/Tests/Functional/DbalConsumerTest.php b/pkg/dbal/Tests/Functional/DbalConsumerTest.php index 69b644ed4..c95ada687 100644 --- a/pkg/dbal/Tests/Functional/DbalConsumerTest.php +++ b/pkg/dbal/Tests/Functional/DbalConsumerTest.php @@ -21,7 +21,7 @@ class DbalConsumerTest extends TestCase */ private $context; - public function setUp() + protected function setUp(): void { $this->context = $this->createDbalContext(); } diff --git a/pkg/dbal/Tests/ManagerRegistryConnectionFactoryTest.php b/pkg/dbal/Tests/ManagerRegistryConnectionFactoryTest.php index 3adefff01..83135c2ed 100644 --- a/pkg/dbal/Tests/ManagerRegistryConnectionFactoryTest.php +++ b/pkg/dbal/Tests/ManagerRegistryConnectionFactoryTest.php @@ -7,6 +7,7 @@ use Enqueue\Dbal\DbalContext; use Enqueue\Dbal\ManagerRegistryConnectionFactory; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\ConnectionFactory; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -14,6 +15,7 @@ class ManagerRegistryConnectionFactoryTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementConnectionFactoryInterface() { @@ -71,7 +73,7 @@ public function testShouldCreateLazyContext() $this->assertInstanceOf(DbalContext::class, $context); $this->assertAttributeEquals(null, 'connection', $context); - $this->assertAttributeInternalType('callable', 'connectionFactory', $context); + $this->assertIsCallable($this->readAttribute($context, 'connectionFactory')); } /** diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php index 5a051a729..23a5855b5 100644 --- a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php +++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php @@ -16,7 +16,7 @@ class DbalSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceivePrio private $publishedAt; - public function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php index a645cbad6..f6d048549 100644 --- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php +++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php @@ -16,7 +16,7 @@ class DbalSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceivePrio private $publishedAt; - public function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/pkg/dbal/composer.json b/pkg/dbal/composer.json index e097f228c..dfeba65f3 100644 --- a/pkg/dbal/composer.json +++ b/pkg/dbal/composer.json @@ -6,13 +6,13 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "queue-interop/queue-interop": "^0.8", "doctrine/dbal": "^2.6", "ramsey/uuid": "^3|^4" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "enqueue/null": "0.10.x-dev", "queue-interop/queue-spec": "^0.6" diff --git a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php index 457a0ffcd..7fb6fdd86 100644 --- a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php @@ -16,7 +16,7 @@ */ class AsyncListenerTest extends WebTestCase { - public function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncProcessorTest.php b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncProcessorTest.php index e595414ae..d85567509 100644 --- a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncProcessorTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncProcessorTest.php @@ -18,7 +18,7 @@ */ class AsyncProcessorTest extends WebTestCase { - public function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncSubscriberTest.php b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncSubscriberTest.php index 7404e6af8..4b145524a 100644 --- a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncSubscriberTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncSubscriberTest.php @@ -16,7 +16,7 @@ */ class AsyncSubscriberTest extends WebTestCase { - public function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php b/pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php index fefbe882b..19f139b69 100644 --- a/pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php @@ -11,13 +11,13 @@ */ class LazyProducerTest extends WebTestCase { - public function setUp() + protected function setUp(): void { // do not call parent::setUp. // parent::setUp(); } - public function tearDown(): void + protected function tearDown(): void { if (static::$kernel) { $fs = new Filesystem(); diff --git a/pkg/enqueue-bundle/Tests/Functional/RoutesCommandTest.php b/pkg/enqueue-bundle/Tests/Functional/RoutesCommandTest.php index 4970e9b43..66833b1ce 100644 --- a/pkg/enqueue-bundle/Tests/Functional/RoutesCommandTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/RoutesCommandTest.php @@ -26,11 +26,11 @@ public function testShouldDisplayRegisteredTopics() $tester->execute([]); $this->assertSame(0, $tester->getStatusCode()); - $this->assertContains('| topic', $tester->getDisplay()); - $this->assertContains('| theTopic', $tester->getDisplay()); - $this->assertContains('| default (prefixed)', $tester->getDisplay()); - $this->assertContains('| test_topic_subscriber_processor', $tester->getDisplay()); - $this->assertContains('| (hidden)', $tester->getDisplay()); + $this->assertStringContainsString('| topic', $tester->getDisplay()); + $this->assertStringContainsString('| theTopic', $tester->getDisplay()); + $this->assertStringContainsString('| default (prefixed)', $tester->getDisplay()); + $this->assertStringContainsString('| test_topic_subscriber_processor', $tester->getDisplay()); + $this->assertStringContainsString('| (hidden)', $tester->getDisplay()); } public function testShouldDisplayCommands() @@ -42,10 +42,10 @@ public function testShouldDisplayCommands() $tester->execute([]); $this->assertSame(0, $tester->getStatusCode()); - $this->assertContains('| command', $tester->getDisplay()); - $this->assertContains('| theCommand', $tester->getDisplay()); - $this->assertContains('| test_command_subscriber_processor', $tester->getDisplay()); - $this->assertContains('| default (prefixed)', $tester->getDisplay()); - $this->assertContains('| (hidden)', $tester->getDisplay()); + $this->assertStringContainsString('| command', $tester->getDisplay()); + $this->assertStringContainsString('| theCommand', $tester->getDisplay()); + $this->assertStringContainsString('| test_command_subscriber_processor', $tester->getDisplay()); + $this->assertStringContainsString('| default (prefixed)', $tester->getDisplay()); + $this->assertStringContainsString('| (hidden)', $tester->getDisplay()); } } diff --git a/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php b/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php index 7c2936c0e..af4159c25 100644 --- a/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php @@ -20,13 +20,13 @@ class UseCasesTest extends WebTestCase { const RECEIVE_TIMEOUT = 500; - public function setUp() + protected function setUp(): void { // do not call parent::setUp. // parent::setUp(); } - public function tearDown(): void + protected function tearDown(): void { if ($this->getContext()) { $this->getContext()->close(); diff --git a/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php b/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php index 8e3569a98..ca462ea1e 100644 --- a/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php +++ b/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php @@ -20,7 +20,7 @@ abstract class WebTestCase extends BaseWebTestCase */ protected static $container; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php index fd2ae06aa..b740e64c1 100644 --- a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php @@ -12,7 +12,7 @@ use Interop\Queue\Processor; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use Psr\Log\LoggerInterface; +use Psr\Log\Test\TestLogger; class DoctrinePingConnectionExtensionTest extends TestCase { @@ -44,20 +44,20 @@ public function testShouldNotReconnectIfConnectionIsOK() ; $context = $this->createContext(); - $context->getLogger() - ->expects($this->never()) - ->method('debug') - ; $registry = $this->createRegistryMock(); $registry - ->expects($this->once()) + ->expects(self::once()) ->method('getConnections') ->willReturn([$connection]) ; $extension = new DoctrinePingConnectionExtension($registry); $extension->onMessageReceived($context); + + /** @var TestLogger $logger */ + $logger = $context->getLogger(); + self::assertFalse($logger->hasDebugRecords()); } public function testShouldDoesReconnectIfConnectionFailed() @@ -83,16 +83,6 @@ public function testShouldDoesReconnectIfConnectionFailed() ; $context = $this->createContext(); - $context->getLogger() - ->expects($this->at(0)) - ->method('debug') - ->with('[DoctrinePingConnectionExtension] Connection is not active trying to reconnect.') - ; - $context->getLogger() - ->expects($this->at(1)) - ->method('debug') - ->with('[DoctrinePingConnectionExtension] Connection is active now.') - ; $registry = $this->createRegistryMock(); $registry @@ -103,6 +93,19 @@ public function testShouldDoesReconnectIfConnectionFailed() $extension = new DoctrinePingConnectionExtension($registry); $extension->onMessageReceived($context); + + /** @var TestLogger $logger */ + $logger = $context->getLogger(); + self::assertTrue( + $logger->hasDebugThatContains( + '[DoctrinePingConnectionExtension] Connection is not active trying to reconnect.' + ) + ); + self::assertTrue( + $logger->hasDebugThatContains( + '[DoctrinePingConnectionExtension] Connection is active now.' + ) + ); } public function testShouldSkipIfConnectionWasNotOpened() @@ -132,10 +135,6 @@ public function testShouldSkipIfConnectionWasNotOpened() ; $context = $this->createContext(); - $context->getLogger() - ->expects($this->never()) - ->method('debug') - ; $registry = $this->createRegistryMock(); $registry @@ -146,6 +145,10 @@ public function testShouldSkipIfConnectionWasNotOpened() $extension = new DoctrinePingConnectionExtension($registry); $extension->onMessageReceived($context); + + /** @var TestLogger $logger */ + $logger = $context->getLogger(); + $this->assertFalse($logger->hasDebugRecords()); } protected function createContext(): MessageReceived @@ -156,7 +159,7 @@ protected function createContext(): MessageReceived $this->createMock(Message::class), $this->createMock(Processor::class), 1, - $this->createMock(LoggerInterface::class) + new TestLogger() ); } diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php index 3f3aae8ee..d641227ef 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php @@ -2,6 +2,7 @@ namespace Enqueue\Bundle\Tests\Unit\DependencyInjection; +use DMS\PHPUnitExtensions\ArraySubset\Assert; use Enqueue\Bundle\DependencyInjection\Configuration; use Enqueue\Test\ClassExtensionTrait; use PHPUnit\Framework\TestCase; @@ -222,7 +223,7 @@ public function testJobShouldBeDisabledByDefault() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'job' => [ 'enabled' => false, @@ -243,7 +244,7 @@ public function testCouldEnableJob() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'job' => true, ], @@ -261,7 +262,7 @@ public function testDoctrinePingConnectionExtensionShouldBeDisabledByDefault() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_ping_connection_extension' => false, @@ -284,7 +285,7 @@ public function testDoctrinePingConnectionExtensionCouldBeEnabled() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_ping_connection_extension' => true, @@ -304,7 +305,7 @@ public function testDoctrineClearIdentityMapExtensionShouldBeDisabledByDefault() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_clear_identity_map_extension' => false, @@ -327,7 +328,7 @@ public function testDoctrineClearIdentityMapExtensionCouldBeEnabled() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_clear_identity_map_extension' => true, @@ -347,7 +348,7 @@ public function testDoctrineOdmClearIdentityMapExtensionShouldBeDisabledByDefaul ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_odm_clear_identity_map_extension' => false, @@ -370,7 +371,7 @@ public function testDoctrineOdmClearIdentityMapExtensionCouldBeEnabled() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_odm_clear_identity_map_extension' => true, @@ -390,7 +391,7 @@ public function testDoctrineClosedEntityManagerExtensionShouldBeDisabledByDefaul ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_closed_entity_manager_extension' => false, @@ -413,7 +414,7 @@ public function testDoctrineClosedEntityManagerExtensionCouldBeEnabled() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_closed_entity_manager_extension' => true, @@ -433,7 +434,7 @@ public function testResetServicesExtensionShouldBeDisabledByDefault() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'reset_services_extension' => false, @@ -456,7 +457,7 @@ public function testResetServicesExtensionCouldBeEnabled() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'reset_services_extension' => true, @@ -478,7 +479,7 @@ public function testSignalExtensionShouldBeEnabledIfPcntlExtensionIsLoaded() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'signal_extension' => $isLoaded, @@ -501,7 +502,7 @@ public function testSignalExtensionCouldBeDisabled() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'signal_extension' => false, @@ -521,7 +522,7 @@ public function testReplyExtensionShouldBeEnabledByDefault() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'reply_extension' => true, @@ -544,7 +545,7 @@ public function testReplyExtensionCouldBeDisabled() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'reply_extension' => false, @@ -564,7 +565,7 @@ public function testShouldDisableAsyncEventsByDefault() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'async_events' => [ 'enabled' => false, @@ -586,7 +587,7 @@ public function testShouldAllowEnableAsyncEvents() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'async_events' => [ 'enabled' => true, @@ -603,7 +604,7 @@ public function testShouldAllowEnableAsyncEvents() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'async_events' => [ 'enabled' => true, @@ -623,7 +624,7 @@ public function testShouldSetDefaultConfigurationForConsumption() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'consumption' => [ 'receive_timeout' => 10000, @@ -646,7 +647,7 @@ public function testShouldAllowConfigureConsumption() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'consumption' => [ 'receive_timeout' => 456, @@ -657,6 +658,6 @@ public function testShouldAllowConfigureConsumption() private function assertConfigEquals(array $expected, array $actual): void { - $this->assertArraySubset($expected, $actual, false, var_export($actual, true)); + Assert::assertArraySubset($expected, $actual, false, var_export($actual, true)); } } diff --git a/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php b/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php index 96d4bc940..55f415d03 100644 --- a/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php @@ -2,6 +2,7 @@ namespace Enqueue\Bundle\Tests\Unit\Profiler; +use DMS\PHPUnitExtensions\ArraySubset\Assert; use Enqueue\Bundle\Profiler\MessageQueueCollector; use Enqueue\Client\MessagePriority; use Enqueue\Client\ProducerInterface; @@ -59,7 +60,7 @@ public function testShouldReturnSentMessageArrayTakenFromTraceableProducers() $collector->collect(new Request(), new Response()); - $this->assertArraySubset( + Assert::assertArraySubset( [ 'foo' => [ [ diff --git a/pkg/enqueue-bundle/composer.json b/pkg/enqueue-bundle/composer.json index ee7c5459e..43a73fa34 100644 --- a/pkg/enqueue-bundle/composer.json +++ b/pkg/enqueue-bundle/composer.json @@ -6,7 +6,7 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "symfony/framework-bundle": "^4.3|^5", "queue-interop/amqp-interop": "^0.8", "queue-interop/queue-interop": "^0.8", @@ -21,7 +21,7 @@ "docs": "https://github.com/php-enqueue/enqueue-dev/blob/master/docs/index.md" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/stomp": "0.10.x-dev", "enqueue/amqp-ext": "0.10.x-dev", "enqueue/amqp-lib": "0.10.x-dev", diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php index 050b4f2f5..a92dc8df1 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php @@ -15,10 +15,11 @@ use Interop\Queue\Destination; use Interop\Queue\Message as TransportMessage; use Interop\Queue\Processor; +use Interop\Queue\Queue; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; +use Psr\Log\Test\TestLogger; class DelayRedeliveredMessageExtensionTest extends TestCase { @@ -54,20 +55,7 @@ public function testShouldSendDelayedMessageAndRejectOriginalMessage() ->willReturn($delayedMessage) ; - $logger = $this->createLoggerMock(); - $logger - ->expects(self::at(0)) - ->method('debug') - ->with('[DelayRedeliveredMessageExtension] Send delayed message') - ; - $logger - ->expects(self::at(1)) - ->method('debug') - ->with( - '[DelayRedeliveredMessageExtension] '. - 'Reject redelivered original message by setting reject status to context.' - ) - ; + $logger = new TestLogger(); $messageReceived = new MessageReceived( $this->createContextMock(), @@ -92,6 +80,16 @@ public function testShouldSendDelayedMessageAndRejectOriginalMessage() $this->assertEquals([ 'enqueue.redelivery_count' => 1, ], $delayedMessage->getProperties()); + + self::assertTrue( + $logger->hasDebugThatContains('[DelayRedeliveredMessageExtension] Send delayed message') + ); + self::assertTrue( + $logger->hasDebugThatContains( + '[DelayRedeliveredMessageExtension] '. + 'Reject redelivered original message by setting reject status to context.' + ) + ); } public function testShouldDoNothingIfMessageIsNotRedelivered() @@ -169,30 +167,20 @@ private function createProcessorMock(): Processor } /** - * @param mixed $queue - * - * @return MockObject + * @return MockObject|Consumer */ - private function createConsumerStub($queue): Consumer + private function createConsumerStub(?Queue $queue): Consumer { $consumerMock = $this->createMock(Consumer::class); $consumerMock ->expects($this->any()) ->method('getQueue') - ->willReturn($queue) + ->willReturn($queue ?? new NullQueue('queue')) ; return $consumerMock; } - /** - * @return MockObject - */ - private function createLoggerMock(): LoggerInterface - { - return $this->createMock(LoggerInterface::class); - } - private function createDriverSendResult(): DriverSendResult { return new DriverSendResult( diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php index 878778b30..dc2c00c96 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php @@ -15,6 +15,7 @@ use Interop\Queue\Consumer; use Interop\Queue\Context as InteropContext; use Interop\Queue\Processor; +use Interop\Queue\Queue; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; @@ -243,15 +244,15 @@ public function testShouldDoNothingIfAnotherQueue() } /** - * @return MockObject + * @return MockObject|DriverInterface */ - private function createDriverStub(RouteCollection $routeCollection = null): DriverInterface + private function createDriverStub(?RouteCollection $routeCollection = null): DriverInterface { $driver = $this->createMock(DriverInterface::class); $driver ->expects($this->any()) ->method('getRouteCollection') - ->willReturn($routeCollection) + ->willReturn($routeCollection ?? new RouteCollection([])) ; return $driver; @@ -274,17 +275,15 @@ private function createProcessorMock(): Processor } /** - * @param mixed $queue - * - * @return MockObject + * @return MockObject|Consumer */ - private function createConsumerStub($queue): Consumer + private function createConsumerStub(?Queue $queue): Consumer { $consumerMock = $this->createMock(Consumer::class); $consumerMock ->expects($this->any()) ->method('getQueue') - ->willReturn($queue) + ->willReturn($queue ?? new NullQueue('queue')) ; return $consumerMock; diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php index 18760e9bf..e5015ff45 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php @@ -13,6 +13,7 @@ use Interop\Queue\Consumer; use Interop\Queue\Context as InteropContext; use Interop\Queue\Processor; +use Interop\Queue\Queue; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; @@ -186,17 +187,15 @@ private function createProcessorMock(): Processor } /** - * @param mixed $queue - * - * @return MockObject + * @return MockObject|Consumer */ - private function createConsumerStub($queue): Consumer + private function createConsumerStub(?Queue $queue): Consumer { $consumerMock = $this->createMock(Consumer::class); $consumerMock ->expects($this->any()) ->method('getQueue') - ->willReturn($queue) + ->willReturn($queue ?? new NullQueue('queue')) ; return $consumerMock; diff --git a/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php b/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php index 4e4cc62fd..2cfb170b9 100644 --- a/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php @@ -2,6 +2,7 @@ namespace Enqueue\Tests\Client\Driver; +use DMS\PHPUnitExtensions\ArraySubset\Assert; use Enqueue\Client\Config; use Enqueue\Client\Driver\AmqpDriver; use Enqueue\Client\Driver\GenericDriver; @@ -312,9 +313,6 @@ protected function createQueue(string $name): InteropQueue return new AmqpQueue($name); } - /** - * @return AmqpTopic - */ protected function createTopic(string $name): AmqpTopic { return new AmqpTopic($name); @@ -336,7 +334,7 @@ protected function getRouterTransportName(): string protected function assertTransportMessage(InteropMessage $transportMessage): void { $this->assertSame('body', $transportMessage->getBody()); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'hkey' => 'hval', 'delivery_mode' => AmqpMessage::DELIVERY_MODE_PERSISTENT, 'content_type' => 'ContentType', diff --git a/pkg/enqueue/Tests/Client/Driver/GenericDriverTest.php b/pkg/enqueue/Tests/Client/Driver/GenericDriverTest.php index 98b6c2285..78f7f6e83 100644 --- a/pkg/enqueue/Tests/Client/Driver/GenericDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/GenericDriverTest.php @@ -2,6 +2,7 @@ namespace Enqueue\Tests\Client\Driver; +use DMS\PHPUnitExtensions\ArraySubset\Assert; use Enqueue\Client\Config; use Enqueue\Client\Driver\GenericDriver; use Enqueue\Client\DriverInterface; @@ -60,7 +61,7 @@ protected function createMessage(): InteropMessage protected function assertTransportMessage(InteropMessage $transportMessage): void { $this->assertSame('body', $transportMessage->getBody()); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'hkey' => 'hval', 'message_id' => 'theMessageId', 'timestamp' => 1000, diff --git a/pkg/enqueue/Tests/Client/Driver/GenericDriverTestsTrait.php b/pkg/enqueue/Tests/Client/Driver/GenericDriverTestsTrait.php index 4f1c81566..d5ad498a9 100644 --- a/pkg/enqueue/Tests/Client/Driver/GenericDriverTestsTrait.php +++ b/pkg/enqueue/Tests/Client/Driver/GenericDriverTestsTrait.php @@ -2,6 +2,7 @@ namespace Enqueue\Tests\Client\Driver; +use DMS\PHPUnitExtensions\ArraySubset\Assert; use Enqueue\Client\Config; use Enqueue\Client\DriverInterface; use Enqueue\Client\Message; @@ -1191,10 +1192,10 @@ protected function assertTransportMessage(InteropMessage $transportMessage): voi protected function assertClientMessage(Message $clientMessage): void { $this->assertSame('body', $clientMessage->getBody()); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'hkey' => 'hval', ], $clientMessage->getHeaders()); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'pkey' => 'pval', Config::CONTENT_TYPE => 'theContentType', Config::EXPIRE => '22', diff --git a/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php b/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php index 2f6e20a82..b209d85bc 100644 --- a/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php @@ -2,6 +2,7 @@ namespace Enqueue\Tests\Client\Driver; +use DMS\PHPUnitExtensions\ArraySubset\Assert; use Enqueue\Client\Config; use Enqueue\Client\Driver\AmqpDriver; use Enqueue\Client\Driver\GenericDriver; @@ -91,9 +92,6 @@ protected function createQueue(string $name): InteropQueue return new AmqpQueue($name); } - /** - * @return AmqpTopic - */ protected function createTopic(string $name): AmqpTopic { return new AmqpTopic($name); @@ -115,7 +113,7 @@ protected function getRouterTransportName(): string protected function assertTransportMessage(InteropMessage $transportMessage): void { $this->assertSame('body', $transportMessage->getBody()); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'hkey' => 'hval', 'delivery_mode' => AmqpMessage::DELIVERY_MODE_PERSISTENT, 'content_type' => 'ContentType', diff --git a/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php b/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php index 4152f93cc..fbcb68644 100644 --- a/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php @@ -24,7 +24,7 @@ use Interop\Queue\Queue as InteropQueue; use Interop\Queue\Topic as InteropTopic; use PHPUnit\Framework\TestCase; -use Psr\Log\LoggerInterface; +use Psr\Log\Test\TestLogger; class RabbitMqStompDriverTest extends TestCase { @@ -281,14 +281,15 @@ public function testShouldNotSetupBrokerIfManagementPluginInstalledOptionIsNotEn $this->createManagementClientMock() ); - $logger = $this->createLoggerMock(); - $logger - ->expects($this->once()) - ->method('debug') - ->with('[RabbitMqStompDriver] Could not setup broker. The option `management_plugin_installed` is not enabled. Please enable that option and install rabbit management plugin') - ; + $logger = new TestLogger(); $driver->setupBroker($logger); + + self::assertTrue( + $logger->hasDebugThatContains( + '[RabbitMqStompDriver] Could not setup broker. The option `management_plugin_installed` is not enabled. Please enable that option and install rabbit management plugin' + ) + ); } public function testShouldSetupBroker() @@ -366,29 +367,30 @@ public function testShouldSetupBroker() $managementClient ); - $logger = $this->createLoggerMock(); - $logger - ->expects($this->at(0)) - ->method('debug') - ->with('[RabbitMqStompDriver] Declare router exchange: aprefix.router') - ; - $logger - ->expects($this->at(1)) - ->method('debug') - ->with('[RabbitMqStompDriver] Declare router queue: aprefix.default') - ; - $logger - ->expects($this->at(2)) - ->method('debug') - ->with('[RabbitMqStompDriver] Bind router queue to exchange: aprefix.default -> aprefix.router') - ; - $logger - ->expects($this->at(3)) - ->method('debug') - ->with('[RabbitMqStompDriver] Declare processor queue: aprefix.default') - ; + $logger = new TestLogger(); $driver->setupBroker($logger); + + self::assertTrue( + $logger->hasDebugThatContains( + '[RabbitMqStompDriver] Declare router exchange: aprefix.router' + ) + ); + self::assertTrue( + $logger->hasDebugThatContains( + '[RabbitMqStompDriver] Declare router queue: aprefix.default' + ) + ); + self::assertTrue( + $logger->hasDebugThatContains( + '[RabbitMqStompDriver] Bind router queue to exchange: aprefix.default -> aprefix.router' + ) + ); + self::assertTrue( + $logger->hasDebugThatContains( + '[RabbitMqStompDriver] Declare processor queue: aprefix.default' + ) + ); } public function testSetupBrokerShouldCreateDelayExchangeIfEnabled() @@ -458,19 +460,20 @@ public function testSetupBrokerShouldCreateDelayExchangeIfEnabled() $managementClient ); - $logger = $this->createLoggerMock(); - $logger - ->expects($this->at(4)) - ->method('debug') - ->with('[RabbitMqStompDriver] Declare delay exchange: aprefix.default.delayed') - ; - $logger - ->expects($this->at(5)) - ->method('debug') - ->with('[RabbitMqStompDriver] Bind processor queue to delay exchange: aprefix.default -> aprefix.default.delayed') - ; + $logger = new TestLogger(); $driver->setupBroker($logger); + + self::assertTrue( + $logger->hasDebugThatContains( + '[RabbitMqStompDriver] Declare delay exchange: aprefix.default.delayed' + ) + ); + self::assertTrue( + $logger->hasDebugThatContains( + '[RabbitMqStompDriver] Bind processor queue to delay exchange: aprefix.default -> aprefix.default.delayed' + ) + ); } protected function createDriver(...$args): DriverInterface @@ -584,12 +587,4 @@ private function createManagementClientMock(): StompManagementClient { return $this->createMock(StompManagementClient::class); } - - /** - * @return \PHPUnit\Framework\MockObject\MockObject|LoggerInterface - */ - private function createLoggerMock() - { - return $this->createMock(LoggerInterface::class); - } } diff --git a/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php b/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php index 8ac0704ca..9500e9d62 100644 --- a/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php +++ b/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php @@ -479,7 +479,7 @@ public function testShouldCallPostSendExtensionMethod() $extension ->expects($this->at(0)) - ->method('onDriverPreSend') + ->method('onPostSend') ->willReturnCallback(function (PostSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); $this->assertSame($producer, $context->getProducer()); diff --git a/pkg/enqueue/Tests/Client/ProducerSendEventTest.php b/pkg/enqueue/Tests/Client/ProducerSendEventTest.php index 29a14b7d4..c92b49560 100644 --- a/pkg/enqueue/Tests/Client/ProducerSendEventTest.php +++ b/pkg/enqueue/Tests/Client/ProducerSendEventTest.php @@ -499,7 +499,7 @@ public function testShouldCallPostSendExtensionMethodWhenSendToApplicationRouter $extension ->expects($this->at(0)) - ->method('onDriverPreSend') + ->method('onPostSend') ->willReturnCallback(function (PostSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); $this->assertSame($producer, $context->getProducer()); diff --git a/pkg/enqueue/Tests/Client/ResourcesTest.php b/pkg/enqueue/Tests/Client/ResourcesTest.php index c2d2b117d..e79fb9dda 100644 --- a/pkg/enqueue/Tests/Client/ResourcesTest.php +++ b/pkg/enqueue/Tests/Client/ResourcesTest.php @@ -28,7 +28,7 @@ public function testShouldGetAvailableDriverInExpectedFormat() { $availableDrivers = Resources::getAvailableDrivers(); - $this->assertInternalType('array', $availableDrivers); + self::assertIsArray($availableDrivers); $this->assertGreaterThan(0, count($availableDrivers)); $driverInfo = $availableDrivers[0]; @@ -50,7 +50,7 @@ public function testShouldGetAvailableDriverWithRequiredExtensionInExpectedForma { $availableDrivers = Resources::getAvailableDrivers(); - $this->assertInternalType('array', $availableDrivers); + self::assertIsArray($availableDrivers); $this->assertGreaterThan(0, count($availableDrivers)); $driverInfo = $availableDrivers[1]; @@ -72,7 +72,7 @@ public function testShouldGetKnownDriversInExpectedFormat() { $knownDrivers = Resources::getAvailableDrivers(); - $this->assertInternalType('array', $knownDrivers); + self::assertIsArray($knownDrivers); $this->assertGreaterThan(0, count($knownDrivers)); $driverInfo = $knownDrivers[0]; diff --git a/pkg/enqueue/Tests/Client/RouterProcessorTest.php b/pkg/enqueue/Tests/Client/RouterProcessorTest.php index cdd44df7a..e2611d09c 100644 --- a/pkg/enqueue/Tests/Client/RouterProcessorTest.php +++ b/pkg/enqueue/Tests/Client/RouterProcessorTest.php @@ -13,6 +13,7 @@ use Enqueue\Null\NullContext; use Enqueue\Null\NullMessage; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\Destination; use Interop\Queue\Message as TransportMessage; use Interop\Queue\Processor; @@ -21,6 +22,7 @@ class RouterProcessorTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementProcessorInterface() { @@ -195,15 +197,15 @@ public function testShouldDoNotModifyOriginalMessage() } /** - * @return \PHPUnit\Framework\MockObject\MockObject + * @return \PHPUnit\Framework\MockObject\MockObject|DriverInterface */ - private function createDriverStub(RouteCollection $routeCollection = null): DriverInterface + private function createDriverStub(?RouteCollection $routeCollection = null): DriverInterface { $driver = $this->createMock(DriverInterface::class); $driver ->expects($this->any()) ->method('getRouteCollection') - ->willReturn($routeCollection) + ->willReturn($routeCollection ?? new RouteCollection([])) ; return $driver; diff --git a/pkg/enqueue/Tests/Client/TraceableProducerTest.php b/pkg/enqueue/Tests/Client/TraceableProducerTest.php index ff5ee83eb..ac0a52961 100644 --- a/pkg/enqueue/Tests/Client/TraceableProducerTest.php +++ b/pkg/enqueue/Tests/Client/TraceableProducerTest.php @@ -2,6 +2,7 @@ namespace Enqueue\Tests\Client; +use DMS\PHPUnitExtensions\ArraySubset\Assert; use Enqueue\Client\Message; use Enqueue\Client\ProducerInterface; use Enqueue\Client\TraceableProducer; @@ -45,7 +46,7 @@ public function testShouldCollectInfoIfStringGivenAsEventMessage() $producer->sendEvent('aFooTopic', 'aFooBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ [ 'topic' => 'aFooTopic', 'command' => null, @@ -70,7 +71,7 @@ public function testShouldCollectInfoIfArrayGivenAsEventMessage() $producer->sendEvent('aFooTopic', ['foo' => 'fooVal', 'bar' => 'barVal']); - $this->assertArraySubset([ + Assert::assertArraySubset([ [ 'topic' => 'aFooTopic', 'command' => null, @@ -106,7 +107,7 @@ public function testShouldCollectInfoIfEventMessageObjectGivenAsMessage() $producer->sendEvent('aFooTopic', $message); - $this->assertArraySubset([ + Assert::assertArraySubset([ [ 'topic' => 'aFooTopic', 'command' => null, @@ -168,7 +169,7 @@ public function testShouldCollectInfoIfStringGivenAsCommandMessage() $producer->sendCommand('aFooCommand', 'aFooBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ [ 'topic' => null, 'command' => 'aFooCommand', @@ -193,7 +194,7 @@ public function testShouldCollectInfoIfArrayGivenAsCommandMessage() $producer->sendCommand('aFooCommand', ['foo' => 'fooVal', 'bar' => 'barVal']); - $this->assertArraySubset([ + Assert::assertArraySubset([ [ 'topic' => null, 'command' => 'aFooCommand', @@ -229,7 +230,7 @@ public function testShouldCollectInfoIfCommandMessageObjectGivenAsMessage() $producer->sendCommand('aFooCommand', $message); - $this->assertArraySubset([ + Assert::assertArraySubset([ [ 'topic' => null, 'command' => 'aFooCommand', @@ -275,7 +276,7 @@ public function testShouldAllowGetInfoSentToSameTopic() $producer->sendEvent('aFooTopic', 'aFooBody'); $producer->sendEvent('aFooTopic', 'aFooBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['topic' => 'aFooTopic', 'body' => 'aFooBody'], ['topic' => 'aFooTopic', 'body' => 'aFooBody'], ], $producer->getTraces()); @@ -288,7 +289,7 @@ public function testShouldAllowGetInfoSentToDifferentTopics() $producer->sendEvent('aFooTopic', 'aFooBody'); $producer->sendEvent('aBarTopic', 'aBarBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['topic' => 'aFooTopic', 'body' => 'aFooBody'], ['topic' => 'aBarTopic', 'body' => 'aBarBody'], ], $producer->getTraces()); @@ -301,11 +302,11 @@ public function testShouldAllowGetInfoSentToSpecialTopic() $producer->sendEvent('aFooTopic', 'aFooBody'); $producer->sendEvent('aBarTopic', 'aBarBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['topic' => 'aFooTopic', 'body' => 'aFooBody'], ], $producer->getTopicTraces('aFooTopic')); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['topic' => 'aBarTopic', 'body' => 'aBarBody'], ], $producer->getTopicTraces('aBarTopic')); } @@ -317,7 +318,7 @@ public function testShouldAllowGetInfoSentToSameCommand() $producer->sendCommand('aFooCommand', 'aFooBody'); $producer->sendCommand('aFooCommand', 'aFooBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['command' => 'aFooCommand', 'body' => 'aFooBody'], ['command' => 'aFooCommand', 'body' => 'aFooBody'], ], $producer->getTraces()); @@ -330,7 +331,7 @@ public function testShouldAllowGetInfoSentToDifferentCommands() $producer->sendCommand('aFooCommand', 'aFooBody'); $producer->sendCommand('aBarCommand', 'aBarBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['command' => 'aFooCommand', 'body' => 'aFooBody'], ['command' => 'aBarCommand', 'body' => 'aBarBody'], ], $producer->getTraces()); @@ -343,11 +344,11 @@ public function testShouldAllowGetInfoSentToSpecialCommand() $producer->sendCommand('aFooCommand', 'aFooBody'); $producer->sendCommand('aBarCommand', 'aBarBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['command' => 'aFooCommand', 'body' => 'aFooBody'], ], $producer->getCommandTraces('aFooCommand')); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['command' => 'aBarCommand', 'body' => 'aBarBody'], ], $producer->getCommandTraces('aBarCommand')); } diff --git a/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php b/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php index 62066737c..4f8ac7a55 100644 --- a/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php +++ b/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php @@ -3,6 +3,7 @@ namespace Enqueue\Tests\Consumption; use Enqueue\Consumption\FallbackSubscriptionConsumer; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\Consumer; use Interop\Queue\Message as InteropMessage; use Interop\Queue\Queue as InteropQueue; @@ -11,6 +12,8 @@ class FallbackSubscriptionConsumerTest extends TestCase { + use ReadAttributeTrait; + public function testShouldImplementSubscriptionConsumerInterface() { $rc = new \ReflectionClass(FallbackSubscriptionConsumer::class); diff --git a/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php index 9e25ab931..ecf7f9afa 100644 --- a/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php +++ b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php @@ -21,6 +21,7 @@ use Enqueue\Consumption\QueueConsumer; use Enqueue\Consumption\Result; use Enqueue\Null\NullQueue; +use Enqueue\Test\ReadAttributeTrait; use Enqueue\Tests\Consumption\Mock\BreakCycleExtension; use Enqueue\Tests\Consumption\Mock\DummySubscriptionConsumer; use Interop\Queue\Consumer; @@ -36,6 +37,8 @@ class QueueConsumerTest extends TestCase { + use ReadAttributeTrait; + public function testCouldBeConstructedWithAllArguments() { new QueueConsumer($this->createContextStub(), null, [], null, 0); @@ -177,7 +180,7 @@ public function testShouldAllowBindCallbackToQueueName() $boundProcessors = $this->readAttribute($consumer, 'boundProcessors'); - $this->assertInternalType('array', $boundProcessors); + self::assertIsArray($boundProcessors); $this->assertCount(1, $boundProcessors); $this->assertArrayHasKey($queueName, $boundProcessors); @@ -203,7 +206,6 @@ public function testShouldUseContextSubscriptionConsumerIfSupport() $contextSubscriptionConsumer ->expects($this->once()) ->method('consume') - ->willReturn(null) ; $fallbackSubscriptionConsumer = $this->createSubscriptionConsumerMock(); @@ -251,7 +253,6 @@ public function testShouldUseFallbackSubscriptionConsumerIfNotSupported() $fallbackSubscriptionConsumer ->expects($this->once()) ->method('consume') - ->willReturn(null) ; $contextMock = $this->createContextWithoutSubscriptionConsumerMock(); @@ -288,7 +289,6 @@ public function testShouldSubscribeToGivenQueueWithExpectedTimeout() ->expects($this->once()) ->method('consume') ->with(12345) - ->willReturn(null) ; $contextMock = $this->createContextWithoutSubscriptionConsumerMock(); @@ -319,7 +319,6 @@ public function testShouldSubscribeToGivenQueueAndQuitAfterFifthConsumeCycle() $subscriptionConsumerMock ->expects($this->exactly(5)) ->method('consume') - ->willReturn(null) ; $contextMock = $this->createContextWithoutSubscriptionConsumerMock(); @@ -1538,6 +1537,9 @@ private function createExtension() */ private function createConsumerStub($queue = null): Consumer { + if (null === $queue) { + $queue = 'queue'; + } if (is_string($queue)) { $queue = new NullQueue($queue); } diff --git a/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php b/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php index 7282aa42e..14f7b1006 100644 --- a/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php +++ b/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php @@ -9,9 +9,12 @@ use Enqueue\Dbal\ManagerRegistryConnectionFactory; use Enqueue\Doctrine\DoctrineConnectionFactoryFactory; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; class DoctrineConnectionFactoryFactoryTest extends TestCase { + use ProphecyTrait; + /** * @var ManagerRegistry|\Prophecy\Prophecy\ObjectProphecy */ @@ -25,7 +28,7 @@ class DoctrineConnectionFactoryFactoryTest extends TestCase */ private $factory; - protected function setUp() + protected function setUp(): void { $this->registry = $this->prophesize(ManagerRegistry::class); $this->fallbackFactory = $this->prophesize(ConnectionFactoryFactoryInterface::class); diff --git a/pkg/enqueue/Tests/ResourcesTest.php b/pkg/enqueue/Tests/ResourcesTest.php index 214a0836f..ec713fd03 100644 --- a/pkg/enqueue/Tests/ResourcesTest.php +++ b/pkg/enqueue/Tests/ResourcesTest.php @@ -28,7 +28,7 @@ public function testShouldGetAvailableConnectionsInExpectedFormat() { $availableConnections = Resources::getAvailableConnections(); - $this->assertInternalType('array', $availableConnections); + self::assertIsArray($availableConnections); $this->assertArrayHasKey(RedisConnectionFactory::class, $availableConnections); $connectionInfo = $availableConnections[RedisConnectionFactory::class]; @@ -46,7 +46,7 @@ public function testShouldGetKnownConnectionsInExpectedFormat() { $availableConnections = Resources::getKnownConnections(); - $this->assertInternalType('array', $availableConnections); + self::assertIsArray($availableConnections); $this->assertArrayHasKey(RedisConnectionFactory::class, $availableConnections); $connectionInfo = $availableConnections[RedisConnectionFactory::class]; @@ -93,12 +93,12 @@ public function testShouldAllowRegisterConnectionThatIsNotInstalled() Resources::addConnection('theConnectionClass', ['foo'], [], 'foo'); $knownConnections = Resources::getKnownConnections(); - $this->assertInternalType('array', $knownConnections); + self::assertIsArray($knownConnections); $this->assertArrayHasKey('theConnectionClass', $knownConnections); $availableConnections = Resources::getAvailableConnections(); - $this->assertInternalType('array', $availableConnections); + self::assertIsArray($availableConnections); $this->assertArrayNotHasKey('theConnectionClass', $availableConnections); } @@ -115,7 +115,7 @@ public function testShouldAllowGetPreviouslyRegisteredConnection() $availableConnections = Resources::getAvailableConnections(); - $this->assertInternalType('array', $availableConnections); + self::assertIsArray($availableConnections); $this->assertArrayHasKey($connectionClass, $availableConnections); $connectionInfo = $availableConnections[$connectionClass]; @@ -133,7 +133,7 @@ public function testShouldHaveRegisteredWampConfiguration() { $availableConnections = Resources::getKnownConnections(); - $this->assertInternalType('array', $availableConnections); + self::assertIsArray($availableConnections); $this->assertArrayHasKey(WampConnectionFactory::class, $availableConnections); $connectionInfo = $availableConnections[WampConnectionFactory::class]; diff --git a/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php index be7de228e..1d94e6e51 100644 --- a/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php @@ -605,13 +605,13 @@ private function createQueueConsumerMock() /** * @return \PHPUnit\Framework\MockObject\MockObject|DriverInterface */ - private function createDriverStub(RouteCollection $routeCollection = null): DriverInterface + private function createDriverStub(?RouteCollection $routeCollection = null): DriverInterface { $driverMock = $this->createMock(DriverInterface::class); $driverMock ->expects($this->any()) ->method('getRouteCollection') - ->willReturn($routeCollection) + ->willReturn($routeCollection ?? new RouteCollection([])) ; $driverMock @@ -677,6 +677,9 @@ private function createExtension() */ private function createConsumerStub($queue = null): Consumer { + if (null === $queue) { + $queue = 'queue'; + } if (is_string($queue)) { $queue = new NullQueue($queue); } diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildClientExtensionsPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildClientExtensionsPassTest.php index af69293d1..90c7493c1 100644 --- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildClientExtensionsPassTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildClientExtensionsPassTest.php @@ -72,7 +72,7 @@ public function testShouldRegisterClientExtension() $pass = new BuildClientExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + self::assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), new Reference('aBarExtension'), @@ -99,7 +99,7 @@ public function testShouldIgnoreOtherClientExtensions() $pass = new BuildClientExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + self::assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $extensions->getArgument(0)); @@ -125,7 +125,7 @@ public function testShouldAddExtensionIfClientAll() $pass = new BuildClientExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + self::assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $extensions->getArgument(0)); @@ -151,7 +151,7 @@ public function testShouldTreatTagsWithoutClientAsDefaultClient() $pass = new BuildClientExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + self::assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), new Reference('aBarExtension'), @@ -247,7 +247,7 @@ public function testShouldMergeWithAddedPreviously() $pass = new BuildClientExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + self::assertIsArray($extensions->getArgument(0)); $this->assertCount(4, $extensions->getArgument(0)); } @@ -275,12 +275,12 @@ public function testShouldRegisterProcessorWithMatchedNameToCorrespondingExtensi $pass = new BuildClientExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $fooExtensions->getArgument(0)); + self::assertIsArray($fooExtensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $fooExtensions->getArgument(0)); - $this->assertInternalType('array', $barExtensions->getArgument(0)); + self::assertIsArray($barExtensions->getArgument(0)); $this->assertEquals([ new Reference('aBarExtension'), ], $barExtensions->getArgument(0)); diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php index 346c0cbdb..a2e964dcc 100644 --- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php @@ -96,7 +96,7 @@ public function testShouldRegisterProcessorWithMatchedName() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -120,7 +120,7 @@ public function testShouldRegisterProcessorWithoutNameToDefaultClient() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -144,7 +144,7 @@ public function testShouldRegisterProcessorIfClientNameEqualsAll() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -166,7 +166,7 @@ public function testShouldRegisterProcessorIfCommandsIsString() $pass = new BuildCommandSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); $this->assertEquals( @@ -222,7 +222,7 @@ public function testShouldRegisterProcessorIfCommandsAreStrings() $pass = new BuildCommandSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(2, $routeCollection->getArgument(0)); $this->assertEquals( @@ -266,7 +266,7 @@ public function testShouldRegisterProcessorIfParamSingleCommandArray() $pass = new BuildCommandSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); @@ -305,7 +305,7 @@ public function testShouldRegisterProcessorIfCommandsAreParamArrays() $pass = new BuildCommandSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(2, $routeCollection->getArgument(0)); $this->assertEquals( @@ -372,7 +372,7 @@ public function testShouldMergeExtractedRoutesWithAlreadySetInCollection() $pass = new BuildCommandSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(3, $routeCollection->getArgument(0)); $this->assertEquals( @@ -422,7 +422,7 @@ public function testShouldRegister08CommandProcessor() $pass = new BuildCommandSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); $this->assertEquals( diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPassTest.php index db991e982..a94636261 100644 --- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPassTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPassTest.php @@ -72,7 +72,7 @@ public function testShouldRegisterClientExtension() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + self::assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), new Reference('aBarExtension'), @@ -99,7 +99,7 @@ public function testShouldIgnoreOtherClientExtensions() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + self::assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $extensions->getArgument(0)); @@ -125,7 +125,7 @@ public function testShouldAddExtensionIfClientAll() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + self::assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $extensions->getArgument(0)); @@ -151,7 +151,7 @@ public function testShouldTreatTagsWithoutClientAsDefaultClient() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + self::assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), new Reference('aBarExtension'), @@ -247,7 +247,7 @@ public function testShouldMergeWithAddedPreviously() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + self::assertIsArray($extensions->getArgument(0)); $this->assertCount(4, $extensions->getArgument(0)); } @@ -275,12 +275,12 @@ public function testShouldRegisterProcessorWithMatchedNameToCorrespondingExtensi $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $fooExtensions->getArgument(0)); + self::assertIsArray($fooExtensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $fooExtensions->getArgument(0)); - $this->assertInternalType('array', $barExtensions->getArgument(0)); + self::assertIsArray($barExtensions->getArgument(0)); $this->assertEquals([ new Reference('aBarExtension'), ], $barExtensions->getArgument(0)); diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRegistryPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRegistryPassTest.php index 4d95ca07d..8541f39bf 100644 --- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRegistryPassTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRegistryPassTest.php @@ -136,7 +136,7 @@ private function assertLocatorServices(ContainerBuilder $container, $locatorId, $locatorId = (string) $locatorId; $this->assertTrue($container->hasDefinition($locatorId)); - $this->assertRegExp('/\.?service_locator\..*?\.enqueue\./', $locatorId); + $this->assertMatchesRegularExpression('/\.?service_locator\..*?\.enqueue\./', $locatorId); $match = []; if (false == preg_match('/(\.?service_locator\..*?)\.enqueue\./', $locatorId, $match)) { diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRoutesPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRoutesPassTest.php index 74553e6eb..b2839c466 100644 --- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRoutesPassTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRoutesPassTest.php @@ -112,7 +112,7 @@ public function testShouldRegisterProcessorWithMatchedName() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -136,7 +136,7 @@ public function testShouldRegisterProcessorWithoutNameToDefaultClient() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -160,7 +160,7 @@ public function testShouldRegisterProcessorIfClientNameEqualsAll() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -180,7 +180,7 @@ public function testShouldRegisterAsTopicProcessor() $pass = new BuildProcessorRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); $this->assertEquals( @@ -212,7 +212,7 @@ public function testShouldRegisterAsCommandProcessor() $pass = new BuildProcessorRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); $this->assertEquals( @@ -244,7 +244,7 @@ public function testShouldRegisterWithCustomProcessorName() $pass = new BuildProcessorRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); $this->assertEquals( @@ -279,7 +279,7 @@ public function testShouldMergeExtractedRoutesWithAlreadySetInCollection() $pass = new BuildProcessorRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(3, $routeCollection->getArgument(0)); $this->assertEquals( diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php index 65b64dcc8..af1c6a37a 100644 --- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php @@ -96,7 +96,7 @@ public function testShouldRegisterProcessorWithMatchedName() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -120,7 +120,7 @@ public function testShouldRegisterProcessorWithoutNameToDefaultClient() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -144,7 +144,7 @@ public function testShouldRegisterProcessorIfClientNameEqualsAll() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -166,7 +166,7 @@ public function testShouldRegisterProcessorIfTopicsIsString() $pass = new BuildTopicSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); $this->assertEquals( @@ -222,7 +222,7 @@ public function testShouldRegisterProcessorIfTopicsAreStrings() $pass = new BuildTopicSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(2, $routeCollection->getArgument(0)); $this->assertEquals( @@ -265,7 +265,7 @@ public function testShouldRegisterProcessorIfTopicsAreParamArrays() $pass = new BuildTopicSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(2, $routeCollection->getArgument(0)); $this->assertEquals( @@ -332,7 +332,7 @@ public function testShouldMergeExtractedRoutesWithAlreadySetInCollection() $pass = new BuildTopicSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(3, $routeCollection->getArgument(0)); $this->assertEquals( @@ -379,7 +379,7 @@ public function testShouldRegister08TopicSubscriber() $pass = new BuildTopicSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + self::assertIsArray($routeCollection->getArgument(0)); $this->assertCount(2, $routeCollection->getArgument(0)); $this->assertEquals( diff --git a/pkg/enqueue/Tests/Symfony/Client/FlushSpoolProducerListenerTest.php b/pkg/enqueue/Tests/Symfony/Client/FlushSpoolProducerListenerTest.php index e7ca3ffd5..3476c101e 100644 --- a/pkg/enqueue/Tests/Symfony/Client/FlushSpoolProducerListenerTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/FlushSpoolProducerListenerTest.php @@ -23,7 +23,7 @@ public function testShouldSubscribeOnKernelTerminateEvent() { $events = FlushSpoolProducerListener::getSubscribedEvents(); - $this->assertInternalType('array', $events); + self::assertIsArray($events); $this->assertArrayHasKey(KernelEvents::TERMINATE, $events); $this->assertEquals('flushMessages', $events[KernelEvents::TERMINATE]); @@ -33,7 +33,7 @@ public function testShouldSubscribeOnConsoleTerminateEvent() { $events = FlushSpoolProducerListener::getSubscribedEvents(); - $this->assertInternalType('array', $events); + self::assertIsArray($events); $this->assertArrayHasKey(ConsoleEvents::TERMINATE, $events); $this->assertEquals('flushMessages', $events[ConsoleEvents::TERMINATE]); diff --git a/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php index d9935bdf4..04980c135 100644 --- a/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php @@ -116,7 +116,7 @@ public function testShouldUseFooDriver() '--client' => 'foo', ]); - $this->assertContains('Found 1 routes', $tester->getDisplay()); + $this->assertStringContainsString('Found 1 routes', $tester->getDisplay()); } public function testThrowIfClientNotFound() @@ -331,7 +331,7 @@ public function testShouldOutputRouteOptions() } /** - * @return \PHPUnit\Framework\MockObject\MockObject + * @return \PHPUnit\Framework\MockObject\MockObject|DriverInterface */ private function createDriverStub(Config $config, RouteCollection $routeCollection): DriverInterface { diff --git a/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php index 358206dc7..82345b2bf 100644 --- a/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php @@ -78,7 +78,7 @@ public function testShouldCallDriverSetupBrokerMethod() $tester = new CommandTester($command); $tester->execute([]); - $this->assertContains('Broker set up', $tester->getDisplay()); + $this->assertStringContainsString('Broker set up', $tester->getDisplay()); } public function testShouldCallRequestedClientDriverSetupBrokerMethod() @@ -105,7 +105,7 @@ public function testShouldCallRequestedClientDriverSetupBrokerMethod() '--client' => 'foo', ]); - $this->assertContains('Broker set up', $tester->getDisplay()); + $this->assertStringContainsString('Broker set up', $tester->getDisplay()); } public function testShouldThrowIfClientNotFound() diff --git a/pkg/enqueue/Tests/Symfony/Client/SimpleConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/SimpleConsumeCommandTest.php index 8f23acdbc..fb89dae32 100644 --- a/pkg/enqueue/Tests/Symfony/Client/SimpleConsumeCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/SimpleConsumeCommandTest.php @@ -122,13 +122,13 @@ private function createQueueConsumerMock() /** * @return \PHPUnit\Framework\MockObject\MockObject|DriverInterface */ - private function createDriverStub(RouteCollection $routeCollection = null): DriverInterface + private function createDriverStub(?RouteCollection $routeCollection = null): DriverInterface { $driverMock = $this->createMock(DriverInterface::class); $driverMock ->expects($this->any()) ->method('getRouteCollection') - ->willReturn($routeCollection) + ->willReturn($routeCollection ?? new RouteCollection([])) ; $driverMock diff --git a/pkg/enqueue/Tests/Symfony/Client/SimpleSetupBrokerCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/SimpleSetupBrokerCommandTest.php index 0d30582e1..f9a66129c 100644 --- a/pkg/enqueue/Tests/Symfony/Client/SimpleSetupBrokerCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/SimpleSetupBrokerCommandTest.php @@ -74,7 +74,7 @@ public function testShouldCallDriverSetupBrokerMethod() $tester = new CommandTester($command); $tester->execute([]); - $this->assertContains('Broker set up', $tester->getDisplay()); + $this->assertStringContainsString('Broker set up', $tester->getDisplay()); } /** diff --git a/pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php index c2f2257c0..348397137 100644 --- a/pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php @@ -221,6 +221,9 @@ private function createExtension() */ private function createConsumerStub($queue = null): Consumer { + if (null === $queue) { + $queue = 'queue'; + } if (is_string($queue)) { $queue = new NullQueue($queue); } diff --git a/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildConsumptionExtensionsPassTest.php b/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildConsumptionExtensionsPassTest.php index b26b4481f..f16daf08a 100644 --- a/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildConsumptionExtensionsPassTest.php +++ b/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildConsumptionExtensionsPassTest.php @@ -72,7 +72,7 @@ public function testShouldRegisterTransportExtension() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + self::assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), new Reference('aBarExtension'), @@ -99,7 +99,7 @@ public function testShouldIgnoreOtherTransportExtensions() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + self::assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $extensions->getArgument(0)); @@ -125,7 +125,7 @@ public function testShouldAddExtensionIfTransportAll() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + self::assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $extensions->getArgument(0)); @@ -151,7 +151,7 @@ public function testShouldTreatTagsWithoutTransportAsDefaultTransport() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + self::assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), new Reference('aBarExtension'), @@ -247,7 +247,7 @@ public function testShouldMergeWithAddedPreviously() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + self::assertIsArray($extensions->getArgument(0)); $this->assertCount(4, $extensions->getArgument(0)); } @@ -275,12 +275,12 @@ public function testShouldRegisterProcessorWithMatchedNameToCorrespondingRegistr $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $fooExtensions->getArgument(0)); + self::assertIsArray($fooExtensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $fooExtensions->getArgument(0)); - $this->assertInternalType('array', $barExtensions->getArgument(0)); + self::assertIsArray($barExtensions->getArgument(0)); $this->assertEquals([ new Reference('aBarExtension'), ], $barExtensions->getArgument(0)); diff --git a/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildProcessorRegistryPassTest.php b/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildProcessorRegistryPassTest.php index 989d048cf..8d8edc537 100644 --- a/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildProcessorRegistryPassTest.php +++ b/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildProcessorRegistryPassTest.php @@ -199,7 +199,7 @@ private function assertLocatorServices(ContainerBuilder $container, $locatorId, $locatorId = (string) $locatorId; $this->assertTrue($container->hasDefinition($locatorId)); - $this->assertRegExp('/\.?service_locator\..*?\.enqueue\./', $locatorId); + $this->assertMatchesRegularExpression('/\.?service_locator\..*?\.enqueue\./', $locatorId); $match = []; if (false == preg_match('/(\.?service_locator\..*?)\.enqueue\./', $locatorId, $match)) { diff --git a/pkg/enqueue/Tests/Util/UUIDTest.php b/pkg/enqueue/Tests/Util/UUIDTest.php index ac3090315..f21693e78 100644 --- a/pkg/enqueue/Tests/Util/UUIDTest.php +++ b/pkg/enqueue/Tests/Util/UUIDTest.php @@ -11,7 +11,7 @@ public function testShouldGenerateUniqueId() { $uuid = UUID::generate(); - $this->assertInternalType('string', $uuid); + $this->assertIsString($uuid); $this->assertEquals(36, strlen($uuid)); } diff --git a/pkg/enqueue/composer.json b/pkg/enqueue/composer.json index ed9603057..e8c3f3ade 100644 --- a/pkg/enqueue/composer.json +++ b/pkg/enqueue/composer.json @@ -6,7 +6,7 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "queue-interop/amqp-interop": "^0.8", "queue-interop/queue-interop": "^0.8", "enqueue/null": "^0.10", @@ -16,7 +16,7 @@ "psr/container": "^1" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "symfony/console": "^4.3|^5", "symfony/dependency-injection": "^4.3|^5", "symfony/config": "^4.3|^5", diff --git a/pkg/fs/Tests/FsConnectionFactoryConfigTest.php b/pkg/fs/Tests/FsConnectionFactoryConfigTest.php index 59193d26d..970fef395 100644 --- a/pkg/fs/Tests/FsConnectionFactoryConfigTest.php +++ b/pkg/fs/Tests/FsConnectionFactoryConfigTest.php @@ -4,6 +4,7 @@ use Enqueue\Fs\FsConnectionFactory; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use PHPUnit\Framework\TestCase; /** @@ -12,6 +13,7 @@ class FsConnectionFactoryConfigTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testThrowNeitherArrayStringNorNullGivenAsConfig() { diff --git a/pkg/fs/Tests/FsConnectionFactoryTest.php b/pkg/fs/Tests/FsConnectionFactoryTest.php index 35558573a..2df442342 100644 --- a/pkg/fs/Tests/FsConnectionFactoryTest.php +++ b/pkg/fs/Tests/FsConnectionFactoryTest.php @@ -5,11 +5,13 @@ use Enqueue\Fs\FsConnectionFactory; use Enqueue\Fs\FsContext; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\ConnectionFactory; class FsConnectionFactoryTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementConnectionFactoryInterface() { diff --git a/pkg/fs/Tests/FsContextTest.php b/pkg/fs/Tests/FsContextTest.php index 377ec0007..4bc05e9de 100644 --- a/pkg/fs/Tests/FsContextTest.php +++ b/pkg/fs/Tests/FsContextTest.php @@ -9,6 +9,7 @@ use Enqueue\Fs\FsProducer; use Enqueue\Null\NullQueue; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\Context; use Interop\Queue\Exception\InvalidDestinationException; use Makasim\File\TempFile; @@ -16,6 +17,7 @@ class FsContextTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementContextInterface() { @@ -190,7 +192,7 @@ public function testShouldCreateFileOnFilesystemIfNotExistOnDeclareDestination() $queue = $context->createQueue($tmpFile->getFilename()); - $this->assertFileNotExists((string) $tmpFile); + $this->assertFileDoesNotExist((string) $tmpFile); $context->declareDestination($queue); diff --git a/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php b/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php index 1ae462731..7abb9d91c 100644 --- a/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php +++ b/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php @@ -17,14 +17,14 @@ class FsCommonUseCasesTest extends \PHPUnit\Framework\TestCase */ private $fsContext; - public function setUp() + protected function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); new TempFile(sys_get_temp_dir().'/fs_test_queue'); } - public function tearDown(): void + protected function tearDown(): void { $this->fsContext->close(); } diff --git a/pkg/fs/Tests/Functional/FsConsumerTest.php b/pkg/fs/Tests/Functional/FsConsumerTest.php index 9dd7a0103..984ea160a 100644 --- a/pkg/fs/Tests/Functional/FsConsumerTest.php +++ b/pkg/fs/Tests/Functional/FsConsumerTest.php @@ -15,14 +15,14 @@ class FsConsumerTest extends TestCase */ private $fsContext; - public function setUp() + protected function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); $this->fsContext->purgeQueue($this->fsContext->createQueue('fs_test_queue')); } - public function tearDown(): void + protected function tearDown(): void { $this->fsContext->close(); } diff --git a/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php b/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php index 98895a62d..334a8fe7d 100644 --- a/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php +++ b/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php @@ -25,14 +25,14 @@ class FsConsumptionUseCasesTest extends \PHPUnit\Framework\TestCase */ private $fsContext; - public function setUp() + protected function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); new TempFile(sys_get_temp_dir().'/fs_test_queue'); } - public function tearDown(): void + protected function tearDown(): void { $this->fsContext->close(); } diff --git a/pkg/fs/Tests/Functional/FsProducerTest.php b/pkg/fs/Tests/Functional/FsProducerTest.php index 6f7e4b4fa..75625cfdd 100644 --- a/pkg/fs/Tests/Functional/FsProducerTest.php +++ b/pkg/fs/Tests/Functional/FsProducerTest.php @@ -14,7 +14,7 @@ class FsProducerTest extends TestCase */ private $fsContext; - public function setUp() + protected function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); @@ -22,7 +22,7 @@ public function setUp() file_put_contents(sys_get_temp_dir().'/fs_test_queue', ''); } - public function tearDown(): void + protected function tearDown(): void { $this->fsContext->close(); } diff --git a/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php b/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php index 046a25f9c..3a0327d7c 100644 --- a/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php +++ b/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php @@ -20,7 +20,7 @@ class FsRpcUseCasesTest extends TestCase */ private $fsContext; - public function setUp() + protected function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); @@ -28,7 +28,7 @@ public function setUp() new TempFile(sys_get_temp_dir().'/fs_reply_queue'); } - public function tearDown(): void + protected function tearDown(): void { $this->fsContext->close(); } diff --git a/pkg/fs/Tests/LegacyFilesystemLockTest.php b/pkg/fs/Tests/LegacyFilesystemLockTest.php index 77d729886..519712881 100644 --- a/pkg/fs/Tests/LegacyFilesystemLockTest.php +++ b/pkg/fs/Tests/LegacyFilesystemLockTest.php @@ -6,12 +6,14 @@ use Enqueue\Fs\LegacyFilesystemLock; use Enqueue\Fs\Lock; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Makasim\File\TempFile; use PHPUnit\Framework\TestCase; class LegacyFilesystemLockTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementLockInterface() { diff --git a/pkg/fs/composer.json b/pkg/fs/composer.json index 19d2fd841..40cfe59c3 100644 --- a/pkg/fs/composer.json +++ b/pkg/fs/composer.json @@ -6,14 +6,14 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "queue-interop/queue-interop": "^0.8", "enqueue/dsn": "^0.10", "symfony/filesystem": "^4.3|^5", "makasim/temp-file": "^0.2@stable" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/null": "0.10.x-dev", "enqueue/test": "0.10.x-dev", "queue-interop/queue-spec": "^0.6", diff --git a/pkg/gearman/Tests/GearmanConnectionFactoryConfigTest.php b/pkg/gearman/Tests/GearmanConnectionFactoryConfigTest.php index bb8ab7ad6..84826d5f9 100644 --- a/pkg/gearman/Tests/GearmanConnectionFactoryConfigTest.php +++ b/pkg/gearman/Tests/GearmanConnectionFactoryConfigTest.php @@ -4,6 +4,7 @@ use Enqueue\Gearman\GearmanConnectionFactory; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use PHPUnit\Framework\TestCase; /** @@ -12,6 +13,7 @@ class GearmanConnectionFactoryConfigTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; use SkipIfGearmanExtensionIsNotInstalledTrait; public function testThrowNeitherArrayStringNorNullGivenAsConfig() diff --git a/pkg/gearman/Tests/SkipIfGearmanExtensionIsNotInstalledTrait.php b/pkg/gearman/Tests/SkipIfGearmanExtensionIsNotInstalledTrait.php index 99419eb15..9c680bb67 100644 --- a/pkg/gearman/Tests/SkipIfGearmanExtensionIsNotInstalledTrait.php +++ b/pkg/gearman/Tests/SkipIfGearmanExtensionIsNotInstalledTrait.php @@ -4,7 +4,7 @@ trait SkipIfGearmanExtensionIsNotInstalledTrait { - public function setUp() + public function setUp(): void { if (false == class_exists(\GearmanClient::class)) { $this->markTestSkipped('The gearman extension is not installed'); diff --git a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php index c90432e00..4d53934ff 100644 --- a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php +++ b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php @@ -13,7 +13,7 @@ class GearmanSendToTopicAndReceiveFromQueueTest extends SendToTopicAndReceiveFro { private $time; - public function setUp() + protected function setUp(): void { $this->time = time(); } diff --git a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php index 469f9e997..26e6f79a4 100644 --- a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php +++ b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php @@ -13,7 +13,7 @@ class GearmanSendToTopicAndReceiveNoWaitFromQueueTest extends SendToTopicAndRece { private $time; - public function setUp() + protected function setUp(): void { $this->time = time(); } diff --git a/pkg/gearman/composer.json b/pkg/gearman/composer.json index a2b2eeccd..92dd3bc09 100644 --- a/pkg/gearman/composer.json +++ b/pkg/gearman/composer.json @@ -6,12 +6,12 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "ext-gearman": "^2.0", "queue-interop/queue-interop": "^0.8" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "enqueue/null": "0.10.x-dev", "queue-interop/queue-spec": "^0.6" diff --git a/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php b/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php index a1700f64f..039e86cd4 100644 --- a/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php +++ b/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php @@ -4,6 +4,7 @@ use Enqueue\Gps\GpsConnectionFactory; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use PHPUnit\Framework\TestCase; /** @@ -12,6 +13,7 @@ class GpsConnectionFactoryConfigTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testThrowNeitherArrayStringNorNullGivenAsConfig() { diff --git a/pkg/gps/composer.json b/pkg/gps/composer.json index 7a9868f2f..116a5dbf8 100644 --- a/pkg/gps/composer.json +++ b/pkg/gps/composer.json @@ -6,13 +6,13 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "queue-interop/queue-interop": "^0.8", "google/cloud-pubsub": "^1.0", "enqueue/dsn": "^0.10" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "queue-interop/queue-spec": "^0.6" }, diff --git a/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php b/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php index bcb62531a..f289c314c 100644 --- a/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php +++ b/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php @@ -102,7 +102,10 @@ public function testShouldCalculateRootJobStatusAndSetStoppedAtTimeIfGotStopStat $case->calculate($childJob); $this->assertEquals($stopStatus, $rootJob->getStatus()); - $this->assertEquals(new \DateTime(), $rootJob->getStoppedAt(), '', 1); + $this->assertEquals( + (new \DateTime())->getTimestamp(), + $rootJob->getStoppedAt()->getTimestamp() + ); } public function testShouldSetStoppedAtOnlyIfWasNotSet() @@ -129,7 +132,10 @@ public function testShouldSetStoppedAtOnlyIfWasNotSet() $case = new CalculateRootJobStatusService($em); $case->calculate($childJob); - $this->assertEquals(new \DateTime('2012-12-12 12:12:12'), $rootJob->getStoppedAt()); + $this->assertEquals( + (new \DateTime('2012-12-12 12:12:12'))->getTimestamp(), + $rootJob->getStoppedAt()->getTimestamp() + ); } public function testShouldThrowIfInvalidStatus() diff --git a/pkg/job-queue/Tests/Functional/WebTestCase.php b/pkg/job-queue/Tests/Functional/WebTestCase.php index 2f8e17cea..90a8188dd 100644 --- a/pkg/job-queue/Tests/Functional/WebTestCase.php +++ b/pkg/job-queue/Tests/Functional/WebTestCase.php @@ -18,7 +18,7 @@ abstract class WebTestCase extends BaseWebTestCase */ protected static $container; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/pkg/job-queue/Tests/JobProcessorTest.php b/pkg/job-queue/Tests/JobProcessorTest.php index f4e937c02..3f06bf8de 100644 --- a/pkg/job-queue/Tests/JobProcessorTest.php +++ b/pkg/job-queue/Tests/JobProcessorTest.php @@ -60,8 +60,14 @@ public function testShouldCreateRootJobAndReturnIt() $this->assertSame($job, $result); $this->assertEquals(Job::STATUS_NEW, $job->getStatus()); - $this->assertEquals(new \DateTime(), $job->getCreatedAt(), '', 1); - $this->assertEquals(new \DateTime(), $job->getStartedAt(), '', 1); + $this->assertEquals( + (new \DateTime())->getTimestamp(), + $job->getCreatedAt()->getTimestamp() + ); + $this->assertEquals( + (new \DateTime())->getTimestamp(), + $job->getStartedAt()->getTimestamp() + ); $this->assertNull($job->getStoppedAt()); $this->assertEquals('job-name', $job->getName()); $this->assertEquals('owner-id', $job->getOwnerId()); @@ -183,7 +189,10 @@ public function testCreateChildJobShouldCreateAndSaveJobAndPublishRecalculateRoo $this->assertSame($job, $result); $this->assertEquals(Job::STATUS_NEW, $job->getStatus()); - $this->assertEquals(new \DateTime(), $job->getCreatedAt(), '', 1); + $this->assertEquals( + (new \DateTime())->getTimestamp(), + $job->getCreatedAt()->getTimestamp() + ); $this->assertNull($job->getStartedAt()); $this->assertNull($job->getStoppedAt()); $this->assertEquals('job-name', $job->getName()); @@ -256,7 +265,10 @@ public function testStartJobShouldUpdateJobWithRunningStatusAndStartAtTime() $processor->startChildJob($job); $this->assertEquals(Job::STATUS_RUNNING, $job->getStatus()); - $this->assertEquals(new \DateTime(), $job->getStartedAt(), '', 1); + $this->assertEquals( + (new \DateTime())->getTimestamp(), + $job->getStartedAt()->getTimestamp() + ); } public function testSuccessChildJobShouldThrowIfRootJob() @@ -325,7 +337,10 @@ public function testSuccessJobShouldUpdateJobWithSuccessStatusAndStopAtTime() $processor->successChildJob($job); $this->assertEquals(Job::STATUS_SUCCESS, $job->getStatus()); - $this->assertEquals(new \DateTime(), $job->getStoppedAt(), '', 1); + $this->assertEquals( + (new \DateTime())->getTimestamp(), + $job->getStoppedAt()->getTimestamp() + ); } public function testFailChildJobShouldThrowIfRootJob() @@ -394,7 +409,10 @@ public function testFailJobShouldUpdateJobWithFailStatusAndStopAtTime() $processor->failChildJob($job); $this->assertEquals(Job::STATUS_FAILED, $job->getStatus()); - $this->assertEquals(new \DateTime(), $job->getStoppedAt(), '', 1); + $this->assertEquals( + (new \DateTime())->getTimestamp(), + $job->getStoppedAt()->getTimestamp() + ); } public function testCancelChildJobShouldThrowIfRootJob() @@ -463,8 +481,14 @@ public function testCancelJobShouldUpdateJobWithCancelStatusAndStoppedAtTimeAndS $processor->cancelChildJob($job); $this->assertEquals(Job::STATUS_CANCELLED, $job->getStatus()); - $this->assertEquals(new \DateTime(), $job->getStoppedAt(), '', 1); - $this->assertEquals(new \DateTime(), $job->getStartedAt(), '', 1); + $this->assertEquals( + (new \DateTime())->getTimestamp(), + $job->getStoppedAt()->getTimestamp() + ); + $this->assertEquals( + (new \DateTime())->getTimestamp(), + $job->getStartedAt()->getTimestamp() + ); } public function testInterruptRootJobShouldThrowIfNotRootJob() @@ -536,7 +560,10 @@ public function testInterruptRootJobShouldUpdateJobAndSetInterruptedTrueAndStopp $processor->interruptRootJob($rootJob, true); $this->assertTrue($rootJob->isInterrupted()); - $this->assertEquals(new \DateTime(), $rootJob->getStoppedAt(), '', 1); + $this->assertEquals( + (new \DateTime())->getTimestamp(), + $rootJob->getStoppedAt()->getTimestamp() + ); } /** diff --git a/pkg/job-queue/composer.json b/pkg/job-queue/composer.json index 08b9889c2..cbe720e28 100644 --- a/pkg/job-queue/composer.json +++ b/pkg/job-queue/composer.json @@ -6,7 +6,7 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "enqueue/enqueue": "^0.10", "enqueue/null": "^0.10", "queue-interop/queue-interop": "^0.8", @@ -14,7 +14,7 @@ "doctrine/dbal": "<2.10" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "doctrine/doctrine-bundle": "~1.2|^2", "symfony/browser-kit": "^4.3|^5", diff --git a/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php b/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php index 6e7f01e5c..b6b644beb 100644 --- a/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php +++ b/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php @@ -19,7 +19,7 @@ class MongodbConsumerTest extends TestCase */ private $context; - public function setUp() + protected function setUp(): void { $this->context = $this->buildMongodbContext(); } diff --git a/pkg/mongodb/Tests/MongodbConnectionFactoryTest.php b/pkg/mongodb/Tests/MongodbConnectionFactoryTest.php index c15b0fa43..d5dd9ca45 100644 --- a/pkg/mongodb/Tests/MongodbConnectionFactoryTest.php +++ b/pkg/mongodb/Tests/MongodbConnectionFactoryTest.php @@ -5,6 +5,7 @@ use Enqueue\Mongodb\MongodbConnectionFactory; use Enqueue\Mongodb\MongodbContext; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\ConnectionFactory; use PHPUnit\Framework\TestCase; @@ -14,6 +15,7 @@ class MongodbConnectionFactoryTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementConnectionFactoryInterface() { diff --git a/pkg/mongodb/Tests/MongodbContextTest.php b/pkg/mongodb/Tests/MongodbContextTest.php index 32835c90e..94da3ae6a 100644 --- a/pkg/mongodb/Tests/MongodbContextTest.php +++ b/pkg/mongodb/Tests/MongodbContextTest.php @@ -8,6 +8,7 @@ use Enqueue\Mongodb\MongodbMessage; use Enqueue\Mongodb\MongodbProducer; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\Context; use Interop\Queue\Destination; use Interop\Queue\Exception\InvalidDestinationException; @@ -21,6 +22,7 @@ class MongodbContextTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementContextInterface() { diff --git a/pkg/mongodb/Tests/MongodbSubscriptionConsumerTest.php b/pkg/mongodb/Tests/MongodbSubscriptionConsumerTest.php index 7d3cb44f4..0fc5afae4 100644 --- a/pkg/mongodb/Tests/MongodbSubscriptionConsumerTest.php +++ b/pkg/mongodb/Tests/MongodbSubscriptionConsumerTest.php @@ -7,6 +7,7 @@ use Enqueue\Mongodb\MongodbConsumer; use Enqueue\Mongodb\MongodbContext; use Enqueue\Mongodb\MongodbSubscriptionConsumer; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\Consumer; use Interop\Queue\Queue; use Interop\Queue\SubscriptionConsumer; @@ -14,6 +15,8 @@ class MongodbSubscriptionConsumerTest extends TestCase { + use ReadAttributeTrait; + public function testShouldImplementSubscriptionConsumerInterface() { $rc = new \ReflectionClass(MongodbSubscriptionConsumer::class); diff --git a/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php index 9869d6e06..ab9b13aaa 100644 --- a/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php @@ -18,7 +18,7 @@ class MongodbSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceiveP private $publishedAt; - public function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/pkg/mongodb/composer.json b/pkg/mongodb/composer.json index 055abe0a2..d84c6e68f 100644 --- a/pkg/mongodb/composer.json +++ b/pkg/mongodb/composer.json @@ -10,13 +10,13 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "queue-interop/queue-interop": "^0.8", "mongodb/mongodb": "^1.2", "ext-mongodb": "^1.5" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "queue-interop/queue-spec": "^0.6", "enqueue/test": "0.10.x-dev", "enqueue/null": "0.10.x-dev" diff --git a/pkg/monitoring/composer.json b/pkg/monitoring/composer.json index ee23e109b..92d31ec96 100644 --- a/pkg/monitoring/composer.json +++ b/pkg/monitoring/composer.json @@ -6,12 +6,12 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "enqueue/enqueue": "^0.10", "enqueue/dsn": "^0.10" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "influxdb/influxdb-php": "^1.14", "datadog/php-datadogstatsd": "^1.3", diff --git a/pkg/null/composer.json b/pkg/null/composer.json index e2ef6c29e..5c43f40bc 100644 --- a/pkg/null/composer.json +++ b/pkg/null/composer.json @@ -6,11 +6,11 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "queue-interop/queue-interop": "^0.8" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "queue-interop/queue-spec": "^0.6" }, diff --git a/pkg/pheanstalk/Tests/PheanstalkConnectionFactoryConfigTest.php b/pkg/pheanstalk/Tests/PheanstalkConnectionFactoryConfigTest.php index 231ec0d77..ef0030d42 100644 --- a/pkg/pheanstalk/Tests/PheanstalkConnectionFactoryConfigTest.php +++ b/pkg/pheanstalk/Tests/PheanstalkConnectionFactoryConfigTest.php @@ -4,6 +4,7 @@ use Enqueue\Pheanstalk\PheanstalkConnectionFactory; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use PHPUnit\Framework\TestCase; /** @@ -12,6 +13,7 @@ class PheanstalkConnectionFactoryConfigTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testThrowNeitherArrayStringNorNullGivenAsConfig() { diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php index a6a5f925a..a961cdf3f 100644 --- a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php +++ b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php @@ -13,7 +13,7 @@ class PheanstalkSendToTopicAndReceiveFromQueueTest extends SendToTopicAndReceive { private $time; - public function setUp() + protected function setUp(): void { $this->time = time(); } diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php index 2bf9f9542..cedc0dd48 100644 --- a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php +++ b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php @@ -13,7 +13,7 @@ class PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest extends SendToTopicAndR { private $time; - public function setUp() + protected function setUp(): void { $this->time = time(); } diff --git a/pkg/pheanstalk/composer.json b/pkg/pheanstalk/composer.json index 7d7907ef1..40a32fb3c 100644 --- a/pkg/pheanstalk/composer.json +++ b/pkg/pheanstalk/composer.json @@ -6,12 +6,12 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "pda/pheanstalk": "^3", "queue-interop/queue-interop": "^0.8" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "enqueue/null": "0.10.x-dev", "queue-interop/queue-spec": "^0.6" diff --git a/pkg/rdkafka/Tests/JsonSerializerTest.php b/pkg/rdkafka/Tests/JsonSerializerTest.php index 6513a2257..84f09a698 100644 --- a/pkg/rdkafka/Tests/JsonSerializerTest.php +++ b/pkg/rdkafka/Tests/JsonSerializerTest.php @@ -43,7 +43,7 @@ public function testThrowIfFailedToEncodeMessageToJson() $resource = fopen(__FILE__, 'r'); //guard - $this->assertInternalType('resource', $resource); + $this->assertIsResource($resource); $message = new RdKafkaMessage('theBody', ['aProp' => $resource]); diff --git a/pkg/rdkafka/Tests/RdKafkaConnectionFactoryConfigTest.php b/pkg/rdkafka/Tests/RdKafkaConnectionFactoryConfigTest.php index d3a6a5dab..0a50218bb 100644 --- a/pkg/rdkafka/Tests/RdKafkaConnectionFactoryConfigTest.php +++ b/pkg/rdkafka/Tests/RdKafkaConnectionFactoryConfigTest.php @@ -4,6 +4,7 @@ use Enqueue\RdKafka\RdKafkaConnectionFactory; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use PHPUnit\Framework\TestCase; /** @@ -12,6 +13,7 @@ class RdKafkaConnectionFactoryConfigTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testThrowNeitherArrayStringNorNullGivenAsConfig() { @@ -39,7 +41,7 @@ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { $factory = new RdKafkaConnectionFactory($config); - $config = $this->getObjectAttribute($factory, 'config'); + $config = $this->readAttribute($factory, 'config'); $this->assertNotEmpty($config['global']['group.id']); diff --git a/pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php b/pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php index 47fdc1715..8af3e8501 100644 --- a/pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php +++ b/pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php @@ -3,6 +3,7 @@ namespace Enqueue\RdKafka\Tests; use Enqueue\RdKafka\RdKafkaConnectionFactory; +use Enqueue\Test\ReadAttributeTrait; use PHPUnit\Framework\TestCase; /** @@ -10,6 +11,8 @@ */ class RdKafkaConnectionFactoryTest extends TestCase { + use ReadAttributeTrait; + public function testThrowNeitherArrayStringNorNullGivenAsConfig() { $this->expectException(\LogicException::class); @@ -38,7 +41,7 @@ public function testShouldBeExpectedDefaultConfig() { $factory = new RdKafkaConnectionFactory(null); - $config = $this->getObjectAttribute($factory, 'config'); + $config = $this->readAttribute($factory, 'config'); $this->assertNotEmpty($config['global']['group.id']); @@ -55,7 +58,7 @@ public function testShouldBeExpectedDefaultDsnConfig() { $factory = new RdKafkaConnectionFactory('kafka:'); - $config = $this->getObjectAttribute($factory, 'config'); + $config = $this->readAttribute($factory, 'config'); $this->assertNotEmpty($config['global']['group.id']); diff --git a/pkg/rdkafka/composer.json b/pkg/rdkafka/composer.json index 4cdeb04ef..8db8e9cc3 100644 --- a/pkg/rdkafka/composer.json +++ b/pkg/rdkafka/composer.json @@ -6,12 +6,12 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "ext-rdkafka": "^3.0.3|^4.0|^5.0", "queue-interop/queue-interop": "^0.8" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "enqueue/null": "0.10.x-dev", "queue-interop/queue-spec": "^0.6", diff --git a/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php b/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php index a63672da8..87d97c289 100644 --- a/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php @@ -11,15 +11,15 @@ */ class PRedisCommonUseCasesTest extends TestCase { - use RedisExtension; use CommonUseCasesTrait; + use RedisExtension; /** * @var RedisContext */ private $context; - public function setUp() + protected function setUp(): void { $this->context = $this->buildPRedisContext(); @@ -27,7 +27,7 @@ public function setUp() $this->context->deleteTopic($this->context->createTopic('enqueue.test_topic')); } - public function tearDown(): void + protected function tearDown(): void { $this->context->close(); } diff --git a/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php b/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php index f748020f1..f68cf6129 100644 --- a/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php @@ -11,15 +11,15 @@ */ class PRedisConsumptionUseCasesTest extends TestCase { - use RedisExtension; use ConsumptionUseCasesTrait; + use RedisExtension; /** * @var RedisContext */ private $context; - public function setUp() + protected function setUp(): void { $this->context = $this->buildPRedisContext(); @@ -27,7 +27,7 @@ public function setUp() $this->context->deleteQueue($this->context->createQueue('enqueue.test_queue_reply')); } - public function tearDown(): void + protected function tearDown(): void { $this->context->close(); } diff --git a/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php b/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php index 41b403565..af9140704 100644 --- a/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php @@ -11,15 +11,15 @@ */ class PhpRedisCommonUseCasesTest extends TestCase { - use RedisExtension; use CommonUseCasesTrait; + use RedisExtension; /** * @var RedisContext */ private $context; - public function setUp() + protected function setUp(): void { $this->context = $this->buildPhpRedisContext(); @@ -27,7 +27,7 @@ public function setUp() $this->context->deleteTopic($this->context->createTopic('enqueue.test_topic')); } - public function tearDown(): void + protected function tearDown(): void { $this->context->close(); } diff --git a/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php b/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php index d48e4bcb4..cd5023178 100644 --- a/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php @@ -11,15 +11,15 @@ */ class PhpRedisConsumptionUseCasesTest extends TestCase { - use RedisExtension; use ConsumptionUseCasesTrait; + use RedisExtension; /** * @var RedisContext */ private $context; - public function setUp() + protected function setUp(): void { $this->context = $this->buildPhpRedisContext(); @@ -27,7 +27,7 @@ public function setUp() $this->context->deleteQueue($this->context->createQueue('enqueue.test_queue_reply')); } - public function tearDown(): void + protected function tearDown(): void { $this->context->close(); } diff --git a/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php b/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php index eee32baac..13eba9589 100644 --- a/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php +++ b/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php @@ -5,6 +5,7 @@ use Enqueue\Redis\Redis; use Enqueue\Redis\RedisConnectionFactory; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use PHPUnit\Framework\TestCase; /** @@ -13,6 +14,7 @@ class RedisConnectionFactoryConfigTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testThrowNeitherArrayStringNorNullGivenAsConfig() { diff --git a/pkg/redis/Tests/RedisConnectionFactoryTest.php b/pkg/redis/Tests/RedisConnectionFactoryTest.php index 049feaef9..1f9b3a259 100644 --- a/pkg/redis/Tests/RedisConnectionFactoryTest.php +++ b/pkg/redis/Tests/RedisConnectionFactoryTest.php @@ -5,12 +5,14 @@ use Enqueue\Redis\RedisConnectionFactory; use Enqueue\Redis\RedisContext; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\ConnectionFactory; use PHPUnit\Framework\TestCase; class RedisConnectionFactoryTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementConnectionFactoryInterface() { @@ -26,6 +28,6 @@ public function testShouldCreateLazyContext() $this->assertInstanceOf(RedisContext::class, $context); $this->assertAttributeEquals(null, 'redis', $context); - $this->assertInternalType('callable', $this->readAttribute($context, 'redisFactory')); + self::assertIsCallable($this->readAttribute($context, 'redisFactory')); } } diff --git a/pkg/redis/Tests/RedisProducerTest.php b/pkg/redis/Tests/RedisProducerTest.php index fa7260311..53d5f19e3 100644 --- a/pkg/redis/Tests/RedisProducerTest.php +++ b/pkg/redis/Tests/RedisProducerTest.php @@ -67,7 +67,7 @@ public function testShouldCallLPushOnSend() $this->assertNotEmpty($message['headers']['message_id']); $this->assertSame(0, $message['headers']['attempts']); - return true; + return 1; }) ; @@ -104,7 +104,7 @@ public function testShouldCallZaddOnSendWithDeliveryDelay() ->with( 'aDestination:delayed', $this->isJson(), - $this->equalTo(time() + 5, 1) + $this->equalTo(time() + 5) ) ; diff --git a/pkg/redis/Tests/RedisSubscriptionConsumerTest.php b/pkg/redis/Tests/RedisSubscriptionConsumerTest.php index ac8300cd2..b3ba4d26b 100644 --- a/pkg/redis/Tests/RedisSubscriptionConsumerTest.php +++ b/pkg/redis/Tests/RedisSubscriptionConsumerTest.php @@ -5,6 +5,7 @@ use Enqueue\Redis\RedisConsumer; use Enqueue\Redis\RedisContext; use Enqueue\Redis\RedisSubscriptionConsumer; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\Consumer; use Interop\Queue\Queue; use Interop\Queue\SubscriptionConsumer; @@ -12,6 +13,8 @@ class RedisSubscriptionConsumerTest extends TestCase { + use ReadAttributeTrait; + public function testShouldImplementSubscriptionConsumerInterface() { $rc = new \ReflectionClass(RedisSubscriptionConsumer::class); diff --git a/pkg/redis/Tests/Spec/JsonSerializerTest.php b/pkg/redis/Tests/Spec/JsonSerializerTest.php index 7516090a9..e374ea170 100644 --- a/pkg/redis/Tests/Spec/JsonSerializerTest.php +++ b/pkg/redis/Tests/Spec/JsonSerializerTest.php @@ -43,7 +43,7 @@ public function testThrowIfFailedToEncodeMessageToJson() $resource = fopen(__FILE__, 'r'); //guard - $this->assertInternalType('resource', $resource); + $this->assertIsResource($resource); $message = new RedisMessage('theBody', ['aProp' => $resource]); diff --git a/pkg/redis/composer.json b/pkg/redis/composer.json index 135f5a0c9..ace7230e5 100644 --- a/pkg/redis/composer.json +++ b/pkg/redis/composer.json @@ -6,13 +6,13 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "queue-interop/queue-interop": "^0.8", "enqueue/dsn": "^0.10", "ramsey/uuid": "^3|^4" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "predis/predis": "^1.1", "enqueue/test": "0.10.x-dev", "enqueue/null": "0.10.x-dev", diff --git a/pkg/simple-client/composer.json b/pkg/simple-client/composer.json index 3b525bf16..e06d880af 100644 --- a/pkg/simple-client/composer.json +++ b/pkg/simple-client/composer.json @@ -6,14 +6,14 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "enqueue/enqueue": "^0.10", "queue-interop/amqp-interop": "^0.8", "queue-interop/queue-interop": "^0.8", "symfony/config": "^4.3|^5" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "enqueue/amqp-ext": "0.10.x-dev", "enqueue/fs": "0.10.x-dev", diff --git a/pkg/sns/Tests/SnsConnectionFactoryConfigTest.php b/pkg/sns/Tests/SnsConnectionFactoryConfigTest.php index d9cbff390..5dd3a2baa 100644 --- a/pkg/sns/Tests/SnsConnectionFactoryConfigTest.php +++ b/pkg/sns/Tests/SnsConnectionFactoryConfigTest.php @@ -4,6 +4,7 @@ use Enqueue\Sns\SnsConnectionFactory; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use PHPUnit\Framework\TestCase; /** @@ -12,6 +13,7 @@ class SnsConnectionFactoryConfigTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testThrowNeitherArrayStringNorNullGivenAsConfig() { diff --git a/pkg/sns/Tests/SnsConnectionFactoryTest.php b/pkg/sns/Tests/SnsConnectionFactoryTest.php index 104c4dc18..37fe6043a 100644 --- a/pkg/sns/Tests/SnsConnectionFactoryTest.php +++ b/pkg/sns/Tests/SnsConnectionFactoryTest.php @@ -7,12 +7,14 @@ use Enqueue\Sns\SnsConnectionFactory; use Enqueue\Sns\SnsContext; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\ConnectionFactory; use PHPUnit\Framework\TestCase; class SnsConnectionFactoryTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementConnectionFactoryInterface() { diff --git a/pkg/sns/composer.json b/pkg/sns/composer.json index 7fb27bffc..cde4dab79 100644 --- a/pkg/sns/composer.json +++ b/pkg/sns/composer.json @@ -6,13 +6,13 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "queue-interop/queue-interop": "^0.8", "enqueue/dsn": "^0.10", "aws/aws-sdk-php": "~3.26" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "queue-interop/queue-spec": "^0.6" }, diff --git a/pkg/snsqs/Tests/SnsQsProducerTest.php b/pkg/snsqs/Tests/SnsQsProducerTest.php index dd82e4895..d0925d15e 100644 --- a/pkg/snsqs/Tests/SnsQsProducerTest.php +++ b/pkg/snsqs/Tests/SnsQsProducerTest.php @@ -18,10 +18,12 @@ use Interop\Queue\Producer; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; class SnsQsProducerTest extends TestCase { use ClassExtensionTrait; + use ProphecyTrait; public function testShouldImplementProducerInterface() { diff --git a/pkg/snsqs/composer.json b/pkg/snsqs/composer.json index 19398df34..ddf8d80cf 100644 --- a/pkg/snsqs/composer.json +++ b/pkg/snsqs/composer.json @@ -6,14 +6,14 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "queue-interop/queue-interop": "^0.8", "enqueue/dsn": "^0.10", "enqueue/sns": "^0.10", "enqueue/sqs": "^0.10" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "queue-interop/queue-spec": "^0.6" }, diff --git a/pkg/sqs/Tests/Functional/SqsCommonUseCasesTest.php b/pkg/sqs/Tests/Functional/SqsCommonUseCasesTest.php index ef8263fa6..7d06df229 100644 --- a/pkg/sqs/Tests/Functional/SqsCommonUseCasesTest.php +++ b/pkg/sqs/Tests/Functional/SqsCommonUseCasesTest.php @@ -27,7 +27,7 @@ class SqsCommonUseCasesTest extends TestCase */ private $queueName; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php b/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php index b9c1a2987..9c57dcbdc 100644 --- a/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php +++ b/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php @@ -18,15 +18,15 @@ class SqsConsumptionUseCasesTest extends TestCase { - use SqsExtension; use RetryTrait; + use SqsExtension; /** * @var SqsContext */ private $context; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php b/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php index 8225a4d34..83c656c0b 100644 --- a/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php +++ b/pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php @@ -4,6 +4,7 @@ use Enqueue\Sqs\SqsConnectionFactory; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use PHPUnit\Framework\TestCase; /** @@ -12,6 +13,7 @@ class SqsConnectionFactoryConfigTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testThrowNeitherArrayStringNorNullGivenAsConfig() { diff --git a/pkg/sqs/Tests/SqsConnectionFactoryTest.php b/pkg/sqs/Tests/SqsConnectionFactoryTest.php index 189cfe7f8..9eb072c77 100644 --- a/pkg/sqs/Tests/SqsConnectionFactoryTest.php +++ b/pkg/sqs/Tests/SqsConnectionFactoryTest.php @@ -7,12 +7,14 @@ use Enqueue\Sqs\SqsConnectionFactory; use Enqueue\Sqs\SqsContext; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\ConnectionFactory; use PHPUnit\Framework\TestCase; class SqsConnectionFactoryTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementConnectionFactoryInterface() { diff --git a/pkg/sqs/composer.json b/pkg/sqs/composer.json index cb21e9905..1ca52ab41 100644 --- a/pkg/sqs/composer.json +++ b/pkg/sqs/composer.json @@ -6,13 +6,13 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "queue-interop/queue-interop": "^0.8", "enqueue/dsn": "^0.10", "aws/aws-sdk-php": "~3.26" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "queue-interop/queue-spec": "^0.6" }, diff --git a/pkg/stomp/Tests/BufferedStompClientTest.php b/pkg/stomp/Tests/BufferedStompClientTest.php index 8732170e9..684edf397 100644 --- a/pkg/stomp/Tests/BufferedStompClientTest.php +++ b/pkg/stomp/Tests/BufferedStompClientTest.php @@ -4,6 +4,7 @@ use Enqueue\Stomp\BufferedStompClient; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Enqueue\Test\WriteAttributeTrait; use Stomp\Client; use Stomp\Network\Connection; @@ -12,6 +13,7 @@ class BufferedStompClientTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; use WriteAttributeTrait; public function testShouldExtendLibStompClient() diff --git a/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php b/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php index e2175b8af..e3f09737a 100644 --- a/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php +++ b/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php @@ -12,22 +12,22 @@ */ class StompCommonUseCasesTest extends \PHPUnit\Framework\TestCase { - use RabbitmqStompExtension; use RabbitManagementExtensionTrait; + use RabbitmqStompExtension; /** * @var StompContext */ private $stompContext; - public function setUp() + protected function setUp(): void { $this->stompContext = $this->buildStompContext(); $this->removeQueue('stomp.test'); } - public function tearDown(): void + protected function tearDown(): void { $this->stompContext->close(); } diff --git a/pkg/stomp/Tests/Functional/StompConnectionFactoryTest.php b/pkg/stomp/Tests/Functional/StompConnectionFactoryTest.php index 9029c17c1..6d4223616 100644 --- a/pkg/stomp/Tests/Functional/StompConnectionFactoryTest.php +++ b/pkg/stomp/Tests/Functional/StompConnectionFactoryTest.php @@ -4,6 +4,7 @@ use Enqueue\Stomp\StompConnectionFactory; use Enqueue\Test\RabbitmqStompExtension; +use Enqueue\Test\ReadAttributeTrait; use Stomp\Network\Observer\Exception\HeartbeatException; use Stomp\Network\Observer\HeartbeatEmitter; use Stomp\Network\Observer\ServerAliveObserver; @@ -14,6 +15,7 @@ class StompConnectionFactoryTest extends \PHPUnit\Framework\TestCase { use RabbitmqStompExtension; + use ReadAttributeTrait; public function testShouldNotCreateConnectionWithSendHeartbeat() { diff --git a/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php b/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php index 36357ca21..2025380fd 100644 --- a/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php +++ b/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php @@ -20,22 +20,22 @@ */ class StompConsumptionUseCasesTest extends \PHPUnit\Framework\TestCase { - use RabbitmqStompExtension; use RabbitManagementExtensionTrait; + use RabbitmqStompExtension; /** * @var StompContext */ private $stompContext; - public function setUp() + protected function setUp(): void { $this->stompContext = $this->buildStompContext(); $this->removeQueue('stomp.test'); } - public function tearDown(): void + protected function tearDown(): void { $this->stompContext->close(); } diff --git a/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php b/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php index 4c06d59b1..4cbb3af47 100644 --- a/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php +++ b/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php @@ -14,15 +14,15 @@ */ class StompRpcUseCasesTest extends \PHPUnit\Framework\TestCase { - use RabbitmqStompExtension; use RabbitManagementExtensionTrait; + use RabbitmqStompExtension; /** * @var StompContext */ private $stompContext; - public function setUp() + protected function setUp(): void { $this->stompContext = $this->buildStompContext(); @@ -30,7 +30,7 @@ public function setUp() $this->removeQueue('stomp.rpc.reply_test'); } - public function tearDown(): void + protected function tearDown(): void { $this->stompContext->close(); } diff --git a/pkg/stomp/Tests/StompConnectionFactoryConfigTest.php b/pkg/stomp/Tests/StompConnectionFactoryConfigTest.php index 50031e1e7..3899f3c76 100644 --- a/pkg/stomp/Tests/StompConnectionFactoryConfigTest.php +++ b/pkg/stomp/Tests/StompConnectionFactoryConfigTest.php @@ -4,6 +4,7 @@ use Enqueue\Stomp\StompConnectionFactory; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use PHPUnit\Framework\TestCase; /** @@ -12,6 +13,7 @@ class StompConnectionFactoryConfigTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testThrowNeitherArrayStringNorNullGivenAsConfig() { diff --git a/pkg/stomp/Tests/StompConnectionFactoryTest.php b/pkg/stomp/Tests/StompConnectionFactoryTest.php index 91986e6d0..1f39e3b20 100644 --- a/pkg/stomp/Tests/StompConnectionFactoryTest.php +++ b/pkg/stomp/Tests/StompConnectionFactoryTest.php @@ -5,11 +5,13 @@ use Enqueue\Stomp\StompConnectionFactory; use Enqueue\Stomp\StompContext; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\ConnectionFactory; class StompConnectionFactoryTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementConnectionFactoryInterface() { @@ -26,7 +28,7 @@ public function testShouldCreateLazyContext() $this->assertAttributeEquals(null, 'stomp', $context); $this->assertAttributeEquals(true, 'useExchangePrefix', $context); - $this->assertInternalType('callable', $this->readAttribute($context, 'stompFactory')); + self::assertIsCallable($this->readAttribute($context, 'stompFactory')); } public function testShouldCreateRabbitMQContext() diff --git a/pkg/stomp/Tests/StompConsumerTest.php b/pkg/stomp/Tests/StompConsumerTest.php index ff07ebde1..916166657 100644 --- a/pkg/stomp/Tests/StompConsumerTest.php +++ b/pkg/stomp/Tests/StompConsumerTest.php @@ -8,6 +8,7 @@ use Enqueue\Stomp\StompDestination; use Enqueue\Stomp\StompMessage; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use Interop\Queue\Consumer; use Interop\Queue\Exception\InvalidMessageException; use Interop\Queue\Message; @@ -17,6 +18,7 @@ class StompConsumerTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testShouldImplementMessageConsumerInterface() { @@ -521,8 +523,8 @@ public function testShouldGenerateUniqueSubscriptionIdPerConsumer() $fooConsumer = new StompConsumer($this->createStompClientMock(), $destination); $barConsumer = new StompConsumer($this->createStompClientMock(), $destination); - $this->assertAttributeNotEmpty('subscriptionId', $fooConsumer); - $this->assertAttributeNotEmpty('subscriptionId', $barConsumer); + $this->assertNotEmpty($this->readAttribute($fooConsumer, 'subscriptionId')); + $this->assertNotEmpty($this->readAttribute($barConsumer, 'subscriptionId')); $fooSubscriptionId = $this->readAttribute($fooConsumer, 'subscriptionId'); $barSubscriptionId = $this->readAttribute($barConsumer, 'subscriptionId'); diff --git a/pkg/stomp/composer.json b/pkg/stomp/composer.json index 30fe9a2fa..0509d34b0 100644 --- a/pkg/stomp/composer.json +++ b/pkg/stomp/composer.json @@ -6,7 +6,7 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "enqueue/dsn": "^0.10", "stomp-php/stomp-php": "^4", "queue-interop/queue-interop": "^0.8", @@ -15,7 +15,7 @@ "richardfullmer/rabbitmq-management-api": "^2.0" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "enqueue/null": "0.10.x-dev", "queue-interop/queue-spec": "^0.6" diff --git a/pkg/test/ReadAttributeTrait.php b/pkg/test/ReadAttributeTrait.php new file mode 100644 index 000000000..6938f257c --- /dev/null +++ b/pkg/test/ReadAttributeTrait.php @@ -0,0 +1,59 @@ +getClassAttribute($object, $attribute); + $refProperty->setAccessible(true); + $value = $refProperty->getValue($object); + $refProperty->setAccessible(false); + + return $value; + } + + private function getClassAttribute( + object $object, + string $attribute, + ?string $class = null + ): ReflectionProperty { + if (null === $class) { + $class = get_class($object); + } + + try { + return new ReflectionProperty($class, $attribute); + } catch (\ReflectionException $exception) { + $parentClass = get_parent_class($object); + if (false === $parentClass) { + throw $exception; + } + + return $this->getClassAttribute($object, $attribute, $parentClass); + } + } + + private function assertAttributeSame($expected, string $attribute, object $object): void + { + static::assertSame($expected, $this->readAttribute($object, $attribute)); + } + + private function assertAttributeEquals($expected, string $attribute, object $object): void + { + static::assertEquals($expected, $this->readAttribute($object, $attribute)); + } + + private function assertAttributeInstanceOf(string $expected, string $attribute, object $object): void + { + static::assertInstanceOf($expected, $this->readAttribute($object, $attribute)); + } + + private function assertAttributeCount(int $count, string $attribute, object $object): void + { + static::assertCount($count, $this->readAttribute($object, $attribute)); + } +} diff --git a/pkg/test/RetryTrait.php b/pkg/test/RetryTrait.php index 17c96ae89..1f1042c81 100644 --- a/pkg/test/RetryTrait.php +++ b/pkg/test/RetryTrait.php @@ -4,6 +4,7 @@ use PHPUnit\Framework\IncompleteTestError; use PHPUnit\Framework\SkippedTestError; +use PHPUnit\Util\Test; trait RetryTrait { @@ -46,7 +47,7 @@ public function runBare(): void */ private function getNumberOfRetries() { - $annotations = $this->getAnnotations(); + $annotations = Test::parseTestMethodAnnotations(static::class, $this->getName(false)); if (isset($annotations['method']['retry'][0])) { return $annotations['method']['retry'][0]; diff --git a/pkg/wamp/Tests/Functional/WampConsumerTest.php b/pkg/wamp/Tests/Functional/WampConsumerTest.php index f76cce71b..2494721d1 100644 --- a/pkg/wamp/Tests/Functional/WampConsumerTest.php +++ b/pkg/wamp/Tests/Functional/WampConsumerTest.php @@ -16,10 +16,10 @@ */ class WampConsumerTest extends TestCase { - use WampExtension; use RetryTrait; + use WampExtension; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { Logger::set(new NullLogger()); } diff --git a/pkg/wamp/Tests/Functional/WampSubscriptionConsumerTest.php b/pkg/wamp/Tests/Functional/WampSubscriptionConsumerTest.php index c28b3e0a5..e272f42ed 100644 --- a/pkg/wamp/Tests/Functional/WampSubscriptionConsumerTest.php +++ b/pkg/wamp/Tests/Functional/WampSubscriptionConsumerTest.php @@ -16,7 +16,7 @@ class WampSubscriptionConsumerTest extends TestCase { use WampExtension; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { Logger::set(new NullLogger()); } diff --git a/pkg/wamp/Tests/Spec/JsonSerializerTest.php b/pkg/wamp/Tests/Spec/JsonSerializerTest.php index 1e7e29413..eaa3c6bc2 100644 --- a/pkg/wamp/Tests/Spec/JsonSerializerTest.php +++ b/pkg/wamp/Tests/Spec/JsonSerializerTest.php @@ -43,7 +43,7 @@ public function testThrowIfFailedToEncodeMessageToJson() $resource = fopen(__FILE__, 'r'); //guard - $this->assertInternalType('resource', $resource); + $this->assertIsResource($resource); $message = new WampMessage('theBody', ['aProp' => $resource]); diff --git a/pkg/wamp/composer.json b/pkg/wamp/composer.json index c128997e5..f868b00eb 100644 --- a/pkg/wamp/composer.json +++ b/pkg/wamp/composer.json @@ -6,14 +6,14 @@ "homepage": "https://enqueue.forma-pro.com/", "license": "MIT", "require": { - "php": "^7.1.3", + "php": "^7.3", "queue-interop/queue-interop": "^0.8", "enqueue/dsn": "^0.10", "thruway/client": "^0.5.0", "thruway/pawl-transport": "^0.5.0" }, "require-dev": { - "phpunit/phpunit": "~7.5", + "phpunit/phpunit": "^9.5", "enqueue/test": "0.10.x-dev", "enqueue/null": "0.10.x-dev", "queue-interop/queue-spec": "^0.6"