Skip to content

Commit

Permalink
Merge pull request #28 from driftphp/feature/added-php8
Browse files Browse the repository at this point in the history
Support for php8
  • Loading branch information
mmoreram authored Jun 24, 2021
2 parents 72ce30e + a952175 commit 66739a0
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 59 deletions.
26 changes: 8 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
- test-php74
- test-php80
6 changes: 6 additions & 0 deletions .circleci/start.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions .circleci/start_base_testsuite.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 2 additions & 9 deletions Console/CommandConsumerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ class CommandConsumerCommand extends Command
*/
private $commandBus;

/**
* @var LoopInterface
*/
private $loop;

/**
* ConsumeCommand constructor.
*
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Console/DebugCommandBusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion Console/InfrastructureCheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Console/InfrastructureCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion Console/InfrastructureDropCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/CompilerPass/BusCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
36 changes: 18 additions & 18 deletions Tests/Async/AsyncAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -134,18 +134,18 @@ 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'));
}

$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);
}

/**
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/BusFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions Tests/Console/CommandsListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion Tests/Middleware/InvalidMiddlewareExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.*",
Expand All @@ -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",
Expand All @@ -45,4 +45,4 @@
"Drift\\CommandBus\\Tests\\": "Tests/"
}
}
}
}
3 changes: 2 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
convertErrorsToExceptions="false"
convertNoticesToExceptions="false"
convertWarningsToExceptions="false"
convertDeprecationsToExceptions="false"
processIsolation="false"
stopOnFailure="true"
bootstrap="vendor/autoload.php"
Expand All @@ -15,4 +16,4 @@
<directory>Tests</directory>
</testsuite>
</testsuites>
</phpunit>
</phpunit>

0 comments on commit 66739a0

Please sign in to comment.