@@ -359,4 +359,64 @@ public function testOverlappingRoutesMatchesFirstRoute()
359
359
$ this ->assertCount (2 , $ this ->routeCollection ->getRoutes ());
360
360
$ this ->assertEquals ('first ' , $ this ->routeCollection ->match ($ request )->getName ());
361
361
}
362
+
363
+ public function testPrependsRoutesWithDomain ()
364
+ {
365
+ $ this ->routeCollection ->add (
366
+ $ noDomainGet1 = new Route ('GET ' , 'no-domain-get1 ' , ['uses ' => 'NoDomainController@index ' ])
367
+ );
368
+
369
+ $ this ->routeCollection ->add (
370
+ $ fooDomainGet1 = (new Route ('GET ' , 'foo-domain-get1 ' , ['uses ' => 'FooDomainController@index ' ]))->domain ('foo.test ' )
371
+ );
372
+
373
+ $ this ->routeCollection ->add (
374
+ $ barDomainGet1 = (new Route ('GET ' , 'bar-domain-get1 ' , ['uses ' => 'BarDomainController@index ' ]))->domain ('bar.test ' )
375
+ );
376
+
377
+ $ this ->routeCollection ->add (
378
+ $ noDomainGet2 = new Route ('GET ' , 'no-domain-get2 ' , ['uses ' => 'NoDomainController@show ' ])
379
+ );
380
+
381
+ $ this ->routeCollection ->add (
382
+ $ fooDomainGet2 = (new Route ('GET ' , 'foo-domain-get2 ' , ['uses ' => 'FooDomainController@show ' ]))->domain ('foo.test ' )
383
+ );
384
+
385
+ $ this ->routeCollection ->add (
386
+ $ barDomainGet2 = (new Route ('GET ' , 'bar-domain-get2 ' , ['uses ' => 'BarDomainController@show ' ]))->domain ('bar.test ' )
387
+ );
388
+
389
+ $ this ->assertSame ([
390
+ $ fooDomainGet1 ,
391
+ $ barDomainGet1 ,
392
+ $ fooDomainGet2 ,
393
+ $ barDomainGet2 ,
394
+ $ noDomainGet1 ,
395
+ $ noDomainGet2 ,
396
+ ], $ this ->routeCollection ->getRoutes ());
397
+
398
+ $ this ->assertSame ([
399
+ 'GET ' => [
400
+ 'foo.testfoo-domain-get1 ' => $ fooDomainGet1 ,
401
+ 'bar.testbar-domain-get1 ' => $ barDomainGet1 ,
402
+
403
+ 'foo.testfoo-domain-get2 ' => $ fooDomainGet2 ,
404
+ 'bar.testbar-domain-get2 ' => $ barDomainGet2 ,
405
+
406
+ 'no-domain-get1 ' => $ noDomainGet1 ,
407
+ 'no-domain-get2 ' => $ noDomainGet2 ,
408
+ ],
409
+
410
+ 'HEAD ' => [
411
+ 'foo.testfoo-domain-get1 ' => $ fooDomainGet1 ,
412
+ 'bar.testbar-domain-get1 ' => $ barDomainGet1 ,
413
+
414
+ 'foo.testfoo-domain-get2 ' => $ fooDomainGet2 ,
415
+ 'bar.testbar-domain-get2 ' => $ barDomainGet2 ,
416
+
417
+ 'no-domain-get1 ' => $ noDomainGet1 ,
418
+ 'no-domain-get2 ' => $ noDomainGet2 ,
419
+ ],
420
+ ], $ this ->routeCollection ->getRoutesByMethod ());
421
+ }
362
422
}
0 commit comments