This repository was archived by the owner on Sep 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +48
-1
lines changed
Tests/AutoRoute/RouteMaker Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,11 @@ public function __construct(DocumentManager $dm)
26
26
27
27
public function init (array $ options )
28
28
{
29
- $ this ->defaults = $ defaults ;
29
+ $ options = array_merge (array (
30
+ 'defaults ' => array (),
31
+ ), $ options );
32
+
33
+ $ this ->defaults = $ options ['defaults ' ];
30
34
}
31
35
32
36
public function make (RouteStack $ routeStack )
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Symfony \Cmf \Bundle \RoutingAutoBundle \Tests \AutoRoute \RouteMaker ;
4
+
5
+ class RouteMakerTest extends GenericMakerTest
6
+ {
7
+ protected $ routeClass = 'Symfony\Cmf\Bundle\RoutingExtraBundle\Document\Route ' ;
8
+ protected $ makerClass = 'Symfony\Cmf\Bundle\RoutingAutoBundle\AutoRoute\RouteMaker\RouteMaker ' ;
9
+
10
+ public function testMake ()
11
+ {
12
+ $ this ->routeMaker ->init (array (
13
+ 'defaults ' => array ('_controller ' => 'foobar ' )
14
+ ));
15
+
16
+ $ this ->routeStack ->expects ($ this ->once ())
17
+ ->method ('getFullPaths ' )
18
+ ->will ($ this ->returnValue (array (
19
+ 'test ' ,
20
+ 'test/foo ' ,
21
+ )));
22
+
23
+ $ test = $ this ;
24
+ $ this ->routeStack ->expects ($ this ->exactly (2 ))
25
+ ->method ('addRoute ' )
26
+ ->will ($ this ->returnCallback (function ($ doc ) use ($ test ) {
27
+ static $ i = 0 ;
28
+ $ expected = array ('/test ' , '/test/foo ' );
29
+
30
+ $ this ->assertInstanceOf (
31
+ 'Symfony\Cmf\Bundle\RoutingExtraBundle\Document\Route ' ,
32
+ $ doc
33
+ );
34
+
35
+ $ this ->assertEquals ($ expected [$ i ++], $ doc ->getId ());
36
+ $ defaults = $ doc ->getDefaults ();
37
+ $ this ->assertTrue (isset ($ defaults ['_controller ' ]));
38
+ $ this ->assertEquals ('foobar ' , $ defaults ['_controller ' ]);
39
+ }));
40
+
41
+ $ this ->routeMaker ->make ($ this ->routeStack );
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments