Skip to content

Commit

Permalink
Test dispatch too short steps
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed Apr 10, 2022
1 parent 9311832 commit c4044cb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
12 changes: 10 additions & 2 deletions tests/Reducer/DispatcherTestCase.php
Expand Up @@ -28,6 +28,14 @@ protected function setUp(): void
$this->bug->setSteps(array_map(fn () => $this->createMock(StepInterface::class), range(1, 11)));
}

public function testDispatchTooShortSteps(): void
{
$this->bug->setSteps([$this->createMock(StepInterface::class)]);
$this->messageBus->expects($this->never())->method('dispatch');
$this->assertSame(0, $this->dispatcher->dispatch($this->bug));
$this->assertPairs(0);
}

public function testDispatch(): void
{
$this->messageBus
Expand Down Expand Up @@ -63,8 +71,8 @@ protected function assertMessage(): Callback
});
}

protected function assertPairs(): void
protected function assertPairs(int $count = 4): void
{
$this->assertCount(4, $this->pairs);
$this->assertCount($count, $this->pairs);
}
}
18 changes: 10 additions & 8 deletions tests/Reducer/Split/SplitDispatcherTest.php
Expand Up @@ -22,14 +22,16 @@ protected function setUp(): void
$this->dispatcher = new SplitDispatcher($this->messageBus);
}

protected function assertPairs(): void
protected function assertPairs(int $count = 4): void
{
parent::assertPairs();
$this->assertSame([
[0, 3],
[3, 6],
[6, 9],
[9, 10],
], $this->pairs);
parent::assertPairs($count);
if (4 === $count) {
$this->assertSame([
[0, 3],
[3, 6],
[6, 9],
[9, 10],
], $this->pairs);
}
}
}

0 comments on commit c4044cb

Please sign in to comment.