@@ -104,14 +104,16 @@ public function testDumpWithSimpleLocalizedRoutes()
104
104
105
105
public function testDumpWithRouteNotFoundLocalizedRoutes ()
106
106
{
107
- $ this ->expectException (RouteNotFoundException::class);
108
- $ this ->expectExceptionMessage ('Unable to generate a URL for the named route "test" as such route does not exist. ' );
109
107
$ this ->routeCollection ->add ('test.en ' , (new Route ('/testing/is/fun ' ))->setDefault ('_locale ' , 'en ' )->setDefault ('_canonical_route ' , 'test ' )->setRequirement ('_locale ' , 'en ' ));
110
108
111
109
$ code = $ this ->generatorDumper ->dump ();
112
110
file_put_contents ($ this ->testTmpFilepath , $ code );
113
111
114
112
$ projectUrlGenerator = new CompiledUrlGenerator (require $ this ->testTmpFilepath , new RequestContext ('/app.php ' ), null , 'pl_PL ' );
113
+
114
+ $ this ->expectException (RouteNotFoundException::class);
115
+ $ this ->expectExceptionMessage ('Unable to generate a URL for the named route "test" as such route does not exist. ' );
116
+
115
117
$ projectUrlGenerator ->generate ('test ' );
116
118
}
117
119
@@ -163,22 +165,25 @@ public function testDumpWithTooManyRoutes()
163
165
164
166
public function testDumpWithoutRoutes ()
165
167
{
166
- $ this ->expectException (\InvalidArgumentException::class);
167
168
file_put_contents ($ this ->testTmpFilepath , $ this ->generatorDumper ->dump ());
168
169
169
170
$ projectUrlGenerator = new CompiledUrlGenerator (require $ this ->testTmpFilepath , new RequestContext ('/app.php ' ));
170
171
172
+ $ this ->expectException (\InvalidArgumentException::class);
173
+
171
174
$ projectUrlGenerator ->generate ('Test ' , []);
172
175
}
173
176
174
177
public function testGenerateNonExistingRoute ()
175
178
{
176
- $ this ->expectException (RouteNotFoundException::class);
177
179
$ this ->routeCollection ->add ('Test ' , new Route ('/test ' ));
178
180
179
181
file_put_contents ($ this ->testTmpFilepath , $ this ->generatorDumper ->dump ());
180
182
181
183
$ projectUrlGenerator = new CompiledUrlGenerator (require $ this ->testTmpFilepath , new RequestContext ());
184
+
185
+ $ this ->expectException (RouteNotFoundException::class);
186
+
182
187
$ projectUrlGenerator ->generate ('NonExisting ' , []);
183
188
}
184
189
@@ -267,21 +272,18 @@ public function testAliases()
267
272
268
273
public function testTargetAliasNotExisting ()
269
274
{
270
- $ this ->expectException (RouteNotFoundException::class);
271
-
272
275
$ this ->routeCollection ->addAlias ('a ' , 'not-existing ' );
273
276
274
277
file_put_contents ($ this ->testTmpFilepath , $ this ->generatorDumper ->dump ());
275
278
276
- $ compiledUrlGenerator = new CompiledUrlGenerator ( require $ this ->testTmpFilepath , new RequestContext () );
279
+ $ this ->expectException (RouteNotFoundException::class );
277
280
281
+ $ compiledUrlGenerator = new CompiledUrlGenerator (require $ this ->testTmpFilepath , new RequestContext ());
278
282
$ compiledUrlGenerator ->generate ('a ' );
279
283
}
280
284
281
285
public function testTargetAliasWithNamePrefixNotExisting ()
282
286
{
283
- $ this ->expectException (RouteNotFoundException::class);
284
-
285
287
$ subCollection = new RouteCollection ();
286
288
$ subCollection ->addAlias ('a ' , 'not-existing ' );
287
289
$ subCollection ->addNamePrefix ('sub_ ' );
@@ -290,43 +292,44 @@ public function testTargetAliasWithNamePrefixNotExisting()
290
292
291
293
file_put_contents ($ this ->testTmpFilepath , $ this ->generatorDumper ->dump ());
292
294
293
- $ compiledUrlGenerator = new CompiledUrlGenerator ( require $ this ->testTmpFilepath , new RequestContext () );
295
+ $ this ->expectException (RouteNotFoundException::class );
294
296
297
+ $ compiledUrlGenerator = new CompiledUrlGenerator (require $ this ->testTmpFilepath , new RequestContext ());
295
298
$ compiledUrlGenerator ->generate ('sub_a ' );
296
299
}
297
300
298
301
public function testCircularReferenceShouldThrowAnException ()
299
302
{
300
- $ this ->expectException (RouteCircularReferenceException::class);
301
- $ this ->expectExceptionMessage ('Circular reference detected for route "b", path: "b -> a -> b". ' );
302
-
303
303
$ this ->routeCollection ->addAlias ('a ' , 'b ' );
304
304
$ this ->routeCollection ->addAlias ('b ' , 'a ' );
305
305
306
+ $ this ->expectException (RouteCircularReferenceException::class);
307
+ $ this ->expectExceptionMessage ('Circular reference detected for route "b", path: "b -> a -> b". ' );
308
+
306
309
$ this ->generatorDumper ->dump ();
307
310
}
308
311
309
312
public function testDeepCircularReferenceShouldThrowAnException ()
310
313
{
311
- $ this ->expectException (RouteCircularReferenceException::class);
312
- $ this ->expectExceptionMessage ('Circular reference detected for route "b", path: "b -> c -> b". ' );
313
-
314
314
$ this ->routeCollection ->addAlias ('a ' , 'b ' );
315
315
$ this ->routeCollection ->addAlias ('b ' , 'c ' );
316
316
$ this ->routeCollection ->addAlias ('c ' , 'b ' );
317
317
318
+ $ this ->expectException (RouteCircularReferenceException::class);
319
+ $ this ->expectExceptionMessage ('Circular reference detected for route "b", path: "b -> c -> b". ' );
320
+
318
321
$ this ->generatorDumper ->dump ();
319
322
}
320
323
321
324
public function testIndirectCircularReferenceShouldThrowAnException ()
322
325
{
323
- $ this ->expectException (RouteCircularReferenceException::class);
324
- $ this ->expectExceptionMessage ('Circular reference detected for route "b", path: "b -> c -> a -> b". ' );
325
-
326
326
$ this ->routeCollection ->addAlias ('a ' , 'b ' );
327
327
$ this ->routeCollection ->addAlias ('b ' , 'c ' );
328
328
$ this ->routeCollection ->addAlias ('c ' , 'a ' );
329
329
330
+ $ this ->expectException (RouteCircularReferenceException::class);
331
+ $ this ->expectExceptionMessage ('Circular reference detected for route "b", path: "b -> c -> a -> b". ' );
332
+
330
333
$ this ->generatorDumper ->dump ();
331
334
}
332
335
0 commit comments