11
11
12
12
namespace Symfony \Cmf \Component \RoutingAuto \Tests \Unit \Adapter ;
13
13
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 ;
14
19
use 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 ;
15
23
16
24
class PhpcrOdmAdapterTest extends \PHPUnit_Framework_TestCase
17
25
{
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 ;
20
71
21
72
public function setUp ()
22
73
{
@@ -118,7 +169,8 @@ public function testCreateAutoRoute($path, $expectedParentPath, $expectedName, $
118
169
119
170
$ this ->uriContext ->getUri ()->willReturn ($ path );
120
171
$ 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 ' );
122
174
$ this ->assertNotNull ($ res );
123
175
$ this ->assertInstanceOf ('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute ' , $ res );
124
176
$ this ->assertEquals ($ expectedName , $ res ->getName ());
@@ -146,8 +198,9 @@ public function testCreateAutoRouteSetDefaults()
146
198
'one ' => 'k1 ' ,
147
199
'two ' => 'k2 ' ,
148
200
]);
201
+ $ this ->uriContext ->getSubject ()->willReturn ($ this ->contentDocument );
149
202
150
- $ res = $ this ->adapter ->createAutoRoute ($ this ->uriContext ->reveal (), $ this -> contentDocument , 'fr ' );
203
+ $ res = $ this ->adapter ->createAutoRoute ($ this ->uriContext ->reveal (), 'fr ' );
151
204
$ this ->assertNotNull ($ res );
152
205
$ this ->assertInstanceOf ('Symfony\Cmf\Bundle\RoutingAutoBundle\Model\AutoRoute ' , $ res );
153
206
$ this ->assertEquals ('to ' , $ res ->getName ());
@@ -184,7 +237,8 @@ public function testCreateAutoRouteThrowsExceptionIfItCannotMigrateExistingGener
184
237
new \stdClass ()
185
238
);
186
239
$ 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 ' );
188
242
}
189
243
190
244
/**
@@ -196,7 +250,8 @@ public function testCreateAutoRouteNonExistingBasePath()
196
250
$ this ->dm ->getPhpcrSession ()->willReturn ($ this ->phpcrSession );
197
251
$ this ->dm ->find (null , $ this ->baseRoutePath )->willReturn (null );
198
252
$ 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 ' );
200
255
}
201
256
202
257
public function testGetRealClassName ()
0 commit comments