Skip to content

Commit

Permalink
Merge pull request #329 from prooph/tests_for_projections
Browse files Browse the repository at this point in the history
add test cases for multiple calls to reset/stop/delete projection
  • Loading branch information
prolic committed Mar 25, 2018
2 parents 88a296a + 176e977 commit 354c251
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/Projection/AbstractProjectionManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,49 @@ public function it_throws_exception_when_trying_to_stop_non_existing_projection(

$this->projectionManager->stopProjection('unknown');
}

/**
* @test
*/
public function it_does_not_fail_deleting_twice(): void
{
$projection = $this->projectionManager->createProjection('test-projection');
$projection->fromAll()->whenAny(function (): void {
})->run(false);

$this->projectionManager->deleteProjection('test-projection', false);
$this->projectionManager->deleteProjection('test-projection', false);

$this->assertTrue($this->projectionManager->fetchProjectionStatus('test-projection')->is(ProjectionStatus::DELETING()));
}

/**
* @test
*/
public function it_does_not_fail_resetting_twice(): void
{
$projection = $this->projectionManager->createProjection('test-projection');
$projection->fromAll()->whenAny(function (): void {
})->run(false);

$this->projectionManager->resetProjection('test-projection');
$this->projectionManager->resetProjection('test-projection');

$this->assertTrue($this->projectionManager->fetchProjectionStatus('test-projection')->is(ProjectionStatus::RESETTING()));
}

/**
* @test
*/
public function it_does_not_fail_stopping_twice(): void
{
$projection = $this->projectionManager->createProjection('test-projection');
$projection->fromAll()->whenAny(function (): void {
})->run(false);

$this->projectionManager->stopProjection('test-projection');
$this->projectionManager->stopProjection('test-projection');

$this->assertTrue($this->projectionManager->fetchProjectionStatus('test-projection')->is(ProjectionStatus::STOPPING()));
}
}
24 changes: 24 additions & 0 deletions tests/Projection/InMemoryProjectionManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,28 @@ public function it_throws_exception_when_trying_to_stop_non_existing_projection(
{
$this->markTestSkipped('Stopping a projection is not supported in ' . InMemoryProjectionManager::class);
}

/**
* @test
*/
public function it_does_not_fail_deleting_twice(): void
{
$this->markTestSkipped('Deleting a projection is not supported in ' . InMemoryProjectionManager::class);
}

/**
* @test
*/
public function it_does_not_fail_resetting_twice(): void
{
$this->markTestSkipped('Resetting a projection is not supported in ' . InMemoryProjectionManager::class);
}

/**
* @test
*/
public function it_does_not_fail_stopping_twice(): void
{
$this->markTestSkipped('Stopping a projection is not supported in ' . InMemoryProjectionManager::class);
}
}

0 comments on commit 354c251

Please sign in to comment.