diff --git a/src/Symfony/Component/Workflow/EventListener/GuardListener.php b/src/Symfony/Component/Workflow/EventListener/GuardListener.php index e0c29876af..798af6ae61 100644 --- a/src/Symfony/Component/Workflow/EventListener/GuardListener.php +++ b/src/Symfony/Component/Workflow/EventListener/GuardListener.php @@ -57,8 +57,7 @@ class GuardListener $token = $this->tokenStorage->getToken(); if (null === $token) { - $token = new AnonymousToken('secret', 'anon', array()); - $this->tokenStorage->setToken($token); + throw new \Exception("No token is set"); } if (null !== $this->roleHierarchy) { diff --git a/src/Symfony/Component/Workflow/Tests/EventListener/GuardListenerTest.php b/src/Symfony/Component/Workflow/Tests/EventListener/GuardListenerTest.php index 50481654e5..d72e319313 100644 --- a/src/Symfony/Component/Workflow/Tests/EventListener/GuardListenerTest.php +++ b/src/Symfony/Component/Workflow/Tests/EventListener/GuardListenerTest.php @@ -74,13 +74,9 @@ class GuardListenerTest extends TestCase $event = $this->createEvent(); $this->tokenStorage = null; + $this->expectException(\Exception::class); + $this->listener->onTransition($event, 'event_name_a'); - - $this->assertFalse($event->isBlocked()); - - $this->listener->onTransition($event, 'event_name_b'); - - $this->assertTrue($event->isBlocked()); } private function createEvent()