Skip to content

Commit

Permalink
Fixed unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
nusje2000 committed Jul 18, 2020
1 parent 71ab7a3 commit 7322c5e
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions tests/TransitionerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Constraint\Callback;
use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\Constraint\IsInstanceOf;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request as HttpRequest;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

final class TransitionerTest extends TestCase
{
Expand Down Expand Up @@ -123,10 +122,12 @@ public function testTransitionForwardsWithHardSkip(): void
[$this->assertFlowEvent(TransitionedEvent::class), 'form_flow.post_forwards.group-1'],
[$this->assertFlowEvent(TransitionedEvent::class), 'form_flow.post_forwards.some-name'],
[$this->assertFlowEvent(TransitionedEvent::class), 'form_flow.post_forwards']
)->willReturnCallback(static function (Event $event, string $eventName): void {
)->willReturnCallback(static function (Event $event, string $eventName): object {
if ($event instanceof SkipEvent && 'form_flow.skip.some-name.step_1' === $eventName) {
$event->hardSkip();
}

return $event;
});

$status = $this->transitioner->transition($this->flow);
Expand All @@ -152,10 +153,12 @@ public function testTransitionForwardsWithSoftSkip(): void
[$this->assertFlowEvent(TransitionedEvent::class), 'form_flow.post_forwards.group-1'],
[$this->assertFlowEvent(TransitionedEvent::class), 'form_flow.post_forwards.some-name'],
[$this->assertFlowEvent(TransitionedEvent::class), 'form_flow.post_forwards']
)->willReturnCallback(static function (Event $event, string $eventName): void {
)->willReturnCallback(static function (Event $event, string $eventName): object {
if ($event instanceof SkipEvent && 'form_flow.skip.some-name.step_1' === $eventName) {
$event->softSkip();
}

return $event;
});

$status = $this->transitioner->transition($this->flow);
Expand All @@ -174,11 +177,13 @@ public function testTransitionForwardWithHardAndSoftSkip(): void
[$this->assertFlowEvent(TransitionEvent::class), 'form_flow.pre_forwards.some-name'],
[$this->assertFlowEvent(TransitionEvent::class), 'form_flow.pre_forwards'],
[$this->assertFlowEvent(SkipEvent::class), 'form_flow.skip.some-name.step_1']
)->willReturnCallback(static function (Event $event, string $eventName): void {
)->willReturnCallback(static function (Event $event, string $eventName): object {
if ($event instanceof SkipEvent && 'form_flow.skip.some-name.step_1' === $eventName) {
$event->hardSkip();
$event->softSkip();
}

return $event;
});

$this->expectException(LogicException::class);
Expand Down Expand Up @@ -217,8 +222,10 @@ public function testTransitionFormwardWithBlockedTransition(): void
[$this->assertFlowEvent(TransitionEvent::class), 'form_flow.pre_forwards.group-1'],
[$this->assertFlowEvent(TransitionEvent::class), 'form_flow.pre_forwards.some-name'],
[$this->assertFlowEvent(TransitionEvent::class), 'form_flow.pre_forwards']
)->willReturnCallback(static function (TransitionEvent $event): void {
)->willReturnCallback(static function (TransitionEvent $event): object {
$event->blockTransition();

return $event;
});

$status = $this->transitioner->transition($this->flow);
Expand Down Expand Up @@ -271,8 +278,10 @@ public function testTransitionBackwardsWithBlockedTransition(): void
[$this->assertFlowEvent(TransitionEvent::class), 'form_flow.pre_backwards.group-1'],
[$this->assertFlowEvent(TransitionEvent::class), 'form_flow.pre_backwards.some-name'],
[$this->assertFlowEvent(TransitionEvent::class), 'form_flow.pre_backwards']
)->willReturnCallback(static function (TransitionEvent $event): void {
)->willReturnCallback(static function (TransitionEvent $event): object {
$event->blockTransition();

return $event;
});

$status = $this->transitioner->transition($this->flow);
Expand Down Expand Up @@ -326,8 +335,10 @@ public function testTransitionCompleteWithBlockedTransition(): void
[$this->assertFlowEvent(TransitionEvent::class), 'form_flow.pre_complete.group-1'],
[$this->assertFlowEvent(TransitionEvent::class), 'form_flow.pre_complete.some-name'],
[$this->assertFlowEvent(TransitionEvent::class), 'form_flow.pre_complete']
)->willReturnCallback(static function (TransitionEvent $event): void {
)->willReturnCallback(static function (TransitionEvent $event): object {
$event->blockTransition();

return $event;
});

$status = $this->transitioner->transition($this->flow);
Expand Down

0 comments on commit 7322c5e

Please sign in to comment.