From 22b44e251fdf4c7a41a3ac85f4150addd9e82660 Mon Sep 17 00:00:00 2001 From: GDIBass Date: Thu, 17 Aug 2017 23:37:10 -0700 Subject: [PATCH] Changed automatic token generation to throw an exception instead --- .../Component/Workflow/EventListener/GuardListener.php | 3 +-- .../Workflow/Tests/EventListener/GuardListenerTest.php | 8 ++------ 2 files changed, 3 insertions(+), 8 deletions(-) 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()