@@ -997,4 +997,75 @@ public function testCanSpecifyRouteNamesViaConfiguration()
997997 $ this ->assertInstanceOf (Route::class, $ route );
998998 $ this ->assertEquals ('home ' , $ route ->getName ());
999999 }
1000+
1001+ public function testCanSpecifyRouteOptionsViaConfiguration ()
1002+ {
1003+ $ router = $ this ->prophesize ('Zend\Expressive\Router\RouterInterface ' );
1004+ $ emitter = $ this ->prophesize ('Zend\Diactoros\Response\EmitterInterface ' );
1005+ $ finalHandler = function ($ req , $ res , $ err = null ) {
1006+ };
1007+
1008+ $ expected = [
1009+ 'values ' => [
1010+ 'foo ' => 'bar '
1011+ ],
1012+ 'tokens ' => [
1013+ 'bar ' => 'foo '
1014+ ]
1015+ ];
1016+ $ config = [
1017+ 'routes ' => [
1018+ [
1019+ 'path ' => '/ ' ,
1020+ 'middleware ' => 'HelloWorld ' ,
1021+ 'name ' => 'home ' ,
1022+ 'allowed_methods ' => ['GET ' ],
1023+ 'options ' => $ expected
1024+ ],
1025+ ],
1026+ ];
1027+
1028+ $ this ->container
1029+ ->has ('Zend\Expressive\Router\RouterInterface ' )
1030+ ->willReturn (true );
1031+ $ this ->container
1032+ ->get ('Zend\Expressive\Router\RouterInterface ' )
1033+ ->will (function () use ($ router ) {
1034+ return $ router ->reveal ();
1035+ });
1036+
1037+ $ this ->container
1038+ ->has ('Zend\Diactoros\Response\EmitterInterface ' )
1039+ ->willReturn (true );
1040+ $ this ->container
1041+ ->get ('Zend\Diactoros\Response\EmitterInterface ' )
1042+ ->will (function () use ($ emitter ) {
1043+ return $ emitter ->reveal ();
1044+ });
1045+
1046+ $ this ->container
1047+ ->has ('Zend\Expressive\FinalHandler ' )
1048+ ->willReturn (true );
1049+ $ this ->container
1050+ ->get ('Zend\Expressive\FinalHandler ' )
1051+ ->willReturn ($ finalHandler );
1052+
1053+ $ this ->container
1054+ ->has ('config ' )
1055+ ->willReturn (true );
1056+
1057+ $ this ->container
1058+ ->get ('config ' )
1059+ ->willReturn ($ config );
1060+
1061+ $ app = $ this ->factory ->__invoke ($ this ->container ->reveal ());
1062+
1063+ $ r = new ReflectionProperty ($ app , 'routes ' );
1064+ $ r ->setAccessible (true );
1065+ $ routes = $ r ->getValue ($ app );
1066+ $ route = array_shift ($ routes );
1067+
1068+ $ this ->assertInstanceOf (Route::class, $ route );
1069+ $ this ->assertEquals ($ expected , $ route ->getOptions ());
1070+ }
10001071}
0 commit comments