From 6faffd46cc921e10fa879673163655ad56afbb36 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Fri, 22 Jan 2021 15:01:31 +0200 Subject: [PATCH 01/26] Add php 8, drop 7.1 and 7.2; up phpunit to 9.5 --- .github/workflows/ci.yml | 39 +++++++++++++++++++-------------------- composer.json | 4 ++-- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f5bbee0f..aa56948be 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 @@ -81,24 +81,6 @@ jobs: 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 @@ -153,6 +135,23 @@ jobs: functional_tests: false rdkafka_tests: true prepare_container: true + - php: 8.0 + symfony_version: 5.2.* + unit_tests: true + functional_tests: false + rdkafka_tests: false + prepare_container: false + - php: 8.0 + symfony_version: 5.2.* + unit_tests: false + functional_tests: true + rdkafka_tests: false + prepare_container: true + - php: 8.0 + symfony_version: 5.2.* + unit_tests: false + rdkafka_tests: true + prepare_container: true name: PHP ${{ matrix.php }} tests on Sf ${{ matrix.symfony_version }}, unit=${{ matrix.unit_tests }}, func=${{ matrix.functional_tests }}, rdkafka=${{ matrix.rdkafka_tests }} diff --git a/composer.json b/composer.json index 21cf655c1..c16aaa7d6 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "phpstan": "bin/phpstan analyse --memory-limit=512M -c phpstan.neon" }, "require": { - "php": "^7.1.3", + "php": "^7.3|^8.0", "ext-amqp": "^1.9.3", "ext-gearman": "^2.0", @@ -41,7 +41,7 @@ "datadog/php-datadogstatsd": "^1.3" }, "require-dev": { - "phpunit/phpunit": "^7.5", + "phpunit/phpunit": "^9.5", "phpstan/phpstan": "^0.12", "queue-interop/queue-spec": "^0.6", "symfony/browser-kit": "^3.4|^4", From 87652fe4b3dfc28ea393a1800495243533f9613c Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Fri, 22 Jan 2021 15:05:19 +0200 Subject: [PATCH 02/26] Disable fail-fast --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa56948be..9b2a50af8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,6 +78,7 @@ jobs: tests: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: php: ['7.4'] include: From 9567c78aaad1768c90365ded94f4464fb254fe89 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Fri, 22 Jan 2021 15:09:43 +0200 Subject: [PATCH 03/26] Fix test setUp method signatures --- pkg/enqueue-bundle/Tests/Functional/WebTestCase.php | 2 +- pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php | 2 +- pkg/job-queue/Tests/Functional/WebTestCase.php | 2 +- pkg/sqs/Tests/Functional/SqsCommonUseCasesTest.php | 2 +- pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) 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/Tests/DoctrineConnectionFactoryFactoryTest.php b/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php index 7282aa42e..81bb0091b 100644 --- a/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php +++ b/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php @@ -25,7 +25,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/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/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..f003825d1 100644 --- a/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php +++ b/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php @@ -26,7 +26,7 @@ class SqsConsumptionUseCasesTest extends TestCase */ private $context; - protected function setUp() + protected function setUp(): void { parent::setUp(); From 3731d696da04475e0ee4944a932b06ddd50a4c63 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Fri, 22 Jan 2021 15:12:15 +0200 Subject: [PATCH 04/26] Fix more setUp signatures --- docs/bundle/functional_testing.md | 2 +- pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php | 2 +- pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php | 2 +- pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php | 2 +- pkg/amqp-tools/Tests/SignalSocketHelperTest.php | 2 +- pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php | 2 +- pkg/dbal/Tests/Functional/DbalConsumerTest.php | 2 +- .../Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php | 2 +- .../DbalSendAndReceivePriorityMessagesFromQueueTest.php | 2 +- .../Tests/Functional/Events/AsyncListenerTest.php | 2 +- .../Tests/Functional/Events/AsyncProcessorTest.php | 2 +- .../Tests/Functional/Events/AsyncSubscriberTest.php | 2 +- pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php | 2 +- pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php | 2 +- pkg/fs/Tests/Functional/FsCommonUseCasesTest.php | 2 +- pkg/fs/Tests/Functional/FsConsumerTest.php | 2 +- pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php | 2 +- pkg/fs/Tests/Functional/FsProducerTest.php | 2 +- pkg/fs/Tests/Functional/FsRpcUseCasesTest.php | 2 +- pkg/gearman/Tests/SkipIfGearmanExtensionIsNotInstalledTrait.php | 2 +- .../Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php | 2 +- .../Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php | 2 +- pkg/mongodb/Tests/Functional/MongodbConsumerTest.php | 2 +- .../Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php | 2 +- .../Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php | 2 +- .../Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php | 2 +- pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php | 2 +- pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php | 2 +- pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php | 2 +- pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php | 2 +- pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php | 2 +- pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php | 2 +- pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php | 2 +- 33 files changed, 33 insertions(+), 33 deletions(-) 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/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php index ee73345e9..8e8ea2545 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php @@ -22,7 +22,7 @@ class AmqpCommonUseCasesTest extends TestCase */ private $amqpContext; - public function setUp() + public function setUp(): void { $this->amqpContext = $this->buildAmqpContext(); diff --git a/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php index 220554859..09d0a0e99 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php @@ -29,7 +29,7 @@ class AmqpConsumptionUseCasesTest extends TestCase */ private $amqpContext; - public function setUp() + public function setUp(): void { $this->amqpContext = $this->buildAmqpContext(); diff --git a/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php index 9e5dc4df3..5aafe96a4 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php @@ -23,7 +23,7 @@ class AmqpRpcUseCasesTest extends TestCase */ private $amqpContext; - public function setUp() + public function setUp(): void { $this->amqpContext = $this->buildAmqpContext(); diff --git a/pkg/amqp-tools/Tests/SignalSocketHelperTest.php b/pkg/amqp-tools/Tests/SignalSocketHelperTest.php index d869878c9..10903d47d 100644 --- a/pkg/amqp-tools/Tests/SignalSocketHelperTest.php +++ b/pkg/amqp-tools/Tests/SignalSocketHelperTest.php @@ -16,7 +16,7 @@ class SignalSocketHelperTest extends TestCase private $backupSigIntHandler; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php b/pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php index d05a9add5..f073ff515 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() + public function setUp(): void { (new Filesystem())->remove(__DIR__.'/queues/'); diff --git a/pkg/dbal/Tests/Functional/DbalConsumerTest.php b/pkg/dbal/Tests/Functional/DbalConsumerTest.php index 69b644ed4..709f1eafe 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() + public function setUp(): void { $this->context = $this->createDbalContext(); } diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php index 5a051a729..a26c58ef2 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() + public 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..44fba568f 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() + public function setUp(): void { parent::setUp(); diff --git a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php index 457a0ffcd..2dcdd251e 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() + public 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..8c8501ad4 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() + public 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..ce9f6456c 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() + public 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..c41a4d2db 100644 --- a/pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php @@ -11,7 +11,7 @@ */ class LazyProducerTest extends WebTestCase { - public function setUp() + public function setUp(): void { // do not call parent::setUp. // parent::setUp(); diff --git a/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php b/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php index 7c2936c0e..2144e42d7 100644 --- a/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php @@ -20,7 +20,7 @@ class UseCasesTest extends WebTestCase { const RECEIVE_TIMEOUT = 500; - public function setUp() + public function setUp(): void { // do not call parent::setUp. // parent::setUp(); diff --git a/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php b/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php index 1ae462731..9b169a03d 100644 --- a/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php +++ b/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php @@ -17,7 +17,7 @@ class FsCommonUseCasesTest extends \PHPUnit\Framework\TestCase */ private $fsContext; - public function setUp() + public function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); diff --git a/pkg/fs/Tests/Functional/FsConsumerTest.php b/pkg/fs/Tests/Functional/FsConsumerTest.php index 9dd7a0103..495989aad 100644 --- a/pkg/fs/Tests/Functional/FsConsumerTest.php +++ b/pkg/fs/Tests/Functional/FsConsumerTest.php @@ -15,7 +15,7 @@ class FsConsumerTest extends TestCase */ private $fsContext; - public function setUp() + public function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); diff --git a/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php b/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php index 98895a62d..28457afbb 100644 --- a/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php +++ b/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php @@ -25,7 +25,7 @@ class FsConsumptionUseCasesTest extends \PHPUnit\Framework\TestCase */ private $fsContext; - public function setUp() + public function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); diff --git a/pkg/fs/Tests/Functional/FsProducerTest.php b/pkg/fs/Tests/Functional/FsProducerTest.php index 6f7e4b4fa..ae95ddf68 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() + public function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); diff --git a/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php b/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php index 046a25f9c..01b8894f9 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() + public function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); 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..e34d9d1d5 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() + public function setUp(): void { $this->time = time(); } diff --git a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php index 469f9e997..b68b94480 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() + public function setUp(): void { $this->time = time(); } diff --git a/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php b/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php index 6e7f01e5c..ccefe0278 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() + public function setUp(): void { $this->context = $this->buildMongodbContext(); } diff --git a/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php index 9869d6e06..1f06aac5d 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() + public function setUp(): void { parent::setUp(); diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php index a6a5f925a..9a913e422 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() + public function setUp(): void { $this->time = time(); } diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php index 2bf9f9542..c3501f8aa 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() + public function setUp(): void { $this->time = time(); } diff --git a/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php b/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php index a63672da8..f54aadf91 100644 --- a/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php @@ -19,7 +19,7 @@ class PRedisCommonUseCasesTest extends TestCase */ private $context; - public function setUp() + public function setUp(): void { $this->context = $this->buildPRedisContext(); diff --git a/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php b/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php index f748020f1..e657b1830 100644 --- a/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php @@ -19,7 +19,7 @@ class PRedisConsumptionUseCasesTest extends TestCase */ private $context; - public function setUp() + public function setUp(): void { $this->context = $this->buildPRedisContext(); diff --git a/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php b/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php index 41b403565..ee4a1a786 100644 --- a/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php @@ -19,7 +19,7 @@ class PhpRedisCommonUseCasesTest extends TestCase */ private $context; - public function setUp() + public function setUp(): void { $this->context = $this->buildPhpRedisContext(); diff --git a/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php b/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php index d48e4bcb4..f255d4ea0 100644 --- a/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php @@ -19,7 +19,7 @@ class PhpRedisConsumptionUseCasesTest extends TestCase */ private $context; - public function setUp() + public function setUp(): void { $this->context = $this->buildPhpRedisContext(); diff --git a/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php b/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php index e2175b8af..1b56893b1 100644 --- a/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php +++ b/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php @@ -20,7 +20,7 @@ class StompCommonUseCasesTest extends \PHPUnit\Framework\TestCase */ private $stompContext; - public function setUp() + public function setUp(): void { $this->stompContext = $this->buildStompContext(); diff --git a/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php b/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php index 36357ca21..fd816ccad 100644 --- a/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php +++ b/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php @@ -28,7 +28,7 @@ class StompConsumptionUseCasesTest extends \PHPUnit\Framework\TestCase */ private $stompContext; - public function setUp() + public function setUp(): void { $this->stompContext = $this->buildStompContext(); diff --git a/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php b/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php index 4c06d59b1..657510c19 100644 --- a/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php +++ b/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php @@ -22,7 +22,7 @@ class StompRpcUseCasesTest extends \PHPUnit\Framework\TestCase */ private $stompContext; - public function setUp() + public function setUp(): void { $this->stompContext = $this->buildStompContext(); From 30687acb9f88dc36d7071408b0b91572fd130df9 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Fri, 22 Jan 2021 15:14:11 +0200 Subject: [PATCH 05/26] Fix setUpBeforeClass signatures --- pkg/wamp/Tests/Functional/WampConsumerTest.php | 2 +- pkg/wamp/Tests/Functional/WampSubscriptionConsumerTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/wamp/Tests/Functional/WampConsumerTest.php b/pkg/wamp/Tests/Functional/WampConsumerTest.php index f76cce71b..57dc32fd5 100644 --- a/pkg/wamp/Tests/Functional/WampConsumerTest.php +++ b/pkg/wamp/Tests/Functional/WampConsumerTest.php @@ -19,7 +19,7 @@ class WampConsumerTest extends TestCase use WampExtension; use RetryTrait; - 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()); } From 642c5ef86c389828664e1166d91e93f09361252b Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Sun, 24 Jan 2021 20:35:57 +0200 Subject: [PATCH 06/26] Fix phpunit compatibility - null queues; - array subset; - is array; - is callable; - read attribute; - add ext-pcntl. --- composer.json | 4 +- .../Tests/AmqpConnectionFactoryTest.php | 4 +- .../Tests/SignalSocketHelperTest.php | 5 ++- .../Tests/DbalConnectionFactoryConfigTest.php | 2 + .../DependencyInjection/ConfigurationTest.php | 45 ++++++++++--------- .../Profiler/MessageQueueCollectorTest.php | 3 +- .../DelayRedeliveredMessageExtensionTest.php | 9 ++-- .../ExclusiveCommandExtensionTest.php | 15 +++---- .../SetRouterPropertiesExtensionTest.php | 9 ++-- .../Tests/Client/Driver/AmqpDriverTest.php | 3 +- .../Tests/Client/Driver/GenericDriverTest.php | 3 +- .../Client/Driver/GenericDriverTestsTrait.php | 5 ++- .../Client/Driver/RabbitMqDriverTest.php | 3 +- pkg/enqueue/Tests/Client/ResourcesTest.php | 6 +-- .../Tests/Client/TraceableProducerTest.php | 29 ++++++------ .../Tests/Consumption/QueueConsumerTest.php | 5 ++- pkg/enqueue/Tests/ResourcesTest.php | 12 ++--- .../BuildClientExtensionsPassTest.php | 14 +++--- .../BuildCommandSubscriberRoutesPassTest.php | 18 ++++---- .../BuildConsumptionExtensionsPassTest.php | 14 +++--- .../BuildProcessorRoutesPassTest.php | 14 +++--- .../BuildTopicSubscriberRoutesPassTest.php | 16 +++---- .../Client/FlushSpoolProducerListenerTest.php | 4 +- .../BuildConsumptionExtensionsPassTest.php | 14 +++--- .../Tests/RedisConnectionFactoryTest.php | 4 +- pkg/sns/Tests/SnsConnectionFactoryTest.php | 2 + pkg/sqs/Tests/SqsConnectionFactoryTest.php | 2 + pkg/stomp/Tests/BufferedStompClientTest.php | 2 + .../Tests/StompConnectionFactoryTest.php | 4 +- pkg/stomp/Tests/StompConsumerTest.php | 2 + pkg/test/ReadAttributeTrait.php | 36 +++++++++++++++ 31 files changed, 186 insertions(+), 122 deletions(-) create mode 100644 pkg/test/ReadAttributeTrait.php diff --git a/composer.json b/composer.json index c16aaa7d6..c13225ac7 100644 --- a/composer.json +++ b/composer.json @@ -41,6 +41,7 @@ "datadog/php-datadogstatsd": "^1.3" }, "require-dev": { + "ext-pcntl": "*", "phpunit/phpunit": "^9.5", "phpstan/phpstan": "^0.12", "queue-interop/queue-spec": "^0.6", @@ -60,7 +61,8 @@ "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" }, "autoload": { "psr-4": { 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-tools/Tests/SignalSocketHelperTest.php b/pkg/amqp-tools/Tests/SignalSocketHelperTest.php index 10903d47d..61e0d2ce6 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 */ @@ -76,7 +79,7 @@ public function testShouldRegisterHandlerOnBeforeSocketAndBackupCurrentOne() $handlers = $this->readAttribute($this->signalHelper, 'handlers'); - $this->assertInternalType('array', $handlers); + self::assertIsArray($handlers); $this->assertArrayHasKey(SIGTERM, $handlers); $this->assertSame($handler, $handlers[SIGTERM]); } 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/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/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php index 050b4f2f5..61a307a5a 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php @@ -15,6 +15,7 @@ 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; @@ -169,17 +170,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/ExclusiveCommandExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php index 878778b30..1e58d14f8 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..3234c45f0 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; @@ -336,7 +337,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..6b61465c3 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; @@ -115,7 +116,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/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/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/QueueConsumerTest.php b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php index 9e25ab931..949c9ca6f 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); 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/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/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/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/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/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/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/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/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..25a873430 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() { diff --git a/pkg/test/ReadAttributeTrait.php b/pkg/test/ReadAttributeTrait.php new file mode 100644 index 000000000..73209105e --- /dev/null +++ b/pkg/test/ReadAttributeTrait.php @@ -0,0 +1,36 @@ +setAccessible(true); + $value = $refProperty->getValue($object); + $refProperty->setAccessible(false); + + return $value; + } + + 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)); + } +} From d38fc1d2f58fbbec9721f12f910431c55b87d619 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Sun, 24 Jan 2021 20:36:17 +0200 Subject: [PATCH 07/26] Remove php 8 from the build matrix for now --- .github/workflows/ci.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b2a50af8..48cb4f16c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -136,23 +136,6 @@ jobs: functional_tests: false rdkafka_tests: true prepare_container: true - - php: 8.0 - symfony_version: 5.2.* - unit_tests: true - functional_tests: false - rdkafka_tests: false - prepare_container: false - - php: 8.0 - symfony_version: 5.2.* - unit_tests: false - functional_tests: true - rdkafka_tests: false - prepare_container: true - - php: 8.0 - symfony_version: 5.2.* - unit_tests: false - rdkafka_tests: true - prepare_container: true name: PHP ${{ matrix.php }} tests on Sf ${{ matrix.symfony_version }}, unit=${{ matrix.unit_tests }}, func=${{ matrix.functional_tests }}, rdkafka=${{ matrix.rdkafka_tests }} From da22b9010ffd14c1a2985f2f960e89335e9b0436 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Sun, 24 Jan 2021 20:45:22 +0200 Subject: [PATCH 08/26] Fix more attributes; nullable params --- pkg/amqp-ext/Tests/AmqpContextTest.php | 2 ++ pkg/async-command/Tests/RunCommandProcessorTest.php | 3 +++ pkg/async-event-dispatcher/Tests/AsyncListenerTest.php | 2 ++ .../Tests/ContainerAwareRegistryTest.php | 2 ++ pkg/dbal/Tests/DbalSubscriptionConsumerTest.php | 3 +++ pkg/dbal/Tests/ManagerRegistryConnectionFactoryTest.php | 2 ++ .../ExclusiveCommandExtensionTest.php | 2 +- pkg/enqueue/Tests/Client/RouterProcessorTest.php | 8 +++++--- .../Consumption/FallbackSubscriptionConsumerTest.php | 3 +++ pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php | 4 ++-- pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php | 2 +- .../Tests/Symfony/Client/SimpleConsumeCommandTest.php | 4 ++-- pkg/fs/Tests/FsConnectionFactoryTest.php | 2 ++ pkg/fs/Tests/FsContextTest.php | 2 ++ pkg/mongodb/Tests/MongodbSubscriptionConsumerTest.php | 3 +++ pkg/redis/Tests/RedisConnectionFactoryConfigTest.php | 2 ++ pkg/redis/Tests/RedisSubscriptionConsumerTest.php | 3 +++ 17 files changed, 40 insertions(+), 9 deletions(-) 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/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-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/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/ManagerRegistryConnectionFactoryTest.php b/pkg/dbal/Tests/ManagerRegistryConnectionFactoryTest.php index 3adefff01..77cdbe1f0 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() { diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php index 1e58d14f8..dc2c00c96 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php @@ -252,7 +252,7 @@ private function createDriverStub(?RouteCollection $routeCollection = null): Dri $driver ->expects($this->any()) ->method('getRouteCollection') - ->willReturn($routeCollection ?? new RouteCollection()) + ->willReturn($routeCollection ?? new RouteCollection([])) ; return $driver; 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/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/Symfony/Client/ConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php index be7de228e..706aee07c 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 diff --git a/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php index d9935bdf4..de29e4c04 100644 --- a/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php @@ -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/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/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..a99276bbe 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() { 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/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/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); From 69383000b4d042a24ee471d51233b251ae6b9736 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Sun, 24 Jan 2021 20:58:12 +0200 Subject: [PATCH 09/26] Fix more attributes; void returns; assert string contains; resource; --- pkg/dbal/Tests/DbalConnectionFactoryTest.php | 2 ++ pkg/dbal/Tests/DbalContextTest.php | 2 ++ .../Tests/Functional/RoutesCommandTest.php | 20 +++++++++---------- .../Tests/Consumption/QueueConsumerTest.php | 4 ---- .../Symfony/Client/RoutesCommandTest.php | 2 +- .../Symfony/Client/SetupBrokerCommandTest.php | 4 ++-- .../Client/SimpleSetupBrokerCommandTest.php | 2 +- pkg/enqueue/Tests/Util/UUIDTest.php | 2 +- .../Tests/FsConnectionFactoryConfigTest.php | 2 ++ .../GearmanConnectionFactoryConfigTest.php | 2 ++ .../Tests/GpsConnectionFactoryConfigTest.php | 2 ++ .../Tests/MongodbConnectionFactoryTest.php | 2 ++ pkg/mongodb/Tests/MongodbContextTest.php | 2 ++ .../PheanstalkConnectionFactoryConfigTest.php | 2 ++ pkg/rdkafka/Tests/JsonSerializerTest.php | 2 +- .../Tests/RdKafkaConnectionFactoryTest.php | 3 +++ pkg/redis/Tests/Spec/JsonSerializerTest.php | 2 +- .../Tests/SnsConnectionFactoryConfigTest.php | 2 ++ .../Tests/SqsConnectionFactoryConfigTest.php | 2 ++ .../Functional/StompConnectionFactoryTest.php | 2 ++ .../StompConnectionFactoryConfigTest.php | 2 ++ pkg/wamp/Tests/Spec/JsonSerializerTest.php | 2 +- 22 files changed, 45 insertions(+), 22 deletions(-) diff --git a/pkg/dbal/Tests/DbalConnectionFactoryTest.php b/pkg/dbal/Tests/DbalConnectionFactoryTest.php index b4a6857f6..6e633cec0 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() { 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/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/Tests/Consumption/QueueConsumerTest.php b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php index 949c9ca6f..5023beacd 100644 --- a/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php +++ b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php @@ -206,7 +206,6 @@ public function testShouldUseContextSubscriptionConsumerIfSupport() $contextSubscriptionConsumer ->expects($this->once()) ->method('consume') - ->willReturn(null) ; $fallbackSubscriptionConsumer = $this->createSubscriptionConsumerMock(); @@ -254,7 +253,6 @@ public function testShouldUseFallbackSubscriptionConsumerIfNotSupported() $fallbackSubscriptionConsumer ->expects($this->once()) ->method('consume') - ->willReturn(null) ; $contextMock = $this->createContextWithoutSubscriptionConsumerMock(); @@ -291,7 +289,6 @@ public function testShouldSubscribeToGivenQueueWithExpectedTimeout() ->expects($this->once()) ->method('consume') ->with(12345) - ->willReturn(null) ; $contextMock = $this->createContextWithoutSubscriptionConsumerMock(); @@ -322,7 +319,6 @@ public function testShouldSubscribeToGivenQueueAndQuitAfterFifthConsumeCycle() $subscriptionConsumerMock ->expects($this->exactly(5)) ->method('consume') - ->willReturn(null) ; $contextMock = $this->createContextWithoutSubscriptionConsumerMock(); diff --git a/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php index de29e4c04..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() 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/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/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/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/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/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/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/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/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/RdKafkaConnectionFactoryTest.php b/pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php index 47fdc1715..29501965b 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); 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/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/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/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/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/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]); From 689c70ae847361f7bf15fbd228b1a99bc27064bd Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Sun, 24 Jan 2021 21:07:30 +0200 Subject: [PATCH 10/26] Fix more attributes and nullables --- pkg/amqp-bunny/Tests/AmqpConnectionFactoryTest.php | 2 ++ pkg/amqp-lib/Tests/AmqpConnectionFactoryTest.php | 2 ++ pkg/dbal/Tests/DbalConnectionFactoryTest.php | 2 +- pkg/dbal/Tests/ManagerRegistryConnectionFactoryTest.php | 2 +- pkg/enqueue/Tests/Consumption/QueueConsumerTest.php | 3 +++ pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php | 3 +++ pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php | 3 +++ pkg/fs/Tests/LegacyFilesystemLockTest.php | 2 ++ pkg/redis/Tests/RedisProducerTest.php | 2 +- pkg/stomp/Tests/StompConsumerTest.php | 4 ++-- 10 files changed, 20 insertions(+), 5 deletions(-) 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-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/dbal/Tests/DbalConnectionFactoryTest.php b/pkg/dbal/Tests/DbalConnectionFactoryTest.php index 6e633cec0..105466c26 100644 --- a/pkg/dbal/Tests/DbalConnectionFactoryTest.php +++ b/pkg/dbal/Tests/DbalConnectionFactoryTest.php @@ -28,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/ManagerRegistryConnectionFactoryTest.php b/pkg/dbal/Tests/ManagerRegistryConnectionFactoryTest.php index 77cdbe1f0..83135c2ed 100644 --- a/pkg/dbal/Tests/ManagerRegistryConnectionFactoryTest.php +++ b/pkg/dbal/Tests/ManagerRegistryConnectionFactoryTest.php @@ -73,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/enqueue/Tests/Consumption/QueueConsumerTest.php b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php index 5023beacd..a087926ad 100644 --- a/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php +++ b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php @@ -1537,6 +1537,9 @@ private function createExtension() */ private function createConsumerStub($queue = null): Consumer { + if ($queue === null) { + $queue = 'queue'; + } if (is_string($queue)) { $queue = new NullQueue($queue); } diff --git a/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php index 706aee07c..fcc099538 100644 --- a/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php @@ -677,6 +677,9 @@ private function createExtension() */ private function createConsumerStub($queue = null): Consumer { + if ($queue === null) { + $queue = 'queue'; + } if (is_string($queue)) { $queue = new NullQueue($queue); } diff --git a/pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php index c2f2257c0..cfcfd520c 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 ($queue === null) { + $queue = 'queue'; + } if (is_string($queue)) { $queue = new NullQueue($queue); } 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/redis/Tests/RedisProducerTest.php b/pkg/redis/Tests/RedisProducerTest.php index fa7260311..ce3c77ad0 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; }) ; diff --git a/pkg/stomp/Tests/StompConsumerTest.php b/pkg/stomp/Tests/StompConsumerTest.php index 25a873430..916166657 100644 --- a/pkg/stomp/Tests/StompConsumerTest.php +++ b/pkg/stomp/Tests/StompConsumerTest.php @@ -523,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'); From 3eb9ba30842a337d74f98f3037aba729ca1d384e Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Sun, 24 Jan 2021 21:09:06 +0200 Subject: [PATCH 11/26] Fix annotations --- pkg/test/RetryTrait.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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]; From 2b33202713a6de4163984a6e06afc2be9b710199 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Sun, 24 Jan 2021 21:11:36 +0200 Subject: [PATCH 12/26] Fix more attributes --- pkg/rdkafka/Tests/RdKafkaConnectionFactoryConfigTest.php | 4 +++- pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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 29501965b..8af3e8501 100644 --- a/pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php +++ b/pkg/rdkafka/Tests/RdKafkaConnectionFactoryTest.php @@ -41,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']); @@ -58,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']); From 63aaebff90e1a703e93f6511cb30d22b8b1c20d8 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Sun, 24 Jan 2021 21:22:57 +0200 Subject: [PATCH 13/26] Fix datetime equal tests --- .../CalculateRootJobStatusServiceTest.php | 10 ++++- pkg/job-queue/Tests/JobProcessorTest.php | 45 +++++++++++++++---- 2 files changed, 44 insertions(+), 11 deletions(-) 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/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() + ); } /** From 140bc0104221a0c488f02b22c5c366b7038a17cd Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Thu, 21 Jan 2021 16:33:24 +0200 Subject: [PATCH 14/26] =?UTF-8?q?Fix=20at()=20warnings=20for=20non-logger?= =?UTF-8?q?=20mocks=20=E2=80=94=20don't=20test=20for=20method=20call=20ord?= =?UTF-8?q?er?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/amqp-lib/Tests/AmqpContextTest.php | 4 +-- .../Tests/Client/Driver/AmqpDriverTest.php | 23 +++++++-------- .../Tests/Client/Driver/FsDriverTest.php | 8 +++--- .../Tests/Client/Driver/GpsDriverTest.php | 12 ++++---- .../Client/Driver/RabbitMqStompDriverTest.php | 16 +++++------ .../Tests/Client/Driver/RdKafkaDriverTest.php | 6 ++-- .../Tests/Client/Driver/SqsDriverTest.php | 8 +++--- .../Tests/Client/ProducerSendCommandTest.php | 8 +++--- .../Tests/Client/ProducerSendEventTest.php | 12 ++++---- .../Tests/Client/SpoolProducerTest.php | 12 ++++---- .../RouteRecipientListProcessorTest.php | 4 +-- .../Symfony/Client/ConsumeCommandTest.php | 28 +++++++++---------- .../ConfigurableConsumeCommandTest.php | 12 ++++---- .../Tests/Doctrine/JobStorageTest.php | 8 +++--- pkg/redis/Tests/RedisConsumerTest.php | 6 ++-- pkg/redis/Tests/RedisContextTest.php | 12 ++++---- pkg/stomp/Tests/BufferedStompClientTest.php | 8 +++--- 17 files changed, 94 insertions(+), 93 deletions(-) diff --git a/pkg/amqp-lib/Tests/AmqpContextTest.php b/pkg/amqp-lib/Tests/AmqpContextTest.php index 4cfde3c14..ea3bc43c3 100644 --- a/pkg/amqp-lib/Tests/AmqpContextTest.php +++ b/pkg/amqp-lib/Tests/AmqpContextTest.php @@ -322,12 +322,12 @@ public function testShouldSetQos() { $channel = $this->createChannelMock(); $channel - ->expects($this->at(0)) + ->expects(self::once()) ->method('basic_qos') ->with($this->identicalTo(0), $this->identicalTo(1), $this->isFalse()) ; $channel - ->expects($this->at(1)) + ->expects(self::once()) ->method('basic_qos') ->with($this->identicalTo(123), $this->identicalTo(456), $this->isTrue()) ; diff --git a/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php b/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php index 3234c45f0..08b22c713 100644 --- a/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php @@ -22,6 +22,7 @@ use Interop\Queue\Message as InteropMessage; use Interop\Queue\Producer as InteropProducer; use Interop\Queue\Queue as InteropQueue; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class AmqpDriverTest extends TestCase @@ -190,54 +191,54 @@ public function testShouldSetupBroker() $context = $this->createContextMock(); // setup router $context - ->expects($this->at(0)) + ->expects(self::once()) ->method('createTopic') ->willReturn($routerTopic) ; $context - ->expects($this->at(1)) + ->expects(self::once()) ->method('declareTopic') ->with($this->identicalTo($routerTopic)) ; $context - ->expects($this->at(2)) + ->expects(self::once()) ->method('createQueue') ->willReturn($routerQueue) ; $context - ->expects($this->at(3)) + ->expects(self::once()) ->method('declareQueue') ->with($this->identicalTo($routerQueue)) ; $context - ->expects($this->at(4)) + ->expects(self::once()) ->method('bind') ->with($this->isInstanceOf(AmqpBind::class)) ; // setup processor with default queue $context - ->expects($this->at(5)) + ->expects(self::once()) ->method('createQueue') ->with($this->getDefaultQueueTransportName()) ->willReturn($processorWithDefaultQueue) ; $context - ->expects($this->at(6)) + ->expects(self::once()) ->method('declareQueue') ->with($this->identicalTo($processorWithDefaultQueue)) ; $context - ->expects($this->at(7)) + ->expects(self::once()) ->method('createQueue') ->with($this->getCustomQueueTransportName()) ->willReturn($processorWithCustomQueue) ; $context - ->expects($this->at(8)) + ->expects(self::once()) ->method('declareQueue') ->with($this->identicalTo($processorWithCustomQueue)) ; @@ -290,7 +291,7 @@ protected function createDriver(...$args): DriverInterface } /** - * @return AmqpContext + * @return AmqpContext|MockObject */ protected function createContextMock(): Context { @@ -298,7 +299,7 @@ protected function createContextMock(): Context } /** - * @return AmqpProducer + * @return AmqpProducer|MockObject */ protected function createProducerMock(): InteropProducer { diff --git a/pkg/enqueue/Tests/Client/Driver/FsDriverTest.php b/pkg/enqueue/Tests/Client/Driver/FsDriverTest.php index f1cd02f9b..a235b64b8 100644 --- a/pkg/enqueue/Tests/Client/Driver/FsDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/FsDriverTest.php @@ -44,23 +44,23 @@ public function testShouldSetupBroker() $context = $this->createContextMock(); // setup router $context - ->expects($this->at(0)) + ->expects(self::once()) ->method('createQueue') ->willReturn($routerQueue) ; $context - ->expects($this->at(1)) + ->expects(self::once()) ->method('declareDestination') ->with($this->identicalTo($routerQueue)) ; // setup processor queue $context - ->expects($this->at(2)) + ->expects(self::once()) ->method('createQueue') ->willReturn($processorQueue) ; $context - ->expects($this->at(3)) + ->expects(self::once()) ->method('declareDestination') ->with($this->identicalTo($processorQueue)) ; diff --git a/pkg/enqueue/Tests/Client/Driver/GpsDriverTest.php b/pkg/enqueue/Tests/Client/Driver/GpsDriverTest.php index c0cac0458..37a97be66 100644 --- a/pkg/enqueue/Tests/Client/Driver/GpsDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/GpsDriverTest.php @@ -46,35 +46,35 @@ public function testShouldSetupBroker() $context = $this->createContextMock(); // setup router $context - ->expects($this->at(0)) + ->expects(self::once()) ->method('createTopic') ->willReturn($routerTopic) ; $context - ->expects($this->at(1)) + ->expects(self::once()) ->method('createQueue') ->willReturn($routerQueue) ; $context - ->expects($this->at(2)) + ->expects(self::once()) ->method('subscribe') ->with($this->identicalTo($routerTopic), $this->identicalTo($routerQueue)) ; $context - ->expects($this->at(3)) + ->expects(self::once()) ->method('createQueue') ->with($this->getDefaultQueueTransportName()) ->willReturn($processorQueue) ; // setup processor queue $context - ->expects($this->at(4)) + ->expects(self::once()) ->method('createTopic') ->with($this->getDefaultQueueTransportName()) ->willReturn($processorTopic) ; $context - ->expects($this->at(5)) + ->expects(self::once()) ->method('subscribe') ->with($this->identicalTo($processorTopic), $this->identicalTo($processorQueue)) ; diff --git a/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php b/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php index 4152f93cc..f59376be4 100644 --- a/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php @@ -196,12 +196,12 @@ public function shouldSendMessageToDelayExchangeIfDelaySet() $producer = $this->createProducerMock(); $producer - ->expects($this->at(0)) + ->expects(self::once()) ->method('setDeliveryDelay') ->with(10000) ; $producer - ->expects($this->at(1)) + ->expects(self::once()) ->method('setDeliveryDelay') ->with(null) ; @@ -299,7 +299,7 @@ public function testShouldSetupBroker() $managementClient = $this->createManagementClientMock(); $managementClient - ->expects($this->at(0)) + ->expects(self::once()) ->method('declareExchange') ->with('aprefix.router', [ 'type' => 'fanout', @@ -308,7 +308,7 @@ public function testShouldSetupBroker() ]) ; $managementClient - ->expects($this->at(1)) + ->expects(self::once()) ->method('declareQueue') ->with('aprefix.default', [ 'durable' => true, @@ -319,12 +319,12 @@ public function testShouldSetupBroker() ]) ; $managementClient - ->expects($this->at(2)) + ->expects(self::once()) ->method('bind') ->with('aprefix.router', 'aprefix.default', 'aprefix.default') ; $managementClient - ->expects($this->at(3)) + ->expects(self::once()) ->method('declareQueue') ->with('aprefix.default', [ 'durable' => true, @@ -399,7 +399,7 @@ public function testSetupBrokerShouldCreateDelayExchangeIfEnabled() $managementClient = $this->createManagementClientMock(); $managementClient - ->expects($this->at(4)) + ->expects(self::once()) ->method('declareExchange') ->with('aprefix.default.delayed', [ 'type' => 'x-delayed-message', @@ -411,7 +411,7 @@ public function testSetupBrokerShouldCreateDelayExchangeIfEnabled() ]) ; $managementClient - ->expects($this->at(5)) + ->expects(self::once()) ->method('bind') ->with('aprefix.default.delayed', 'aprefix.default', 'aprefix.default') ; diff --git a/pkg/enqueue/Tests/Client/Driver/RdKafkaDriverTest.php b/pkg/enqueue/Tests/Client/Driver/RdKafkaDriverTest.php index 659590ba3..16d1da929 100644 --- a/pkg/enqueue/Tests/Client/Driver/RdKafkaDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/RdKafkaDriverTest.php @@ -47,17 +47,17 @@ public function testShouldSetupBroker() $context = $this->createContextMock(); $context - ->expects($this->at(0)) + ->expects(self::once()) ->method('createQueue') ->willReturn($routerTopic) ; $context - ->expects($this->at(1)) + ->expects(self::once()) ->method('createQueue') ->willReturn($routerQueue) ; $context - ->expects($this->at(2)) + ->expects(self::once()) ->method('createQueue') ->willReturn($processorTopic) ; diff --git a/pkg/enqueue/Tests/Client/Driver/SqsDriverTest.php b/pkg/enqueue/Tests/Client/Driver/SqsDriverTest.php index 2e3005e6a..fb4af5303 100644 --- a/pkg/enqueue/Tests/Client/Driver/SqsDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/SqsDriverTest.php @@ -42,25 +42,25 @@ public function testShouldSetupBroker() $context = $this->createContextMock(); // setup router $context - ->expects($this->at(0)) + ->expects(self::once()) ->method('createQueue') ->with('aprefix_dot_default') ->willReturn($routerQueue) ; $context - ->expects($this->at(1)) + ->expects(self::once()) ->method('declareQueue') ->with($this->identicalTo($routerQueue)) ; // setup processor queue $context - ->expects($this->at(2)) + ->expects(self::once()) ->method('createQueue') ->with('aprefix_dot_default') ->willReturn($processorQueue) ; $context - ->expects($this->at(3)) + ->expects(self::once()) ->method('declareQueue') ->with($this->identicalTo($processorQueue)) ; diff --git a/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php b/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php index 8ac0704ca..9532ba368 100644 --- a/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php +++ b/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php @@ -370,7 +370,7 @@ public function testShouldCallPreSendCommandExtensionMethodWhenSendToBus() $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects($this->at(0)) + ->expects(self::once()) ->method('onPreSendCommand') ->willReturnCallback(function (PreSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -408,7 +408,7 @@ public function testShouldCallPreSendCommandExtensionMethodWhenSendToApplication $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects($this->at(0)) + ->expects(self::once()) ->method('onPreSendCommand') ->willReturnCallback(function (PreSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -446,7 +446,7 @@ public function testShouldCallPreDriverSendExtensionMethod() $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects($this->at(0)) + ->expects(self::once()) ->method('onDriverPreSend') ->willReturnCallback(function (DriverPreSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -478,7 +478,7 @@ public function testShouldCallPostSendExtensionMethod() $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects($this->at(0)) + ->expects(self::once()) ->method('onDriverPreSend') ->willReturnCallback(function (PostSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); diff --git a/pkg/enqueue/Tests/Client/ProducerSendEventTest.php b/pkg/enqueue/Tests/Client/ProducerSendEventTest.php index 29a14b7d4..b482492b4 100644 --- a/pkg/enqueue/Tests/Client/ProducerSendEventTest.php +++ b/pkg/enqueue/Tests/Client/ProducerSendEventTest.php @@ -326,7 +326,7 @@ public function testShouldCallPreSendEventExtensionMethodWhenSendToBus() $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects($this->at(0)) + ->expects(self::once()) ->method('onPreSendEvent') ->willReturnCallback(function (PreSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -364,7 +364,7 @@ public function testShouldCallPreSendEventExtensionMethodWhenSendToApplicationRo $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects($this->at(0)) + ->expects(self::once()) ->method('onPreSendEvent') ->willReturnCallback(function (PreSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -402,7 +402,7 @@ public function testShouldCallPreDriverSendExtensionMethodWhenSendToMessageBus() $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects($this->at(0)) + ->expects(self::once()) ->method('onDriverPreSend') ->willReturnCallback(function (DriverPreSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -434,7 +434,7 @@ public function testShouldCallPreDriverSendExtensionMethodWhenSendToApplicationR $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects($this->at(0)) + ->expects(self::once()) ->method('onDriverPreSend') ->willReturnCallback(function (DriverPreSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -466,7 +466,7 @@ public function testShouldCallPostSendExtensionMethodWhenSendToMessageBus() $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects($this->at(0)) + ->expects(self::once()) ->method('onPostSend') ->willReturnCallback(function (PostSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -498,7 +498,7 @@ public function testShouldCallPostSendExtensionMethodWhenSendToApplicationRouter $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects($this->at(0)) + ->expects(self::once()) ->method('onDriverPreSend') ->willReturnCallback(function (PostSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); diff --git a/pkg/enqueue/Tests/Client/SpoolProducerTest.php b/pkg/enqueue/Tests/Client/SpoolProducerTest.php index 024fd6da2..df9e728ed 100644 --- a/pkg/enqueue/Tests/Client/SpoolProducerTest.php +++ b/pkg/enqueue/Tests/Client/SpoolProducerTest.php @@ -68,17 +68,17 @@ public function testShouldSendQueuedEventMessagesOnFlush() $realProducer = $this->createProducerMock(); $realProducer - ->expects($this->at(0)) + ->expects(self::once()) ->method('sendEvent') ->with('foo_topic', 'first') ; $realProducer - ->expects($this->at(1)) + ->expects(self::once()) ->method('sendEvent') ->with('bar_topic', ['second']) ; $realProducer - ->expects($this->at(2)) + ->expects(self::once()) ->method('sendEvent') ->with('baz_topic', $this->identicalTo($message)) ; @@ -103,17 +103,17 @@ public function testShouldSendQueuedCommandMessagesOnFlush() $realProducer = $this->createProducerMock(); $realProducer - ->expects($this->at(0)) + ->expects(self::once()) ->method('sendCommand') ->with('foo_command', 'first') ; $realProducer - ->expects($this->at(1)) + ->expects(self::once()) ->method('sendCommand') ->with('bar_command', ['second']) ; $realProducer - ->expects($this->at(2)) + ->expects(self::once()) ->method('sendCommand') ->with('baz_command', $this->identicalTo($message)) ; diff --git a/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php b/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php index 8a2e089f7..dfc820656 100644 --- a/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php +++ b/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php @@ -45,12 +45,12 @@ public function testShouldProduceRecipientsMessagesAndAckOriginalMessage() $producerMock = $this->createProducerMock(); $producerMock - ->expects($this->at(0)) + ->expects(self::once()) ->method('send') ->with($this->identicalTo($fooRecipient->getDestination()), $this->identicalTo($fooRecipient->getMessage())) ; $producerMock - ->expects($this->at(1)) + ->expects(self::once()) ->method('send') ->with($this->identicalTo($barRecipient->getDestination()), $this->identicalTo($barRecipient->getMessage())) ; diff --git a/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php index fcc099538..4f1dfe2fa 100644 --- a/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php @@ -269,13 +269,13 @@ public function testShouldBindCustomExecuteConsumptionAndUseCustomClientDestinat $driver = $this->createDriverStub($routeCollection); $driver - ->expects($this->at(3)) + ->expects(self::once()) ->method('createQueue') ->with('default', true) ->willReturn($defaultQueue) ; $driver - ->expects($this->at(4)) + ->expects(self::once()) ->method('createQueue') ->with('custom', true) ->willReturn($customQueue) @@ -283,17 +283,17 @@ public function testShouldBindCustomExecuteConsumptionAndUseCustomClientDestinat $consumer = $this->createQueueConsumerMock(); $consumer - ->expects($this->at(0)) + ->expects(self::once()) ->method('bind') ->with($this->identicalTo($defaultQueue), $this->identicalTo($processor)) ; $consumer - ->expects($this->at(1)) + ->expects(self::once()) ->method('bind') ->with($this->identicalTo($customQueue), $this->identicalTo($processor)) ; $consumer - ->expects($this->at(2)) + ->expects(self::once()) ->method('consume') ->with($this->isInstanceOf(ChainExtension::class)) ; @@ -408,13 +408,13 @@ public function testShouldBindQueuesOnlyOnce() $driver = $this->createDriverStub($routeCollection); $driver - ->expects($this->at(3)) + ->expects(self::once()) ->method('createQueue') ->with('default', true) ->willReturn($defaultQueue) ; $driver - ->expects($this->at(4)) + ->expects(self::once()) ->method('createQueue', true) ->with('custom') ->willReturn($customQueue) @@ -422,17 +422,17 @@ public function testShouldBindQueuesOnlyOnce() $consumer = $this->createQueueConsumerMock(); $consumer - ->expects($this->at(0)) + ->expects(self::once()) ->method('bind') ->with($this->identicalTo($defaultQueue), $this->identicalTo($processor)) ; $consumer - ->expects($this->at(1)) + ->expects(self::once()) ->method('bind') ->with($this->identicalTo($customQueue), $this->identicalTo($processor)) ; $consumer - ->expects($this->at(2)) + ->expects(self::once()) ->method('consume') ->with($this->isInstanceOf(ChainExtension::class)) ; @@ -473,7 +473,7 @@ public function testShouldNotBindExternalRoutes() ->with($this->identicalTo($defaultQueue), $this->identicalTo($processor)) ; $consumer - ->expects($this->at(1)) + ->expects(self::once()) ->method('consume') ->with($this->isInstanceOf(ChainExtension::class)) ; @@ -513,19 +513,19 @@ public function testShouldSkipQueueConsumptionAndUseCustomClientDestinationName( $driver = $this->createDriverStub($routeCollection); $driver - ->expects($this->at(3)) + ->expects(self::once()) ->method('createQueue', true) ->with('default') ->willReturn($queue) ; $driver - ->expects($this->at(4)) + ->expects(self::once()) ->method('createQueue', true) ->with('fooQueue') ->willReturn($queue) ; $driver - ->expects($this->at(5)) + ->expects(self::once()) ->method('createQueue', true) ->with('ololoQueue') ->willReturn($queue) diff --git a/pkg/enqueue/Tests/Symfony/Consumption/ConfigurableConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Consumption/ConfigurableConsumeCommandTest.php index c788d5e75..083354c24 100644 --- a/pkg/enqueue/Tests/Symfony/Consumption/ConfigurableConsumeCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Consumption/ConfigurableConsumeCommandTest.php @@ -163,17 +163,17 @@ public function testShouldExecuteConsumptionWithSeveralCustomQueues() $consumer = $this->createQueueConsumerMock(); $consumer - ->expects($this->at(0)) + ->expects(self::once()) ->method('bind') ->with('queue-name', $this->identicalTo($processor)) ; $consumer - ->expects($this->at(1)) + ->expects(self::once()) ->method('bind') ->with('another-queue-name', $this->identicalTo($processor)) ; $consumer - ->expects($this->at(2)) + ->expects(self::once()) ->method('consume') ->with($this->isInstanceOf(ChainExtension::class)) ; @@ -205,17 +205,17 @@ public static function getSubscribedQueues() $consumer = $this->createQueueConsumerMock(); $consumer - ->expects($this->at(0)) + ->expects(self::once()) ->method('bind') ->with('fooSubscribedQueues', $this->identicalTo($processor)) ; $consumer - ->expects($this->at(1)) + ->expects(self::once()) ->method('bind') ->with('barSubscribedQueues', $this->identicalTo($processor)) ; $consumer - ->expects($this->at(2)) + ->expects(self::once()) ->method('consume') ->with($this->isInstanceOf(ChainExtension::class)) ; diff --git a/pkg/job-queue/Tests/Doctrine/JobStorageTest.php b/pkg/job-queue/Tests/Doctrine/JobStorageTest.php index 38d72a81c..f01fd06e2 100644 --- a/pkg/job-queue/Tests/Doctrine/JobStorageTest.php +++ b/pkg/job-queue/Tests/Doctrine/JobStorageTest.php @@ -440,12 +440,12 @@ public function testShouldInsertIntoUniqueTableIfJobIsUniqueAndNew() }) ; $connection - ->expects($this->at(0)) + ->expects(self::once()) ->method('insert') ->with('unique_table', ['name' => 'owner-id']) ; $connection - ->expects($this->at(1)) + ->expects(self::once()) ->method('insert') ->with('unique_table', ['name' => 'job-name']) ; @@ -510,12 +510,12 @@ public function testShouldDeleteRecordFromUniqueTableIfJobIsUniqueAndStoppedAtIs $connection = $this->createConnectionMock(); $connection - ->expects($this->at(0)) + ->expects(self::once()) ->method('delete') ->with('unique_table', ['name' => 'owner-id']) ; $connection - ->expects($this->at(1)) + ->expects(self::once()) ->method('delete') ->with('unique_table', ['name' => 'job-name']) ; diff --git a/pkg/redis/Tests/RedisConsumerTest.php b/pkg/redis/Tests/RedisConsumerTest.php index ed67bd73b..f6e77c829 100644 --- a/pkg/redis/Tests/RedisConsumerTest.php +++ b/pkg/redis/Tests/RedisConsumerTest.php @@ -187,19 +187,19 @@ public function testShouldCallRedisBRPopSeveralTimesWithFiveSecondTimeoutIfZeroT $redisMock = $this->createRedisMock(); $redisMock - ->expects($this->at(2)) + ->expects(self::once()) ->method('brpop') ->with(['aQueue'], $expectedTimeout) ->willReturn(null) ; $redisMock - ->expects($this->at(5)) + ->expects(self::once()) ->method('brpop') ->with(['aQueue'], $expectedTimeout) ->willReturn(null) ; $redisMock - ->expects($this->at(8)) + ->expects(self::once()) ->method('brpop') ->with(['aQueue'], $expectedTimeout) ->willReturn(new RedisResult('aQueue', $serializer->toString(new RedisMessage('aBody')))) diff --git a/pkg/redis/Tests/RedisContextTest.php b/pkg/redis/Tests/RedisContextTest.php index 0115f27b8..01fd2fe09 100644 --- a/pkg/redis/Tests/RedisContextTest.php +++ b/pkg/redis/Tests/RedisContextTest.php @@ -161,17 +161,17 @@ public function testShouldAllowDeleteQueue() { $redisMock = $this->createRedisMock(); $redisMock - ->expects($this->at(0)) + ->expects(self::once()) ->method('del') ->with('aQueueName') ; $redisMock - ->expects($this->at(1)) + ->expects(self::once()) ->method('del') ->with('aQueueName:delayed') ; $redisMock - ->expects($this->at(2)) + ->expects(self::once()) ->method('del') ->with('aQueueName:reserved') ; @@ -201,17 +201,17 @@ public function testShouldAllowDeleteTopic() { $redisMock = $this->createRedisMock(); $redisMock - ->expects($this->at(0)) + ->expects(self::once()) ->method('del') ->with('aTopicName') ; $redisMock - ->expects($this->at(1)) + ->expects(self::once()) ->method('del') ->with('aTopicName:delayed') ; $redisMock - ->expects($this->at(2)) + ->expects(self::once()) ->method('del') ->with('aTopicName:reserved') ; diff --git a/pkg/stomp/Tests/BufferedStompClientTest.php b/pkg/stomp/Tests/BufferedStompClientTest.php index 684edf397..ddb92e50d 100644 --- a/pkg/stomp/Tests/BufferedStompClientTest.php +++ b/pkg/stomp/Tests/BufferedStompClientTest.php @@ -128,12 +128,12 @@ public function testShouldAddFrameToBufferIfSubscriptionIdIsNotEqual() $connection = $this->createStompConnectionMock(); $connection - ->expects($this->at(1)) + ->expects(self::once()) ->method('readFrame') ->willReturn($frame) ; $connection - ->expects($this->at(2)) + ->expects(self::once()) ->method('readFrame') ->willReturn(false) ; @@ -159,12 +159,12 @@ public function testShouldAddFirstFrameToBufferIfSubscriptionNotEqualAndReturnSe $connection = $this->createStompConnectionMock(); $connection - ->expects($this->at(1)) + ->expects(self::once()) ->method('readFrame') ->willReturn($frame1) ; $connection - ->expects($this->at(3)) + ->expects(self::once()) ->method('readFrame') ->willReturn($frame2) ; From 582b3a9a670267653064cb789119831ceefa588e Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Thu, 21 Jan 2021 16:37:57 +0200 Subject: [PATCH 15/26] =?UTF-8?q?Fix=20logger-related=20at()=20warnings=20?= =?UTF-8?q?=E2=80=94=20replace=20mocks=20with=20TestLogger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DoctrinePingConnectionExtensionTest.php | 37 ++++---- .../DelayRedeliveredMessageExtensionTest.php | 35 +++----- .../Client/Driver/RabbitMqStompDriverTest.php | 89 +++++++++---------- 3 files changed, 74 insertions(+), 87 deletions(-) diff --git a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php index fd2ae06aa..f7e984392 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() @@ -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/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php index 61a307a5a..a92dc8df1 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php @@ -18,8 +18,8 @@ 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 { @@ -55,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(), @@ -93,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() @@ -184,14 +181,6 @@ private function createConsumerStub(?Queue $queue): Consumer 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/Driver/RabbitMqStompDriverTest.php b/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php index f59376be4..79e8c33b7 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); - } } From b2b1d59370c2a108e308f1e6046f962c1ecbb131 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Thu, 21 Jan 2021 16:53:04 +0200 Subject: [PATCH 16/26] Fix renamed assertions and prophecy warnings --- .../DependencyInjection/BuildProcessorRegistryPassTest.php | 2 +- .../DependencyInjection/BuildProcessorRegistryPassTest.php | 2 +- pkg/fs/Tests/FsContextTest.php | 2 +- pkg/snsqs/Tests/SnsQsProducerTest.php | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) 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/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/fs/Tests/FsContextTest.php b/pkg/fs/Tests/FsContextTest.php index a99276bbe..4bc05e9de 100644 --- a/pkg/fs/Tests/FsContextTest.php +++ b/pkg/fs/Tests/FsContextTest.php @@ -192,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/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() { From 32d49e331d27a7ad18039f82f060743d6ce8b0b4 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Thu, 21 Jan 2021 16:24:09 +0200 Subject: [PATCH 17/26] Fix prophecy warning --- composer.json | 3 ++- pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c13225ac7..c1cc4b041 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,8 @@ "alcaeus/mongo-php-adapter": "^1.0", "kwn/php-rdkafka-stubs": "^1.0.2 | ^2.0", "friendsofphp/php-cs-fixer": "^2", - "dms/phpunit-arraysubset-asserts": "^0.2.1" + "dms/phpunit-arraysubset-asserts": "^0.2.1", + "phpspec/prophecy-phpunit": "^2.0" }, "autoload": { "psr-4": { diff --git a/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php b/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php index 81bb0091b..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 */ From c0ce9b6f3381f7b4881c193160e47a211d9df1b9 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Sun, 24 Jan 2021 21:33:39 +0200 Subject: [PATCH 18/26] Fix mocks and logger --- .../Extension/DoctrinePingConnectionExtensionTest.php | 8 ++++---- pkg/enqueue/Tests/Client/ProducerSendCommandTest.php | 2 +- pkg/enqueue/Tests/Client/ProducerSendEventTest.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php index f7e984392..b740e64c1 100644 --- a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php @@ -135,10 +135,6 @@ public function testShouldSkipIfConnectionWasNotOpened() ; $context = $this->createContext(); - $context->getLogger() - ->expects($this->never()) - ->method('debug') - ; $registry = $this->createRegistryMock(); $registry @@ -149,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 diff --git a/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php b/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php index 9532ba368..443426766 100644 --- a/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php +++ b/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php @@ -479,7 +479,7 @@ public function testShouldCallPostSendExtensionMethod() $extension ->expects(self::once()) - ->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 b482492b4..2a3bbcb5e 100644 --- a/pkg/enqueue/Tests/Client/ProducerSendEventTest.php +++ b/pkg/enqueue/Tests/Client/ProducerSendEventTest.php @@ -499,7 +499,7 @@ public function testShouldCallPostSendExtensionMethodWhenSendToApplicationRouter $extension ->expects(self::once()) - ->method('onDriverPreSend') + ->method('onPostSend') ->willReturnCallback(function (PostSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); $this->assertSame($producer, $context->getProducer()); From dcb62c63fee64c204eb644f50488d3d3d80c9a24 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Sun, 24 Jan 2021 22:24:25 +0200 Subject: [PATCH 19/26] =?UTF-8?q?Revert=20"Fix=20at()=20warnings=20for=20n?= =?UTF-8?q?on-logger=20mocks=20=E2=80=94=20don't=20test=20for=20method=20c?= =?UTF-8?q?all=20order"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 140bc0104221a0c488f02b22c5c366b7038a17cd. # Conflicts: # pkg/enqueue/Tests/Client/ProducerSendCommandTest.php # pkg/enqueue/Tests/Client/ProducerSendEventTest.php --- pkg/amqp-lib/Tests/AmqpContextTest.php | 4 +-- .../Tests/Client/Driver/AmqpDriverTest.php | 23 ++++++++------- .../Tests/Client/Driver/FsDriverTest.php | 8 +++--- .../Tests/Client/Driver/GpsDriverTest.php | 12 ++++---- .../Client/Driver/RabbitMqStompDriverTest.php | 16 +++++------ .../Tests/Client/Driver/RdKafkaDriverTest.php | 6 ++-- .../Tests/Client/Driver/SqsDriverTest.php | 8 +++--- .../Tests/Client/ProducerSendCommandTest.php | 8 +++--- .../Tests/Client/ProducerSendEventTest.php | 12 ++++---- .../Tests/Client/SpoolProducerTest.php | 12 ++++---- .../RouteRecipientListProcessorTest.php | 4 +-- .../Symfony/Client/ConsumeCommandTest.php | 28 +++++++++---------- .../ConfigurableConsumeCommandTest.php | 12 ++++---- .../Tests/Doctrine/JobStorageTest.php | 8 +++--- pkg/redis/Tests/RedisConsumerTest.php | 6 ++-- pkg/redis/Tests/RedisContextTest.php | 12 ++++---- pkg/stomp/Tests/BufferedStompClientTest.php | 8 +++--- 17 files changed, 93 insertions(+), 94 deletions(-) diff --git a/pkg/amqp-lib/Tests/AmqpContextTest.php b/pkg/amqp-lib/Tests/AmqpContextTest.php index ea3bc43c3..4cfde3c14 100644 --- a/pkg/amqp-lib/Tests/AmqpContextTest.php +++ b/pkg/amqp-lib/Tests/AmqpContextTest.php @@ -322,12 +322,12 @@ public function testShouldSetQos() { $channel = $this->createChannelMock(); $channel - ->expects(self::once()) + ->expects($this->at(0)) ->method('basic_qos') ->with($this->identicalTo(0), $this->identicalTo(1), $this->isFalse()) ; $channel - ->expects(self::once()) + ->expects($this->at(1)) ->method('basic_qos') ->with($this->identicalTo(123), $this->identicalTo(456), $this->isTrue()) ; diff --git a/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php b/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php index 08b22c713..3234c45f0 100644 --- a/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php @@ -22,7 +22,6 @@ use Interop\Queue\Message as InteropMessage; use Interop\Queue\Producer as InteropProducer; use Interop\Queue\Queue as InteropQueue; -use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class AmqpDriverTest extends TestCase @@ -191,54 +190,54 @@ public function testShouldSetupBroker() $context = $this->createContextMock(); // setup router $context - ->expects(self::once()) + ->expects($this->at(0)) ->method('createTopic') ->willReturn($routerTopic) ; $context - ->expects(self::once()) + ->expects($this->at(1)) ->method('declareTopic') ->with($this->identicalTo($routerTopic)) ; $context - ->expects(self::once()) + ->expects($this->at(2)) ->method('createQueue') ->willReturn($routerQueue) ; $context - ->expects(self::once()) + ->expects($this->at(3)) ->method('declareQueue') ->with($this->identicalTo($routerQueue)) ; $context - ->expects(self::once()) + ->expects($this->at(4)) ->method('bind') ->with($this->isInstanceOf(AmqpBind::class)) ; // setup processor with default queue $context - ->expects(self::once()) + ->expects($this->at(5)) ->method('createQueue') ->with($this->getDefaultQueueTransportName()) ->willReturn($processorWithDefaultQueue) ; $context - ->expects(self::once()) + ->expects($this->at(6)) ->method('declareQueue') ->with($this->identicalTo($processorWithDefaultQueue)) ; $context - ->expects(self::once()) + ->expects($this->at(7)) ->method('createQueue') ->with($this->getCustomQueueTransportName()) ->willReturn($processorWithCustomQueue) ; $context - ->expects(self::once()) + ->expects($this->at(8)) ->method('declareQueue') ->with($this->identicalTo($processorWithCustomQueue)) ; @@ -291,7 +290,7 @@ protected function createDriver(...$args): DriverInterface } /** - * @return AmqpContext|MockObject + * @return AmqpContext */ protected function createContextMock(): Context { @@ -299,7 +298,7 @@ protected function createContextMock(): Context } /** - * @return AmqpProducer|MockObject + * @return AmqpProducer */ protected function createProducerMock(): InteropProducer { diff --git a/pkg/enqueue/Tests/Client/Driver/FsDriverTest.php b/pkg/enqueue/Tests/Client/Driver/FsDriverTest.php index a235b64b8..f1cd02f9b 100644 --- a/pkg/enqueue/Tests/Client/Driver/FsDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/FsDriverTest.php @@ -44,23 +44,23 @@ public function testShouldSetupBroker() $context = $this->createContextMock(); // setup router $context - ->expects(self::once()) + ->expects($this->at(0)) ->method('createQueue') ->willReturn($routerQueue) ; $context - ->expects(self::once()) + ->expects($this->at(1)) ->method('declareDestination') ->with($this->identicalTo($routerQueue)) ; // setup processor queue $context - ->expects(self::once()) + ->expects($this->at(2)) ->method('createQueue') ->willReturn($processorQueue) ; $context - ->expects(self::once()) + ->expects($this->at(3)) ->method('declareDestination') ->with($this->identicalTo($processorQueue)) ; diff --git a/pkg/enqueue/Tests/Client/Driver/GpsDriverTest.php b/pkg/enqueue/Tests/Client/Driver/GpsDriverTest.php index 37a97be66..c0cac0458 100644 --- a/pkg/enqueue/Tests/Client/Driver/GpsDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/GpsDriverTest.php @@ -46,35 +46,35 @@ public function testShouldSetupBroker() $context = $this->createContextMock(); // setup router $context - ->expects(self::once()) + ->expects($this->at(0)) ->method('createTopic') ->willReturn($routerTopic) ; $context - ->expects(self::once()) + ->expects($this->at(1)) ->method('createQueue') ->willReturn($routerQueue) ; $context - ->expects(self::once()) + ->expects($this->at(2)) ->method('subscribe') ->with($this->identicalTo($routerTopic), $this->identicalTo($routerQueue)) ; $context - ->expects(self::once()) + ->expects($this->at(3)) ->method('createQueue') ->with($this->getDefaultQueueTransportName()) ->willReturn($processorQueue) ; // setup processor queue $context - ->expects(self::once()) + ->expects($this->at(4)) ->method('createTopic') ->with($this->getDefaultQueueTransportName()) ->willReturn($processorTopic) ; $context - ->expects(self::once()) + ->expects($this->at(5)) ->method('subscribe') ->with($this->identicalTo($processorTopic), $this->identicalTo($processorQueue)) ; diff --git a/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php b/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php index 79e8c33b7..fbcb68644 100644 --- a/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php @@ -196,12 +196,12 @@ public function shouldSendMessageToDelayExchangeIfDelaySet() $producer = $this->createProducerMock(); $producer - ->expects(self::once()) + ->expects($this->at(0)) ->method('setDeliveryDelay') ->with(10000) ; $producer - ->expects(self::once()) + ->expects($this->at(1)) ->method('setDeliveryDelay') ->with(null) ; @@ -300,7 +300,7 @@ public function testShouldSetupBroker() $managementClient = $this->createManagementClientMock(); $managementClient - ->expects(self::once()) + ->expects($this->at(0)) ->method('declareExchange') ->with('aprefix.router', [ 'type' => 'fanout', @@ -309,7 +309,7 @@ public function testShouldSetupBroker() ]) ; $managementClient - ->expects(self::once()) + ->expects($this->at(1)) ->method('declareQueue') ->with('aprefix.default', [ 'durable' => true, @@ -320,12 +320,12 @@ public function testShouldSetupBroker() ]) ; $managementClient - ->expects(self::once()) + ->expects($this->at(2)) ->method('bind') ->with('aprefix.router', 'aprefix.default', 'aprefix.default') ; $managementClient - ->expects(self::once()) + ->expects($this->at(3)) ->method('declareQueue') ->with('aprefix.default', [ 'durable' => true, @@ -401,7 +401,7 @@ public function testSetupBrokerShouldCreateDelayExchangeIfEnabled() $managementClient = $this->createManagementClientMock(); $managementClient - ->expects(self::once()) + ->expects($this->at(4)) ->method('declareExchange') ->with('aprefix.default.delayed', [ 'type' => 'x-delayed-message', @@ -413,7 +413,7 @@ public function testSetupBrokerShouldCreateDelayExchangeIfEnabled() ]) ; $managementClient - ->expects(self::once()) + ->expects($this->at(5)) ->method('bind') ->with('aprefix.default.delayed', 'aprefix.default', 'aprefix.default') ; diff --git a/pkg/enqueue/Tests/Client/Driver/RdKafkaDriverTest.php b/pkg/enqueue/Tests/Client/Driver/RdKafkaDriverTest.php index 16d1da929..659590ba3 100644 --- a/pkg/enqueue/Tests/Client/Driver/RdKafkaDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/RdKafkaDriverTest.php @@ -47,17 +47,17 @@ public function testShouldSetupBroker() $context = $this->createContextMock(); $context - ->expects(self::once()) + ->expects($this->at(0)) ->method('createQueue') ->willReturn($routerTopic) ; $context - ->expects(self::once()) + ->expects($this->at(1)) ->method('createQueue') ->willReturn($routerQueue) ; $context - ->expects(self::once()) + ->expects($this->at(2)) ->method('createQueue') ->willReturn($processorTopic) ; diff --git a/pkg/enqueue/Tests/Client/Driver/SqsDriverTest.php b/pkg/enqueue/Tests/Client/Driver/SqsDriverTest.php index fb4af5303..2e3005e6a 100644 --- a/pkg/enqueue/Tests/Client/Driver/SqsDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/SqsDriverTest.php @@ -42,25 +42,25 @@ public function testShouldSetupBroker() $context = $this->createContextMock(); // setup router $context - ->expects(self::once()) + ->expects($this->at(0)) ->method('createQueue') ->with('aprefix_dot_default') ->willReturn($routerQueue) ; $context - ->expects(self::once()) + ->expects($this->at(1)) ->method('declareQueue') ->with($this->identicalTo($routerQueue)) ; // setup processor queue $context - ->expects(self::once()) + ->expects($this->at(2)) ->method('createQueue') ->with('aprefix_dot_default') ->willReturn($processorQueue) ; $context - ->expects(self::once()) + ->expects($this->at(3)) ->method('declareQueue') ->with($this->identicalTo($processorQueue)) ; diff --git a/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php b/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php index 443426766..9500e9d62 100644 --- a/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php +++ b/pkg/enqueue/Tests/Client/ProducerSendCommandTest.php @@ -370,7 +370,7 @@ public function testShouldCallPreSendCommandExtensionMethodWhenSendToBus() $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects(self::once()) + ->expects($this->at(0)) ->method('onPreSendCommand') ->willReturnCallback(function (PreSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -408,7 +408,7 @@ public function testShouldCallPreSendCommandExtensionMethodWhenSendToApplication $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects(self::once()) + ->expects($this->at(0)) ->method('onPreSendCommand') ->willReturnCallback(function (PreSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -446,7 +446,7 @@ public function testShouldCallPreDriverSendExtensionMethod() $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects(self::once()) + ->expects($this->at(0)) ->method('onDriverPreSend') ->willReturnCallback(function (DriverPreSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -478,7 +478,7 @@ public function testShouldCallPostSendExtensionMethod() $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects(self::once()) + ->expects($this->at(0)) ->method('onPostSend') ->willReturnCallback(function (PostSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); diff --git a/pkg/enqueue/Tests/Client/ProducerSendEventTest.php b/pkg/enqueue/Tests/Client/ProducerSendEventTest.php index 2a3bbcb5e..c92b49560 100644 --- a/pkg/enqueue/Tests/Client/ProducerSendEventTest.php +++ b/pkg/enqueue/Tests/Client/ProducerSendEventTest.php @@ -326,7 +326,7 @@ public function testShouldCallPreSendEventExtensionMethodWhenSendToBus() $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects(self::once()) + ->expects($this->at(0)) ->method('onPreSendEvent') ->willReturnCallback(function (PreSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -364,7 +364,7 @@ public function testShouldCallPreSendEventExtensionMethodWhenSendToApplicationRo $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects(self::once()) + ->expects($this->at(0)) ->method('onPreSendEvent') ->willReturnCallback(function (PreSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -402,7 +402,7 @@ public function testShouldCallPreDriverSendExtensionMethodWhenSendToMessageBus() $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects(self::once()) + ->expects($this->at(0)) ->method('onDriverPreSend') ->willReturnCallback(function (DriverPreSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -434,7 +434,7 @@ public function testShouldCallPreDriverSendExtensionMethodWhenSendToApplicationR $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects(self::once()) + ->expects($this->at(0)) ->method('onDriverPreSend') ->willReturnCallback(function (DriverPreSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -466,7 +466,7 @@ public function testShouldCallPostSendExtensionMethodWhenSendToMessageBus() $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects(self::once()) + ->expects($this->at(0)) ->method('onPostSend') ->willReturnCallback(function (PostSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); @@ -498,7 +498,7 @@ public function testShouldCallPostSendExtensionMethodWhenSendToApplicationRouter $producer = new Producer($driver, $this->createRpcFactoryMock(), $extension); $extension - ->expects(self::once()) + ->expects($this->at(0)) ->method('onPostSend') ->willReturnCallback(function (PostSend $context) use ($message, $producer, $driver) { $this->assertSame($message, $context->getMessage()); diff --git a/pkg/enqueue/Tests/Client/SpoolProducerTest.php b/pkg/enqueue/Tests/Client/SpoolProducerTest.php index df9e728ed..024fd6da2 100644 --- a/pkg/enqueue/Tests/Client/SpoolProducerTest.php +++ b/pkg/enqueue/Tests/Client/SpoolProducerTest.php @@ -68,17 +68,17 @@ public function testShouldSendQueuedEventMessagesOnFlush() $realProducer = $this->createProducerMock(); $realProducer - ->expects(self::once()) + ->expects($this->at(0)) ->method('sendEvent') ->with('foo_topic', 'first') ; $realProducer - ->expects(self::once()) + ->expects($this->at(1)) ->method('sendEvent') ->with('bar_topic', ['second']) ; $realProducer - ->expects(self::once()) + ->expects($this->at(2)) ->method('sendEvent') ->with('baz_topic', $this->identicalTo($message)) ; @@ -103,17 +103,17 @@ public function testShouldSendQueuedCommandMessagesOnFlush() $realProducer = $this->createProducerMock(); $realProducer - ->expects(self::once()) + ->expects($this->at(0)) ->method('sendCommand') ->with('foo_command', 'first') ; $realProducer - ->expects(self::once()) + ->expects($this->at(1)) ->method('sendCommand') ->with('bar_command', ['second']) ; $realProducer - ->expects(self::once()) + ->expects($this->at(2)) ->method('sendCommand') ->with('baz_command', $this->identicalTo($message)) ; diff --git a/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php b/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php index dfc820656..8a2e089f7 100644 --- a/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php +++ b/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php @@ -45,12 +45,12 @@ public function testShouldProduceRecipientsMessagesAndAckOriginalMessage() $producerMock = $this->createProducerMock(); $producerMock - ->expects(self::once()) + ->expects($this->at(0)) ->method('send') ->with($this->identicalTo($fooRecipient->getDestination()), $this->identicalTo($fooRecipient->getMessage())) ; $producerMock - ->expects(self::once()) + ->expects($this->at(1)) ->method('send') ->with($this->identicalTo($barRecipient->getDestination()), $this->identicalTo($barRecipient->getMessage())) ; diff --git a/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php index 4f1dfe2fa..fcc099538 100644 --- a/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php @@ -269,13 +269,13 @@ public function testShouldBindCustomExecuteConsumptionAndUseCustomClientDestinat $driver = $this->createDriverStub($routeCollection); $driver - ->expects(self::once()) + ->expects($this->at(3)) ->method('createQueue') ->with('default', true) ->willReturn($defaultQueue) ; $driver - ->expects(self::once()) + ->expects($this->at(4)) ->method('createQueue') ->with('custom', true) ->willReturn($customQueue) @@ -283,17 +283,17 @@ public function testShouldBindCustomExecuteConsumptionAndUseCustomClientDestinat $consumer = $this->createQueueConsumerMock(); $consumer - ->expects(self::once()) + ->expects($this->at(0)) ->method('bind') ->with($this->identicalTo($defaultQueue), $this->identicalTo($processor)) ; $consumer - ->expects(self::once()) + ->expects($this->at(1)) ->method('bind') ->with($this->identicalTo($customQueue), $this->identicalTo($processor)) ; $consumer - ->expects(self::once()) + ->expects($this->at(2)) ->method('consume') ->with($this->isInstanceOf(ChainExtension::class)) ; @@ -408,13 +408,13 @@ public function testShouldBindQueuesOnlyOnce() $driver = $this->createDriverStub($routeCollection); $driver - ->expects(self::once()) + ->expects($this->at(3)) ->method('createQueue') ->with('default', true) ->willReturn($defaultQueue) ; $driver - ->expects(self::once()) + ->expects($this->at(4)) ->method('createQueue', true) ->with('custom') ->willReturn($customQueue) @@ -422,17 +422,17 @@ public function testShouldBindQueuesOnlyOnce() $consumer = $this->createQueueConsumerMock(); $consumer - ->expects(self::once()) + ->expects($this->at(0)) ->method('bind') ->with($this->identicalTo($defaultQueue), $this->identicalTo($processor)) ; $consumer - ->expects(self::once()) + ->expects($this->at(1)) ->method('bind') ->with($this->identicalTo($customQueue), $this->identicalTo($processor)) ; $consumer - ->expects(self::once()) + ->expects($this->at(2)) ->method('consume') ->with($this->isInstanceOf(ChainExtension::class)) ; @@ -473,7 +473,7 @@ public function testShouldNotBindExternalRoutes() ->with($this->identicalTo($defaultQueue), $this->identicalTo($processor)) ; $consumer - ->expects(self::once()) + ->expects($this->at(1)) ->method('consume') ->with($this->isInstanceOf(ChainExtension::class)) ; @@ -513,19 +513,19 @@ public function testShouldSkipQueueConsumptionAndUseCustomClientDestinationName( $driver = $this->createDriverStub($routeCollection); $driver - ->expects(self::once()) + ->expects($this->at(3)) ->method('createQueue', true) ->with('default') ->willReturn($queue) ; $driver - ->expects(self::once()) + ->expects($this->at(4)) ->method('createQueue', true) ->with('fooQueue') ->willReturn($queue) ; $driver - ->expects(self::once()) + ->expects($this->at(5)) ->method('createQueue', true) ->with('ololoQueue') ->willReturn($queue) diff --git a/pkg/enqueue/Tests/Symfony/Consumption/ConfigurableConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Consumption/ConfigurableConsumeCommandTest.php index 083354c24..c788d5e75 100644 --- a/pkg/enqueue/Tests/Symfony/Consumption/ConfigurableConsumeCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Consumption/ConfigurableConsumeCommandTest.php @@ -163,17 +163,17 @@ public function testShouldExecuteConsumptionWithSeveralCustomQueues() $consumer = $this->createQueueConsumerMock(); $consumer - ->expects(self::once()) + ->expects($this->at(0)) ->method('bind') ->with('queue-name', $this->identicalTo($processor)) ; $consumer - ->expects(self::once()) + ->expects($this->at(1)) ->method('bind') ->with('another-queue-name', $this->identicalTo($processor)) ; $consumer - ->expects(self::once()) + ->expects($this->at(2)) ->method('consume') ->with($this->isInstanceOf(ChainExtension::class)) ; @@ -205,17 +205,17 @@ public static function getSubscribedQueues() $consumer = $this->createQueueConsumerMock(); $consumer - ->expects(self::once()) + ->expects($this->at(0)) ->method('bind') ->with('fooSubscribedQueues', $this->identicalTo($processor)) ; $consumer - ->expects(self::once()) + ->expects($this->at(1)) ->method('bind') ->with('barSubscribedQueues', $this->identicalTo($processor)) ; $consumer - ->expects(self::once()) + ->expects($this->at(2)) ->method('consume') ->with($this->isInstanceOf(ChainExtension::class)) ; diff --git a/pkg/job-queue/Tests/Doctrine/JobStorageTest.php b/pkg/job-queue/Tests/Doctrine/JobStorageTest.php index f01fd06e2..38d72a81c 100644 --- a/pkg/job-queue/Tests/Doctrine/JobStorageTest.php +++ b/pkg/job-queue/Tests/Doctrine/JobStorageTest.php @@ -440,12 +440,12 @@ public function testShouldInsertIntoUniqueTableIfJobIsUniqueAndNew() }) ; $connection - ->expects(self::once()) + ->expects($this->at(0)) ->method('insert') ->with('unique_table', ['name' => 'owner-id']) ; $connection - ->expects(self::once()) + ->expects($this->at(1)) ->method('insert') ->with('unique_table', ['name' => 'job-name']) ; @@ -510,12 +510,12 @@ public function testShouldDeleteRecordFromUniqueTableIfJobIsUniqueAndStoppedAtIs $connection = $this->createConnectionMock(); $connection - ->expects(self::once()) + ->expects($this->at(0)) ->method('delete') ->with('unique_table', ['name' => 'owner-id']) ; $connection - ->expects(self::once()) + ->expects($this->at(1)) ->method('delete') ->with('unique_table', ['name' => 'job-name']) ; diff --git a/pkg/redis/Tests/RedisConsumerTest.php b/pkg/redis/Tests/RedisConsumerTest.php index f6e77c829..ed67bd73b 100644 --- a/pkg/redis/Tests/RedisConsumerTest.php +++ b/pkg/redis/Tests/RedisConsumerTest.php @@ -187,19 +187,19 @@ public function testShouldCallRedisBRPopSeveralTimesWithFiveSecondTimeoutIfZeroT $redisMock = $this->createRedisMock(); $redisMock - ->expects(self::once()) + ->expects($this->at(2)) ->method('brpop') ->with(['aQueue'], $expectedTimeout) ->willReturn(null) ; $redisMock - ->expects(self::once()) + ->expects($this->at(5)) ->method('brpop') ->with(['aQueue'], $expectedTimeout) ->willReturn(null) ; $redisMock - ->expects(self::once()) + ->expects($this->at(8)) ->method('brpop') ->with(['aQueue'], $expectedTimeout) ->willReturn(new RedisResult('aQueue', $serializer->toString(new RedisMessage('aBody')))) diff --git a/pkg/redis/Tests/RedisContextTest.php b/pkg/redis/Tests/RedisContextTest.php index 01fd2fe09..0115f27b8 100644 --- a/pkg/redis/Tests/RedisContextTest.php +++ b/pkg/redis/Tests/RedisContextTest.php @@ -161,17 +161,17 @@ public function testShouldAllowDeleteQueue() { $redisMock = $this->createRedisMock(); $redisMock - ->expects(self::once()) + ->expects($this->at(0)) ->method('del') ->with('aQueueName') ; $redisMock - ->expects(self::once()) + ->expects($this->at(1)) ->method('del') ->with('aQueueName:delayed') ; $redisMock - ->expects(self::once()) + ->expects($this->at(2)) ->method('del') ->with('aQueueName:reserved') ; @@ -201,17 +201,17 @@ public function testShouldAllowDeleteTopic() { $redisMock = $this->createRedisMock(); $redisMock - ->expects(self::once()) + ->expects($this->at(0)) ->method('del') ->with('aTopicName') ; $redisMock - ->expects(self::once()) + ->expects($this->at(1)) ->method('del') ->with('aTopicName:delayed') ; $redisMock - ->expects(self::once()) + ->expects($this->at(2)) ->method('del') ->with('aTopicName:reserved') ; diff --git a/pkg/stomp/Tests/BufferedStompClientTest.php b/pkg/stomp/Tests/BufferedStompClientTest.php index ddb92e50d..684edf397 100644 --- a/pkg/stomp/Tests/BufferedStompClientTest.php +++ b/pkg/stomp/Tests/BufferedStompClientTest.php @@ -128,12 +128,12 @@ public function testShouldAddFrameToBufferIfSubscriptionIdIsNotEqual() $connection = $this->createStompConnectionMock(); $connection - ->expects(self::once()) + ->expects($this->at(1)) ->method('readFrame') ->willReturn($frame) ; $connection - ->expects(self::once()) + ->expects($this->at(2)) ->method('readFrame') ->willReturn(false) ; @@ -159,12 +159,12 @@ public function testShouldAddFirstFrameToBufferIfSubscriptionNotEqualAndReturnSe $connection = $this->createStompConnectionMock(); $connection - ->expects(self::once()) + ->expects($this->at(1)) ->method('readFrame') ->willReturn($frame1) ; $connection - ->expects(self::once()) + ->expects($this->at(3)) ->method('readFrame') ->willReturn($frame2) ; From 9d34085defd6eca69399516112e30218663bdda1 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Mon, 25 Jan 2021 09:03:39 +0200 Subject: [PATCH 20/26] Ignore phpunit result cache --- .gitignore | 1 + 1 file changed, 1 insertion(+) 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 From 443fd77f6a0d5e7ba2b68af8885aadf94ccca35e Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Mon, 25 Jan 2021 09:03:49 +0200 Subject: [PATCH 21/26] Fix reading parent attribute --- pkg/test/ReadAttributeTrait.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/pkg/test/ReadAttributeTrait.php b/pkg/test/ReadAttributeTrait.php index 73209105e..381b513da 100644 --- a/pkg/test/ReadAttributeTrait.php +++ b/pkg/test/ReadAttributeTrait.php @@ -2,11 +2,13 @@ namespace Enqueue\Test; +use ReflectionProperty; + trait ReadAttributeTrait { public function readAttribute(object $object, string $attribute) { - $refProperty = new \ReflectionProperty(get_class($object), $attribute); + $refProperty = $this->getClassAttribute($object, $attribute); $refProperty->setAccessible(true); $value = $refProperty->getValue($object); $refProperty->setAccessible(false); @@ -14,6 +16,27 @@ public function readAttribute(object $object, string $attribute) return $value; } + private function getClassAttribute( + object $object, + string $attribute, + ?string $class = null + ): ReflectionProperty { + if ($class === null) { + $class = get_class($object); + } + + try { + return new ReflectionProperty($class, $attribute); + } catch (\ReflectionException $exception) { + $parentClass = get_parent_class($object); + if ($parentClass === false) { + throw $exception; + } + + return $this->getClassAttribute($object, $attribute, $parentClass); + } + } + private function assertAttributeSame($expected, string $attribute, object $object): void { static::assertSame($expected, $this->readAttribute($object, $attribute)); From d380e5edf834041329e5992c2eaf685bc5401126 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Mon, 25 Jan 2021 09:20:30 +0200 Subject: [PATCH 22/26] Migrate PhpUnit config --- phpunit.xml.dist | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 + + From 5a403dc5d4694b23b06304d5990ab887608b993d Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Mon, 25 Jan 2021 09:44:34 +0200 Subject: [PATCH 23/26] Fix stan --- pkg/redis/Tests/RedisProducerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/redis/Tests/RedisProducerTest.php b/pkg/redis/Tests/RedisProducerTest.php index ce3c77ad0..53d5f19e3 100644 --- a/pkg/redis/Tests/RedisProducerTest.php +++ b/pkg/redis/Tests/RedisProducerTest.php @@ -104,7 +104,7 @@ public function testShouldCallZaddOnSendWithDeliveryDelay() ->with( 'aDestination:delayed', $this->isJson(), - $this->equalTo(time() + 5, 1) + $this->equalTo(time() + 5) ) ; From 8ba67506bbb5307539968457a0facf920abb25e3 Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Mon, 25 Jan 2021 09:46:24 +0200 Subject: [PATCH 24/26] Fix CS --- .../Functional/AmqpCommonUseCasesTest.php | 6 ++-- .../AmqpConsumptionUseCasesTest.php | 6 ++-- .../Tests/Functional/AmqpRpcUseCasesTest.php | 6 ++-- .../Tests/SignalSocketHelperTest.php | 28 +++++++++---------- .../Tests/Functional/UseCasesTest.php | 2 +- .../Tests/Functional/DbalConsumerTest.php | 2 +- ...ndReceivePriorityMessagesFromQueueTest.php | 2 +- ...ndReceivePriorityMessagesFromQueueTest.php | 2 +- .../Functional/Events/AsyncListenerTest.php | 2 +- .../Functional/Events/AsyncProcessorTest.php | 2 +- .../Functional/Events/AsyncSubscriberTest.php | 2 +- .../Tests/Functional/LazyProducerTest.php | 4 +-- .../Tests/Functional/UseCasesTest.php | 4 +-- .../Tests/Client/Driver/AmqpDriverTest.php | 3 -- .../Client/Driver/RabbitMqDriverTest.php | 3 -- .../Tests/Consumption/QueueConsumerTest.php | 2 +- .../Symfony/Client/ConsumeCommandTest.php | 2 +- .../Consumption/ConsumeCommandTest.php | 2 +- .../Tests/Functional/FsCommonUseCasesTest.php | 4 +-- pkg/fs/Tests/Functional/FsConsumerTest.php | 4 +-- .../Functional/FsConsumptionUseCasesTest.php | 4 +-- pkg/fs/Tests/Functional/FsProducerTest.php | 4 +-- pkg/fs/Tests/Functional/FsRpcUseCasesTest.php | 4 +-- ...rmanSendToTopicAndReceiveFromQueueTest.php | 2 +- ...ndToTopicAndReceiveNoWaitFromQueueTest.php | 2 +- .../Tests/Functional/MongodbConsumerTest.php | 2 +- ...ndReceivePriorityMessagesFromQueueTest.php | 2 +- ...talkSendToTopicAndReceiveFromQueueTest.php | 2 +- ...ndToTopicAndReceiveNoWaitFromQueueTest.php | 2 +- .../Functional/PRedisCommonUseCasesTest.php | 6 ++-- .../PRedisConsumptionUseCasesTest.php | 6 ++-- .../Functional/PhpRedisCommonUseCasesTest.php | 6 ++-- .../PhpRedisConsumptionUseCasesTest.php | 6 ++-- .../Functional/SqsConsumptionUseCasesTest.php | 2 +- .../Functional/StompCommonUseCasesTest.php | 6 ++-- .../StompConsumptionUseCasesTest.php | 6 ++-- .../Tests/Functional/StompRpcUseCasesTest.php | 6 ++-- pkg/test/ReadAttributeTrait.php | 4 +-- .../Tests/Functional/WampConsumerTest.php | 2 +- 39 files changed, 78 insertions(+), 84 deletions(-) diff --git a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php index 8e8ea2545..4e4b54166 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(): void + protected function setUp(): void { $this->amqpContext = $this->buildAmqpContext(); @@ -30,7 +30,7 @@ public function setUp(): void $this->removeExchange('amqp_ext.test_exchange'); } - public function tearDown(): void + protected function tearDown(): void { $this->amqpContext->close(); } diff --git a/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php index 09d0a0e99..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(): void + 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 5aafe96a4..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(): void + protected function setUp(): void { $this->amqpContext = $this->buildAmqpContext(); @@ -31,7 +31,7 @@ public function setUp(): void $this->removeQueue('rpc.reply_test'); } - public function tearDown(): void + protected function tearDown(): void { $this->amqpContext->close(); } diff --git a/pkg/amqp-tools/Tests/SignalSocketHelperTest.php b/pkg/amqp-tools/Tests/SignalSocketHelperTest.php index 61e0d2ce6..a44e42a70 100644 --- a/pkg/amqp-tools/Tests/SignalSocketHelperTest.php +++ b/pkg/amqp-tools/Tests/SignalSocketHelperTest.php @@ -19,7 +19,7 @@ class SignalSocketHelperTest extends TestCase private $backupSigIntHandler; - public function setUp(): void + protected function setUp(): void { parent::setUp(); @@ -28,16 +28,16 @@ public function setUp(): void $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(); @@ -46,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); } } @@ -71,7 +71,7 @@ public function testShouldRegisterHandlerOnBeforeSocketAndBackupCurrentOne() { $handler = function () {}; - pcntl_signal(SIGTERM, $handler); + pcntl_signal(\SIGTERM, $handler); $this->signalHelper->beforeSocket(); @@ -80,8 +80,8 @@ public function testShouldRegisterHandlerOnBeforeSocketAndBackupCurrentOne() $handlers = $this->readAttribute($this->signalHelper, 'handlers'); self::assertIsArray($handlers); - $this->assertArrayHasKey(SIGTERM, $handlers); - $this->assertSame($handler, $handlers[SIGTERM]); + $this->assertArrayHasKey(\SIGTERM, $handlers); + $this->assertSame($handler, $handlers[\SIGTERM]); } public function testRestoreDefaultPropertiesOnAfterSocket() @@ -97,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() @@ -118,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/async-event-dispatcher/Tests/Functional/UseCasesTest.php b/pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php index f073ff515..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(): void + protected function setUp(): void { (new Filesystem())->remove(__DIR__.'/queues/'); diff --git a/pkg/dbal/Tests/Functional/DbalConsumerTest.php b/pkg/dbal/Tests/Functional/DbalConsumerTest.php index 709f1eafe..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(): void + protected function setUp(): void { $this->context = $this->createDbalContext(); } diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php index a26c58ef2..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(): void + 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 44fba568f..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(): void + protected function setUp(): void { parent::setUp(); diff --git a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php index 2dcdd251e..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(): void + 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 8c8501ad4..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(): void + 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 ce9f6456c..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(): void + 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 c41a4d2db..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(): void + 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/UseCasesTest.php b/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php index 2144e42d7..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(): void + 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/Tests/Client/Driver/AmqpDriverTest.php b/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php index 3234c45f0..2cfb170b9 100644 --- a/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php @@ -313,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); diff --git a/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php b/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php index 6b61465c3..b209d85bc 100644 --- a/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php @@ -92,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); diff --git a/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php index a087926ad..ecf7f9afa 100644 --- a/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php +++ b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php @@ -1537,7 +1537,7 @@ private function createExtension() */ private function createConsumerStub($queue = null): Consumer { - if ($queue === null) { + if (null === $queue) { $queue = 'queue'; } if (is_string($queue)) { diff --git a/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php index fcc099538..1d94e6e51 100644 --- a/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php @@ -677,7 +677,7 @@ private function createExtension() */ private function createConsumerStub($queue = null): Consumer { - if ($queue === null) { + if (null === $queue) { $queue = 'queue'; } if (is_string($queue)) { diff --git a/pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php index cfcfd520c..348397137 100644 --- a/pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Consumption/ConsumeCommandTest.php @@ -221,7 +221,7 @@ private function createExtension() */ private function createConsumerStub($queue = null): Consumer { - if ($queue === null) { + if (null === $queue) { $queue = 'queue'; } if (is_string($queue)) { diff --git a/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php b/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php index 9b169a03d..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(): void + 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 495989aad..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(): void + 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 28457afbb..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(): void + 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 ae95ddf68..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(): void + protected function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); @@ -22,7 +22,7 @@ public function setUp(): void 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 01b8894f9..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(): void + protected function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); @@ -28,7 +28,7 @@ public function setUp(): void new TempFile(sys_get_temp_dir().'/fs_reply_queue'); } - public function tearDown(): void + protected function tearDown(): void { $this->fsContext->close(); } diff --git a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php index e34d9d1d5..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(): void + protected function setUp(): void { $this->time = time(); } diff --git a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php index b68b94480..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(): void + protected function setUp(): void { $this->time = time(); } diff --git a/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php b/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php index ccefe0278..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(): void + protected function setUp(): void { $this->context = $this->buildMongodbContext(); } diff --git a/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php index 1f06aac5d..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(): void + protected function setUp(): void { parent::setUp(); diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php index 9a913e422..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(): void + protected function setUp(): void { $this->time = time(); } diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php index c3501f8aa..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(): void + protected function setUp(): void { $this->time = time(); } diff --git a/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php b/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php index f54aadf91..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(): void + protected function setUp(): void { $this->context = $this->buildPRedisContext(); @@ -27,7 +27,7 @@ public function setUp(): void $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 e657b1830..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(): void + protected function setUp(): void { $this->context = $this->buildPRedisContext(); @@ -27,7 +27,7 @@ public function setUp(): void $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 ee4a1a786..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(): void + protected function setUp(): void { $this->context = $this->buildPhpRedisContext(); @@ -27,7 +27,7 @@ public function setUp(): void $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 f255d4ea0..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(): void + protected function setUp(): void { $this->context = $this->buildPhpRedisContext(); @@ -27,7 +27,7 @@ public function setUp(): void $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/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php b/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php index f003825d1..9c57dcbdc 100644 --- a/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php +++ b/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php @@ -18,8 +18,8 @@ class SqsConsumptionUseCasesTest extends TestCase { - use SqsExtension; use RetryTrait; + use SqsExtension; /** * @var SqsContext diff --git a/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php b/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php index 1b56893b1..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(): void + 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/StompConsumptionUseCasesTest.php b/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php index fd816ccad..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(): void + 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 657510c19..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(): void + protected function setUp(): void { $this->stompContext = $this->buildStompContext(); @@ -30,7 +30,7 @@ public function setUp(): void $this->removeQueue('stomp.rpc.reply_test'); } - public function tearDown(): void + protected function tearDown(): void { $this->stompContext->close(); } diff --git a/pkg/test/ReadAttributeTrait.php b/pkg/test/ReadAttributeTrait.php index 381b513da..6938f257c 100644 --- a/pkg/test/ReadAttributeTrait.php +++ b/pkg/test/ReadAttributeTrait.php @@ -21,7 +21,7 @@ private function getClassAttribute( string $attribute, ?string $class = null ): ReflectionProperty { - if ($class === null) { + if (null === $class) { $class = get_class($object); } @@ -29,7 +29,7 @@ private function getClassAttribute( return new ReflectionProperty($class, $attribute); } catch (\ReflectionException $exception) { $parentClass = get_parent_class($object); - if ($parentClass === false) { + if (false === $parentClass) { throw $exception; } diff --git a/pkg/wamp/Tests/Functional/WampConsumerTest.php b/pkg/wamp/Tests/Functional/WampConsumerTest.php index 57dc32fd5..2494721d1 100644 --- a/pkg/wamp/Tests/Functional/WampConsumerTest.php +++ b/pkg/wamp/Tests/Functional/WampConsumerTest.php @@ -16,8 +16,8 @@ */ class WampConsumerTest extends TestCase { - use WampExtension; use RetryTrait; + use WampExtension; public static function setUpBeforeClass(): void { From 9e6a755fb1d8118aab5f1e0efd8dfd12ceac5bfe Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Mon, 25 Jan 2021 09:51:30 +0200 Subject: [PATCH 25/26] Update PHP and PHPUnit across all packages; fix ext-rdkafka requirement --- composer.json | 4 ++-- pkg/amqp-bunny/composer.json | 4 ++-- pkg/amqp-ext/composer.json | 4 ++-- pkg/amqp-lib/composer.json | 4 ++-- pkg/amqp-tools/composer.json | 4 ++-- pkg/async-command/composer.json | 2 +- pkg/async-event-dispatcher/composer.json | 4 ++-- pkg/dbal/composer.json | 4 ++-- pkg/enqueue-bundle/composer.json | 4 ++-- pkg/enqueue/composer.json | 4 ++-- pkg/fs/composer.json | 4 ++-- pkg/gearman/composer.json | 4 ++-- pkg/gps/composer.json | 4 ++-- pkg/job-queue/composer.json | 4 ++-- pkg/mongodb/composer.json | 4 ++-- pkg/monitoring/composer.json | 4 ++-- pkg/null/composer.json | 4 ++-- pkg/pheanstalk/composer.json | 4 ++-- pkg/rdkafka/composer.json | 4 ++-- pkg/redis/composer.json | 4 ++-- pkg/simple-client/composer.json | 4 ++-- pkg/sns/composer.json | 4 ++-- pkg/snsqs/composer.json | 4 ++-- pkg/sqs/composer.json | 4 ++-- pkg/stomp/composer.json | 4 ++-- pkg/wamp/composer.json | 4 ++-- 26 files changed, 51 insertions(+), 51 deletions(-) diff --git a/composer.json b/composer.json index c1cc4b041..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.3|^8.0", + "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", 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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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" From 1cad99fc1d9dcda2e09527ac0faa175b101a239e Mon Sep 17 00:00:00 2001 From: Andrew M-Y Date: Mon, 25 Jan 2021 09:55:35 +0200 Subject: [PATCH 26/26] Fix CS --- pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php index 4e4b54166..a90b1d306 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php @@ -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);