Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoreram committed Mar 8, 2020
1 parent 8042db0 commit 114a4ab
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 31 deletions.
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ jobs:
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
test-php74:
docker:
Expand Down
13 changes: 7 additions & 6 deletions Tests/RouteFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,10 @@ public function testRouteConnection()
{
$this->setupInfrastructure();
$loop = $this->get('reactphp.event_loop');
$inputServer = new InputStream();
$websocketServer = $this->createSocketServer('8001', $inputServer);
$websocketServer = $this->createSocketServer('8001');
sleep(1);
$input1 = new InputStream();
$conn1 = $this->connectToSocket('8001', $input1);
$input2 = new InputStream();
$conn2 = $this->connectToSocket('8001', $input2);
$conn1 = $this->connectToSocket('8001');
$conn2 = $this->connectToSocket('8001');
sleep(1);

$promise = $this->get('drit.event_bus.public')->dispatch(new TestEvent());
Expand All @@ -72,5 +69,9 @@ public function testRouteConnection()
$this->assertContains(TestEvent::class, $conn1->getOutput());
$this->assertContains('Opened connection', $conn2->getOutput());
$this->assertContains(TestEvent::class, $conn2->getOutput());

$websocketServer->stop();
$conn1->stop();
$conn2->stop();
}
}
31 changes: 8 additions & 23 deletions Tests/WebsocketFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

namespace Drift\Websocket\Tests;

use Drift\AMQP\AMQPBundle;
use Drift\EventBus\Bus\EventBus;
use Drift\Websocket\WebsocketBundle;
use Mmoreram\BaseBundle\Kernel\DriftBaseKernel;
Expand Down Expand Up @@ -64,21 +63,14 @@ protected static function getKernel(): KernelInterface
'alias' => EventBus::class,
],
],
'amqp' => [
'clients' => [
'main' => [
'host' => 'localhost',
],
],
],
'event_bus' => [
'exchanges' => [
'events' => 'events',
],
'async_adapter' => [
'adapter' => 'amqp',
'amqp' => [
'client' => 'main',
'host' => 'localhost',
],
],
],
Expand All @@ -94,8 +86,7 @@ protected static function getKernel(): KernelInterface
return new DriftBaseKernel(
[
FrameworkBundle::class,
WebsocketBundle::class,
AMQPBundle::class,
WebsocketBundle::class
],
static::decorateConfiguration($configuration),
[],
Expand All @@ -119,38 +110,32 @@ protected static function decorateConfiguration(array $configuration): array
* Create socket server.
*
* @param string $port
* @param mixed $input
*
* @return Process
*/
protected function createSocketServer(
string $port,
$input
): Process {
protected function createSocketServer(string $port): Process
{
return static::runAsyncCommand([
'websocket:run',
'localhost:'.$port,
'--route=main',
'--exchange=events',
], $input);
]);
}

/**
* Connect to socket.
*
* @param string $port
* @param mixed $input
*
* @return Process
*/
protected function connectToSocket(
string $port,
$input
): Process {
protected function connectToSocket(string $port): Process
{
return static::runAsyncCommand([
'websocket:connect',
'ws://localhost:'.$port,
], $input);
]);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
"clue/stdio-react": "^2.0",

"drift/http-kernel": "0.1.*",
"drift/event-bus-bundle": "0.1.*, >=0.1.3",
"drift/event-bus-bundle": "0.1.*, >=0.1.4",
"mmoreram/base-bundle": "^2.1.2",

"cboden/ratchet": "^0.4",
"ratchet/pawl": "^0.3"
},

"require-dev": {
"drift/amqp-bundle": "0.1.*, >=0.1.1",
"drift/amqp-bundle": "0.1.*, >=0.1.2",
"symfony/process": "^5.0"
},

Expand Down

0 comments on commit 114a4ab

Please sign in to comment.