Skip to content

Commit

Permalink
Update PdoEventStoreProjector & PdoEventStoreReadModelProjector as we…
Browse files Browse the repository at this point in the history
…ll as tests based on [email protected] changes
  • Loading branch information
fritz-gerneth committed Jul 1, 2017
1 parent 3f995ad commit 2514676
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 25 deletions.
4 changes: 0 additions & 4 deletions src/Projection/PdoEventStoreProjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@

final class PdoEventStoreProjector implements Projector
{
public const OPTION_PCNTL_DISPATCH = 'trigger_pcntl_dispatch';

public const DEFAULT_PCNTL_DISPATCH = false;

private const UNIQUE_VIOLATION_ERROR_CODES = [
'pgsql' => '23505',
'mysql' => '23000',
Expand Down
4 changes: 0 additions & 4 deletions src/Projection/PdoEventStoreReadModelProjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@

final class PdoEventStoreReadModelProjector implements ReadModelProjector
{
public const OPTION_PCNTL_DISPATCH = 'trigger_pcntl_dispatch';

public const DEFAULT_PCNTL_DISPATCH = false;

/**
* @var EventStore
*/
Expand Down
13 changes: 6 additions & 7 deletions tests/Projection/PdoEventStoreProjectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,13 @@ public function it_throws_exception_when_unknown_event_store_instance_passed():
*/
public function it_dispatches_pcntl_signals_when_enabled(): void
{
if (!extension_loaded('pcntl')) {
if (! extension_loaded('pcntl')) {
$this->markTestSkipped('The PCNTL extension is not available.');
}

$this->prepareEventStream('user-123');
$this->connection->exec('DROP TABLE projections;');
return;
}

$command = 'php ' . realpath(__DIR__) . '/isolated-projection.php';
$command = 'exec php ' . realpath(__DIR__) . '/isolated-projection.php';
$descriptorSpec = [
0 => ['pipe', 'r'],
1 => ['pipe', 'w'],
Expand All @@ -193,9 +192,9 @@ public function it_dispatches_pcntl_signals_when_enabled(): void
*/
$projectionProcess = proc_open($command, $descriptorSpec, $pipes);
$processDetails = proc_get_status($projectionProcess);
sleep(2);
sleep(1);
posix_kill($processDetails['pid'], SIGQUIT);
sleep(2);
sleep(1);

$processDetails = proc_get_status($projectionProcess);
$this->assertEquals(
Expand Down
13 changes: 6 additions & 7 deletions tests/Projection/PdoEventStoreReadModelProjectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,13 @@ public function it_throws_exception_when_unknown_event_store_instance_passed():
*/
public function it_dispatches_pcntl_signals_when_enabled(): void
{
if (!extension_loaded('pcntl')) {
if (! extension_loaded('pcntl')) {
$this->markTestSkipped('The PCNTL extension is not available.');
}

$this->prepareEventStream('user-123');
$this->connection->exec('DROP TABLE projections;');
return;
}

$command = 'php ' . realpath(__DIR__) . '/isolated-read-model-projection.php';
$command = 'exec php ' . realpath(__DIR__) . '/isolated-read-model-projection.php';
$descriptorSpec = [
0 => ['pipe', 'r'],
1 => ['pipe', 'w'],
Expand All @@ -216,9 +215,9 @@ public function it_dispatches_pcntl_signals_when_enabled(): void
*/
$projectionProcess = proc_open($command, $descriptorSpec, $pipes);
$processDetails = proc_get_status($projectionProcess);
sleep(2);
sleep(1);
posix_kill($processDetails['pid'], SIGQUIT);
sleep(2);
sleep(1);

$processDetails = proc_get_status($projectionProcess);
$this->assertEquals(
Expand Down
4 changes: 3 additions & 1 deletion tests/Projection/isolated-projection.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Prooph\Common\Messaging\FQCNMessageFactory;
use Prooph\EventStore\Pdo\MySqlEventStore;
use Prooph\EventStore\Pdo\PersistenceStrategy\MySqlSimpleStreamStrategy;
Expand All @@ -26,7 +28,7 @@
$projection = $projectionManager->createProjection(
'test_projection',
[
PdoEventStoreProjector::OPTION_PCNTL_DISPATCH => true
PdoEventStoreProjector::OPTION_PCNTL_DISPATCH => true,
]
);
pcntl_signal(SIGQUIT, function () use ($projection) {
Expand Down
7 changes: 5 additions & 2 deletions tests/Projection/isolated-read-model-projection.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<?php

declare(strict_types=1);

use Prooph\Common\Messaging\FQCNMessageFactory;
use Prooph\EventStore\Pdo\MySqlEventStore;
use Prooph\EventStore\Pdo\PersistenceStrategy\MySqlSimpleStreamStrategy;
use Prooph\EventStore\Pdo\Projection\MySqlProjectionManager;
use Prooph\EventStore\Pdo\Projection\PdoEventStoreProjector;
use Prooph\EventStore\Projection\ReadModel;
use ProophTest\EventStore\Mock\UserCreated;
use ProophTest\EventStore\Pdo\TestUtil;

require __DIR__ . '/../../vendor/autoload.php';

$readModel = new class() implements \Prooph\EventStore\Projection\ReadModel {
$readModel = new class() implements ReadModel {
public function init(): void
{
}
Expand Down Expand Up @@ -54,7 +57,7 @@ public function persist(): void
'test_projection',
$readModel,
[
PdoEventStoreProjector::OPTION_PCNTL_DISPATCH => true
PdoEventStoreProjector::OPTION_PCNTL_DISPATCH => true,
]
);
pcntl_signal(SIGQUIT, function () use ($projection) {
Expand Down

0 comments on commit 2514676

Please sign in to comment.