1111
1212namespace Symfony \Cmf \Component \RoutingAuto \Tests \Unit \Adapter ;
1313
14+ use Doctrine \ODM \PHPCR \DocumentManager ;
15+ use Doctrine \ODM \PHPCR \Mapping \ClassMetadata ;
16+ use PHPCR \NodeInterface ;
17+ use PHPCR \SessionInterface ;
18+ use Prophecy \Prophecy \ObjectProphecy ;
1419use Symfony \Cmf \Bundle \RoutingAutoBundle \Adapter \PhpcrOdmAdapter ;
20+ use Symfony \Cmf \Component \RoutingAuto \Model \AutoRouteInterface ;
21+ use Symfony \Cmf \Component \RoutingAuto \UriContext ;
22+ use Symfony \Component \Serializer \Mapping \Factory \ClassMetadataFactory ;
1523
1624class PhpcrOdmAdapterTest extends \PHPUnit_Framework_TestCase
1725{
18- protected $ dm ;
19- protected $ baseRoutePath ;
26+ /**
27+ * @var DocumentManager|ObjectProphecy
28+ */
29+ private $ dm ;
30+
31+ /**
32+ * @var ClassMetadataFactory|ObjectProphecy
33+ */
34+ private $ metadataFactory ;
35+
36+ /**
37+ * @var ClassMetadata|ObjectProphecy
38+ */
39+ private $ metadata ;
40+
41+ private $ contentDocument ;
42+ private $ contentDocument2 ;
43+ private $ baseNode ;
44+ private $ parentRoute ;
45+
46+ /**
47+ * @var AutoRouteInterface|ObjectProphecy
48+ */
49+ private $ route ;
50+
51+ /**
52+ * @var UriContext|ObjectProphecy
53+ */
54+ private $ uriContext ;
55+
56+ /**
57+ * @var SessionInterface|ObjectProphecy
58+ */
59+ private $ phpcrSession ;
60+
61+ /**
62+ * @var NodeInterface|ObjectProphecy
63+ */
64+ private $ phpcrRootNode ;
65+ private $ baseRoutePath ;
66+
67+ /**
68+ * @var PhpcrOdmAdapter
69+ */
70+ private $ adapter ;
2071
2172 public function setUp ()
2273 {
@@ -118,7 +169,8 @@ public function testCreateAutoRoute($path, $expectedParentPath, $expectedName, $
118169
119170 $ this ->uriContext ->getUri ()->willReturn ($ path );
120171 $ this ->uriContext ->getDefaults ()->willReturn ([]);
121- $ res = $ this ->adapter ->createAutoRoute ($ this ->uriContext ->reveal (), $ this ->contentDocument , 'fr ' );
172+ $ this ->uriContext ->getSubject ()->willReturn ($ this ->contentDocument );
173+ $ res = $ this ->adapter ->createAutoRoute ($ this ->uriContext ->reveal (), 'fr ' );
122174 $ this ->assertNotNull ($ res );
123175 $ this ->assertInstanceOf ('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute ' , $ res );
124176 $ this ->assertEquals ($ expectedName , $ res ->getName ());
@@ -146,8 +198,9 @@ public function testCreateAutoRouteSetDefaults()
146198 'one ' => 'k1 ' ,
147199 'two ' => 'k2 ' ,
148200 ]);
201+ $ this ->uriContext ->getSubject ()->willReturn ($ this ->contentDocument );
149202
150- $ res = $ this ->adapter ->createAutoRoute ($ this ->uriContext ->reveal (), $ this -> contentDocument , 'fr ' );
203+ $ res = $ this ->adapter ->createAutoRoute ($ this ->uriContext ->reveal (), 'fr ' );
151204 $ this ->assertNotNull ($ res );
152205 $ this ->assertInstanceOf ('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute ' , $ res );
153206 $ this ->assertEquals ('to ' , $ res ->getName ());
@@ -184,7 +237,8 @@ public function testCreateAutoRouteThrowsExceptionIfItCannotMigrateExistingGener
184237 new \stdClass ()
185238 );
186239 $ this ->uriContext ->getUri ()->willReturn ($ uri );
187- $ this ->adapter ->createAutoRoute ($ this ->uriContext ->reveal (), $ this ->contentDocument , 'it ' );
240+ $ this ->uriContext ->getSubject ()->willReturn ($ this ->contentDocument );
241+ $ this ->adapter ->createAutoRoute ($ this ->uriContext ->reveal (), 'it ' );
188242 }
189243
190244 /**
@@ -196,7 +250,8 @@ public function testCreateAutoRouteNonExistingBasePath()
196250 $ this ->dm ->getPhpcrSession ()->willReturn ($ this ->phpcrSession );
197251 $ this ->dm ->find (null , $ this ->baseRoutePath )->willReturn (null );
198252 $ this ->uriContext ->getUri ()->willReturn ('/asdasd ' );
199- $ this ->adapter ->createAutoRoute ($ this ->uriContext ->reveal (), $ this ->contentDocument , 'fr ' );
253+ $ this ->uriContext ->getSubject ()->willReturn ($ this ->contentDocument );
254+ $ this ->adapter ->createAutoRoute ($ this ->uriContext ->reveal (), 'fr ' );
200255 }
201256
202257 public function testGetRealClassName ()
0 commit comments