From a95217529ef70375c8fe8ccc3fec1d259295002d Mon Sep 17 00:00:00 2001 From: Marc Morera Date: Fri, 25 Jun 2021 00:38:50 +0200 Subject: [PATCH] Support for php8 --- .circleci/config.yml | 26 +++++--------- .circleci/start.sh | 6 ++++ .circleci/start_base_testsuite.sh | 6 ++++ Console/CommandConsumerCommand.php | 11 ++---- Console/DebugCommandBusCommand.php | 2 +- Console/InfrastructureCheckCommand.php | 2 +- Console/InfrastructureCreateCommand.php | 2 +- Console/InfrastructureDropCommand.php | 2 +- .../CompilerPass/BusCompilerPass.php | 2 +- Tests/Async/AsyncAdapterTest.php | 36 +++++++++---------- Tests/BusFunctionalTest.php | 2 +- Tests/Console/CommandsListTest.php | 4 +-- .../InvalidMiddlewareExceptionTest.php | 2 +- composer.json | 8 ++--- phpunit.xml | 3 +- 15 files changed, 55 insertions(+), 59 deletions(-) create mode 100755 .circleci/start.sh create mode 100755 .circleci/start_base_testsuite.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index ee385a6..a160d44 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,8 +1,8 @@ version: 2 jobs: - test-php73: + test-php74: docker: - - image: circleci/php:7.3-cli + - image: circleci/php:7.4-cli - image: redis - image: rabbitmq - image: postgres:alpine @@ -19,20 +19,11 @@ jobs: name: Run tests / Symfony 4^4 command: | composer update -n --prefer-dist --prefer-lowest --no-suggest - rm -Rf var/* - php vendor/bin/phpunit - - - run: - name: Run tests / Symfony 5^0 - command: | - composer update -n --prefer-dist --no-suggest - rm -Rf var/* - php vendor/bin/phpunit - + sh .circleci/start.sh - test-php74: + test-php80: docker: - - image: circleci/php:7.4-cli + - image: circleci/php:8.0-cli - image: redis - image: rabbitmq - image: postgres:alpine @@ -49,12 +40,11 @@ jobs: name: Run tests / Symfony 5^0 command: | composer update -n --prefer-dist --no-suggest - rm -Rf var/* - php vendor/bin/phpunit --testsuite=base + sh .circleci/start_base_testsuite.sh workflows: version: 2 test: jobs: - - test-php73 - - test-php74 \ No newline at end of file + - test-php74 + - test-php80 diff --git a/.circleci/start.sh b/.circleci/start.sh new file mode 100755 index 0000000..4dbb132 --- /dev/null +++ b/.circleci/start.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +while ! nc -z localhost 5672; do sleep 1; done +while ! nc -z localhost 5432; do sleep 1; done +while ! nc -z localhost 6379; do sleep 1; done +php vendor/bin/phpunit diff --git a/.circleci/start_base_testsuite.sh b/.circleci/start_base_testsuite.sh new file mode 100755 index 0000000..70bd2ec --- /dev/null +++ b/.circleci/start_base_testsuite.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +while ! nc -z localhost 5672; do sleep 1; done +while ! nc -z localhost 5432; do sleep 1; done +while ! nc -z localhost 6379; do sleep 1; done +php vendor/bin/phpunit --testsuite=base diff --git a/Console/CommandConsumerCommand.php b/Console/CommandConsumerCommand.php index 8beaded..82f7e01 100644 --- a/Console/CommandConsumerCommand.php +++ b/Console/CommandConsumerCommand.php @@ -39,11 +39,6 @@ class CommandConsumerCommand extends Command */ private $commandBus; - /** - * @var LoopInterface - */ - private $loop; - /** * ConsumeCommand constructor. * @@ -53,14 +48,12 @@ class CommandConsumerCommand extends Command */ public function __construct( AsyncAdapter $asyncAdapter, - InlineCommandBus $commandBus, - LoopInterface $loop + InlineCommandBus $commandBus ) { parent::__construct(); $this->asyncAdapter = $asyncAdapter; $this->commandBus = $commandBus; - $this->loop = $loop; } /** @@ -90,7 +83,7 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { - $outputPrinter = new OutputPrinter($output); + $outputPrinter = new OutputPrinter($output, false, false); $adapterName = $this->asyncAdapter->getName(); (new CommandBusHeaderMessage('', 'Consumer built'))->print($outputPrinter); (new CommandBusHeaderMessage('', 'Using adapter '.$adapterName))->print($outputPrinter); diff --git a/Console/DebugCommandBusCommand.php b/Console/DebugCommandBusCommand.php index 31c50ce..767d306 100644 --- a/Console/DebugCommandBusCommand.php +++ b/Console/DebugCommandBusCommand.php @@ -50,7 +50,7 @@ class DebugCommandBusCommand extends Command * BusDebugger constructor. * * @param CommandBus $commandBus - * @param InlineCommandBus $commandBus + * @param InlineCommandBus $inlineCommandBus * @param QueryBus $queryBus */ public function __construct( diff --git a/Console/InfrastructureCheckCommand.php b/Console/InfrastructureCheckCommand.php index 88bee49..b3681fd 100644 --- a/Console/InfrastructureCheckCommand.php +++ b/Console/InfrastructureCheckCommand.php @@ -74,7 +74,7 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { - $outputPrinter = new OutputPrinter($output); + $outputPrinter = new OutputPrinter($output, false, false); $adapterName = $this->asyncAdapter->getName(); (new CommandBusHeaderMessage('', 'Started checking infrastructure...'))->print($outputPrinter); (new CommandBusHeaderMessage('', 'Using adapter '.$adapterName))->print($outputPrinter); diff --git a/Console/InfrastructureCreateCommand.php b/Console/InfrastructureCreateCommand.php index b219666..6782c09 100644 --- a/Console/InfrastructureCreateCommand.php +++ b/Console/InfrastructureCreateCommand.php @@ -81,7 +81,7 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { - $outputPrinter = new OutputPrinter($output); + $outputPrinter = new OutputPrinter($output, false, false); if (!$input->getOption('force')) { (new CommandBusHeaderMessage('', 'Please, use the flag --force'))->print($outputPrinter); diff --git a/Console/InfrastructureDropCommand.php b/Console/InfrastructureDropCommand.php index a90b38d..29d11e7 100644 --- a/Console/InfrastructureDropCommand.php +++ b/Console/InfrastructureDropCommand.php @@ -81,7 +81,7 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { - $outputPrinter = new OutputPrinter($output); + $outputPrinter = new OutputPrinter($output, false, false); if (!$input->getOption('force')) { (new CommandBusHeaderMessage('', 'Please, use the flag --force'))->print($outputPrinter); diff --git a/DependencyInjection/CompilerPass/BusCompilerPass.php b/DependencyInjection/CompilerPass/BusCompilerPass.php index 279d130..ad8d97f 100644 --- a/DependencyInjection/CompilerPass/BusCompilerPass.php +++ b/DependencyInjection/CompilerPass/BusCompilerPass.php @@ -341,7 +341,7 @@ private function createHandlersMap( } $reflectionParameter = $reflectionMethod->getParameters()[0]; - $handlersMap[$reflectionParameter->getClass()->getName()] = [new Reference($serviceId), $reflectionMethod->getName()]; + $handlersMap[$reflectionParameter->getType()->getName()] = [new Reference($serviceId), $reflectionMethod->getName()]; } return $handlersMap; diff --git a/Tests/Async/AsyncAdapterTest.php b/Tests/Async/AsyncAdapterTest.php index 59ba803..fe37604 100644 --- a/Tests/Async/AsyncAdapterTest.php +++ b/Tests/Async/AsyncAdapterTest.php @@ -91,16 +91,16 @@ abstract protected static function getAsyncConfiguration(): array; public function testInfrastructure() { $output = $this->dropInfrastructure(); - $this->assertContains('dropped', $output); + $this->assertStringContainsString('dropped', $output); $output = $this->createInfrastructure(); - $this->assertContains('created properly', $output); + $this->assertStringContainsString('created properly', $output); $output = $this->checkInfrastructure(); - $this->assertContains('exists', $output); + $this->assertStringContainsString('exists', $output); $output = $this->dropInfrastructure(); - $this->assertContains('dropped', $output); + $this->assertStringContainsString('dropped', $output); } /** @@ -134,8 +134,8 @@ public function test1Command() $this->assertFalse(file_exists('/tmp/a.thing')); $output = $this->consumeCommands(1); - $this->assertContains("\033[01;32mConsumed\033[0m ChangeAThing", $output); - $this->assertNotContains("\033[01;32mConsumed\033[0m ChangeAnotherThing", $output); + $this->assertStringContainsString("\033[01;32mConsumed\033[0m ChangeAThing", $output); + $this->assertStringNotContainsString("\033[01;32mConsumed\033[0m ChangeAnotherThing", $output); if ($this instanceof InMemoryAsyncTest) { $this->assertTrue($this->getContextValue('middleware1')); } @@ -143,9 +143,9 @@ public function test1Command() $this->assertTrue(file_exists('/tmp/a.thing')); $output2 = $this->consumeCommands(1); - $this->assertNotContains("\033[01;32mConsumed\033[0m ChangeAThing", $output2); - $this->assertContains("\033[01;36mIgnored \033[0m ChangeBThing", $output2); - $this->assertContains("\033[01;32mConsumed\033[0m ChangeAnotherThing", $output2); + $this->assertStringNotContainsString("\033[01;32mConsumed\033[0m ChangeAThing", $output2); + $this->assertStringContainsString("\033[01;36mIgnored \033[0m ChangeBThing", $output2); + $this->assertStringContainsString("\033[01;32mConsumed\033[0m ChangeAnotherThing", $output2); } /** @@ -171,14 +171,14 @@ public function test2Commands() $output = $this->consumeCommands(2); - $this->assertContains("\033[01;32mConsumed\033[0m ChangeAThing", $output); - $this->assertContains("\033[01;32mConsumed\033[0m ChangeAnotherThing", $output); - $this->assertNotContains("\033[01;32mConsumed\033[0m ChangeYetAnotherThing", $output); + $this->assertStringContainsString("\033[01;32mConsumed\033[0m ChangeAThing", $output); + $this->assertStringContainsString("\033[01;32mConsumed\033[0m ChangeAnotherThing", $output); + $this->assertStringNotContainsString("\033[01;32mConsumed\033[0m ChangeYetAnotherThing", $output); $output = $this->consumeCommands(1); - $this->assertNotContains("\033[01;32mConsumed\033[0m ChangeAThing", $output); - $this->assertNotContains("\033[01;32mConsumed\033[0m ChangeAnotherThing", $output); - $this->assertContains("\033[01;32mConsumed\033[0m ChangeYetAnotherThing", $output); + $this->assertStringNotContainsString("\033[01;32mConsumed\033[0m ChangeAThing", $output); + $this->assertStringNotContainsString("\033[01;32mConsumed\033[0m ChangeAnotherThing", $output); + $this->assertStringContainsString("\033[01;32mConsumed\033[0m ChangeYetAnotherThing", $output); } /** @@ -213,9 +213,9 @@ public function testAsyncCommands() awaitAll($promises, $this->getLoop()); usleep(200000); $output = $process->getOutput(); - $this->assertContains("\033[01;32mConsumed\033[0m ChangeAThing", $output); - $this->assertContains("\033[01;32mConsumed\033[0m ChangeAnotherThing", $output); - $this->assertContains("\033[01;32mConsumed\033[0m ChangeYetAnotherThing", $output); + $this->assertStringContainsString("\033[01;32mConsumed\033[0m ChangeAThing", $output); + $this->assertStringContainsString("\033[01;32mConsumed\033[0m ChangeAnotherThing", $output); + $this->assertStringContainsString("\033[01;32mConsumed\033[0m ChangeYetAnotherThing", $output); $process->stop(); } diff --git a/Tests/BusFunctionalTest.php b/Tests/BusFunctionalTest.php index 0acbb34..0f77bb5 100644 --- a/Tests/BusFunctionalTest.php +++ b/Tests/BusFunctionalTest.php @@ -41,7 +41,7 @@ abstract class BusFunctionalTest extends BaseFunctionalTest * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { self::$output = new BufferedOutput(); parent::setUpBeforeClass(); diff --git a/Tests/Console/CommandsListTest.php b/Tests/Console/CommandsListTest.php index 97ad7ed..6c5cca8 100644 --- a/Tests/Console/CommandsListTest.php +++ b/Tests/Console/CommandsListTest.php @@ -56,7 +56,7 @@ public function testCommandsList() '', ]); - $this->assertContains('debug:command-bus', $output); - $this->assertContains('bus:consume-commands', $output); + $this->assertStringContainsString('debug:command-bus', $output); + $this->assertStringContainsString('bus:consume-commands', $output); } } diff --git a/Tests/Middleware/InvalidMiddlewareExceptionTest.php b/Tests/Middleware/InvalidMiddlewareExceptionTest.php index af1d73a..2a4ba7a 100644 --- a/Tests/Middleware/InvalidMiddlewareExceptionTest.php +++ b/Tests/Middleware/InvalidMiddlewareExceptionTest.php @@ -48,7 +48,7 @@ protected static function decorateConfiguration(array $configuration): array * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { try { parent::setUpBeforeClass(); diff --git a/composer.json b/composer.json index 40ae6e2..6a41a69 100644 --- a/composer.json +++ b/composer.json @@ -11,13 +11,13 @@ } ], "require": { - "php": "^7.3", + "php": "^7.4 || ^8", "symfony/console": "^5.0.0", "symfony/dependency-injection": "^5.0.0", "symfony/proxy-manager-bridge": "^5.0.0", - "mmoreram/base-bundle": "^2.1.2", + "mmoreram/base-bundle": "^2.3", "drift/http-kernel": "0.1.*, >=0.1.5", "drift/console-bridge": "0.1.*", "drift/event-loop-utils": "0.1.*", @@ -28,7 +28,7 @@ "drift/amqp-bundle": "0.1.*, >=0.1.2", "drift/postgresql-bundle": "0.1.*, >=0.1.2", "symfony/process": "^5.0.0", - "phpunit/phpunit": "7.5.17" + "phpunit/phpunit": "^9" }, "suggest": { "drift/redis-bundle": "Install this bundle to use Redis as a queue system", @@ -45,4 +45,4 @@ "Drift\\CommandBus\\Tests\\": "Tests/" } } -} \ No newline at end of file +} diff --git a/phpunit.xml b/phpunit.xml index 5eeb145..fd00271 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -6,6 +6,7 @@ convertErrorsToExceptions="false" convertNoticesToExceptions="false" convertWarningsToExceptions="false" + convertDeprecationsToExceptions="false" processIsolation="false" stopOnFailure="true" bootstrap="vendor/autoload.php" @@ -15,4 +16,4 @@ Tests - \ No newline at end of file +