File tree Expand file tree Collapse file tree 3 files changed +28
-4
lines changed
src/Symfony/Component/Workflow Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Original file line number Diff line number Diff line change 16
16
use Symfony \Component \Security \Core \Authorization \AuthorizationCheckerInterface ;
17
17
use Symfony \Component \Security \Core \Role \RoleHierarchyInterface ;
18
18
use Symfony \Component \Workflow \Event \GuardEvent ;
19
+ use Symfony \Component \Workflow \Exception \InvalidTokenConfigurationException ;
19
20
20
21
/**
21
22
* @author Grégoire Pineau <lyrixx@lyrixx.info>
@@ -56,7 +57,7 @@ private function getVariables(GuardEvent $event)
56
57
$ token = $ this ->tokenStorage ->getToken ();
57
58
58
59
if (null === $ token ) {
59
- throw new \ Exception ('No token is set ' );
60
+ throw new InvalidTokenConfigurationException ('No token is set ' );
60
61
}
61
62
62
63
if (null !== $ this ->roleHierarchy ) {
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \Component \Workflow \Exception ;
13
+
14
+ /**
15
+ * Thrown by GuardListener when there is no token set, but guards are placed on a transition
16
+ *
17
+ * @author Matt Johnson <matj1985@gmail.com>
18
+ */
19
+ class InvalidTokenConfigurationException extends LogicException implements ExceptionInterface
20
+ {
21
+ }
Original file line number Diff line number Diff line change @@ -69,12 +69,14 @@ public function testWithSupportedEventAndAccept()
69
69
$ this ->assertTrue ($ event ->isBlocked ());
70
70
}
71
71
72
+ /**
73
+ * @expectedException \Symfony\Component\Workflow\Exception\InvalidTokenConfigurationException
74
+ * @expectedExceptionMessage No token is set
75
+ */
72
76
public function testWithNoTokenStorage ()
73
77
{
74
78
$ event = $ this ->createEvent ();
75
- $ this ->tokenStorage = null ;
76
-
77
- $ this ->expectException (\Exception::class);
79
+ $ this ->tokenStorage ->setToken (null );
78
80
79
81
$ this ->listener ->onTransition ($ event , 'event_name_a ' );
80
82
}
You can’t perform that action at this time.
0 commit comments