Skip to content

Commit

Permalink
Merge pull request #58 from nusje2000/feature/symfony-update
Browse files Browse the repository at this point in the history
Allow symfony ^5.0
  • Loading branch information
aeviiq authored Jul 21, 2020
2 parents 105c528 + 7322c5e commit b158ffe
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"aeviiq/collection": "^3.2",
"aeviiq/storage-manager": "^3.0",
"aeviiq/enum": "^2.0",
"symfony/form": "^4.3",
"symfony/event-dispatcher": "^4.3",
"symfony/http-foundation": "^4.3"
"symfony/form": "^4.3|^5.0",
"symfony/http-foundation": "^4.3|^5.0",
"symfony/event-dispatcher-contracts": "^1.0|^2.0"
},
"require-dev": {
"phpunit/phpunit": "^8.2"
Expand Down
2 changes: 1 addition & 1 deletion src/Transitioner.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
use Aeviiq\FormFlow\Event\TransitionEvent;
use Aeviiq\FormFlow\Exception\LogicException;
use Aeviiq\FormFlow\Exception\TransitionException;
use Symfony\Component\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 Transitioner implements TransitionerInterface, RequestStackAwareInterface
{
Expand Down
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\Component\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 b158ffe

Please sign in to comment.