24
24
use Symfony \Component \Routing \Generator \UrlGeneratorInterface ;
25
25
use Symfony \Component \Routing \Matcher \UrlMatcherInterface ;
26
26
use Symfony \Component \Routing \RequestContext ;
27
+ use Symfony \Contracts \EventDispatcher \EventDispatcherInterface as ContractsEventDispatcherInterface ;
27
28
28
29
class DynamicRouterTest extends TestCase
29
30
{
@@ -62,7 +63,7 @@ class DynamicRouterTest extends TestCase
62
63
*/
63
64
private $ eventDispatcher ;
64
65
65
- public function setUp ()
66
+ public function setUp (): void
66
67
{
67
68
$ this ->matcher = $ this ->createMock (UrlMatcherInterface::class);
68
69
$ this ->matcher ->expects ($ this ->once ())
@@ -95,9 +96,15 @@ private function assertRequestAttributes($request)
95
96
*/
96
97
public function testMatch ()
97
98
{
99
+ $ dispatchParams = [Events::PRE_DYNAMIC_MATCH , $ this ->equalTo (new RouterMatchEvent ())];
100
+ if ($ this ->eventDispatcher instanceof ContractsEventDispatcherInterface) {
101
+ // New Symfony 4.3 EventDispatcher signature
102
+ $ dispatchParams = [$ this ->equalTo (new RouterMatchEvent ()), Events::PRE_DYNAMIC_MATCH ];
103
+ }
104
+
98
105
$ this ->eventDispatcher ->expects ($ this ->once ())
99
106
->method ('dispatch ' )
100
- ->with (Events:: PRE_DYNAMIC_MATCH , $ this -> equalTo ( new RouterMatchEvent ()) )
107
+ ->with (... $ dispatchParams )
101
108
;
102
109
103
110
$ parameters = $ this ->router ->match ('/foo ' );
@@ -108,9 +115,15 @@ public function testMatch()
108
115
109
116
public function testMatchRequest ()
110
117
{
118
+ $ dispatchParams = [Events::PRE_DYNAMIC_MATCH_REQUEST , $ this ->equalTo (new RouterMatchEvent ($ this ->request ))];
119
+ if ($ this ->eventDispatcher instanceof ContractsEventDispatcherInterface) {
120
+ // New Symfony 4.3 EventDispatcher signature
121
+ $ dispatchParams = [$ this ->equalTo (new RouterMatchEvent ($ this ->request )), Events::PRE_DYNAMIC_MATCH_REQUEST ];
122
+ }
123
+
111
124
$ this ->eventDispatcher ->expects ($ this ->once ())
112
125
->method ('dispatch ' )
113
- ->with (Events:: PRE_DYNAMIC_MATCH_REQUEST , $ this -> equalTo ( new RouterMatchEvent ( $ this -> request )) )
126
+ ->with (... $ dispatchParams )
114
127
;
115
128
116
129
$ parameters = $ this ->router ->matchRequest ($ this ->request );
@@ -126,9 +139,15 @@ public function testMatchNoRequest()
126
139
{
127
140
$ this ->router ->setRequestStack (new RequestStack ());
128
141
142
+ $ dispatchParams = [Events::PRE_DYNAMIC_MATCH , $ this ->equalTo (new RouterMatchEvent ())];
143
+ if ($ this ->eventDispatcher instanceof ContractsEventDispatcherInterface) {
144
+ // New Symfony 4.3 EventDispatcher signature
145
+ $ dispatchParams = [$ this ->equalTo (new RouterMatchEvent ()), Events::PRE_DYNAMIC_MATCH ];
146
+ }
147
+
129
148
$ this ->eventDispatcher ->expects ($ this ->once ())
130
149
->method ('dispatch ' )
131
- ->with (Events:: PRE_DYNAMIC_MATCH , $ this -> equalTo ( new RouterMatchEvent ()) )
150
+ ->with (... $ dispatchParams )
132
151
;
133
152
134
153
$ this ->expectException (ResourceNotFoundException::class);
0 commit comments