@@ -14,24 +14,19 @@ class ContentRepositoryTest extends \PHPUnit_Framework_Testcase
14
14
15
15
public function setUp ()
16
16
{
17
- $ this ->document = $ this -> getMock ( ' Symfony\Cmf\Bundle\RoutingBundle\Tests\Doctrine\Phpcr\TestDocument ' ) ;
18
- $ this ->document2 = $ this -> getMock ( ' Symfony\Cmf\Bundle\RoutingBundle\Tests\Doctrine\Phpcr\TestDocument ' ) ;
17
+ $ this ->document = new \ stdClass ;
18
+ $ this ->document2 = new \ stdClass ;
19
19
$ this ->objectManager = $ this ->getMock ('Doctrine\Common\Persistence\ObjectManager ' );
20
20
$ this ->objectManager2 = $ this ->getMock ('Doctrine\Common\Persistence\ObjectManager ' );
21
21
$ this ->managerRegistry = $ this ->getMock ('Doctrine\Common\Persistence\ManagerRegistry ' );
22
22
}
23
23
24
24
public function testFindById ()
25
25
{
26
- $ this ->document
27
- ->expects ($ this ->any ())
28
- ->method ('getPath ' )
29
- ->will ($ this ->returnValue ('/cms/my-document ' ))
30
- ;
31
-
32
26
$ this ->objectManager
33
27
->expects ($ this ->any ())
34
28
->method ('find ' )
29
+ ->with (null , 'id-123 ' )
35
30
->will ($ this ->returnValue ($ this ->document ))
36
31
;
37
32
@@ -44,10 +39,7 @@ public function testFindById()
44
39
$ contentRepository = new ContentRepository ($ this ->managerRegistry );
45
40
$ contentRepository ->setManagerName ('default ' );
46
41
47
- $ foundDocument = $ contentRepository ->findById ('id-123 ' );
48
-
49
- $ this ->assertInstanceOf ('Symfony\Cmf\Bundle\RoutingBundle\Tests\Doctrine\Phpcr\TestDocument ' , $ foundDocument );
50
- $ this ->assertEquals ('/cms/my-document ' , $ foundDocument ->getPath ());
42
+ $ this ->assertSame ($ this ->document , $ contentRepository ->findById ('id-123 ' ));
51
43
}
52
44
53
45
public function testGetContentId ()
@@ -61,18 +53,6 @@ public function testGetContentId()
61
53
*/
62
54
public function testChangingDocumentManager ()
63
55
{
64
- $ this ->document
65
- ->expects ($ this ->any ())
66
- ->method ('getPath ' )
67
- ->will ($ this ->returnValue ('/cms/my-document ' ))
68
- ;
69
-
70
- $ this ->document2
71
- ->expects ($ this ->any ())
72
- ->method ('getPath ' )
73
- ->will ($ this ->returnValue ('/cms/new-document ' ))
74
- ;
75
-
76
56
$ this ->objectManager
77
57
->expects ($ this ->any ())
78
58
->method ('find ' )
@@ -105,23 +85,9 @@ function ($name) use ($objectManagers) {
105
85
$ contentRepository = new ContentRepository ($ this ->managerRegistry );
106
86
107
87
$ contentRepository ->setManagerName ('default ' );
108
- $ foundDocument = $ contentRepository ->findById ('id-123 ' );
109
- $ this ->assertInstanceOf ('Symfony\Cmf\Bundle\RoutingBundle\Tests\Doctrine\Phpcr\TestDocument ' , $ foundDocument );
110
- $ this ->assertEquals ('/cms/my-document ' , $ foundDocument ->getPath ());
88
+ $ this ->assertSame ($ this ->document , $ contentRepository ->findById ('id-123 ' ));
111
89
112
90
$ contentRepository ->setManagerName ('new_manager ' );
113
- $ newFoundDocument = $ contentRepository ->findById ('id-123 ' );
114
- $ this ->assertInstanceOf ('Symfony\Cmf\Bundle\RoutingBundle\Tests\Doctrine\Phpcr\TestDocument ' , $ newFoundDocument );
115
- $ this ->assertEquals ('/cms/new-document ' , $ newFoundDocument ->getPath ());
116
- }
117
- }
118
-
119
- /**
120
- * Empty Document class for use with getMock()
121
- */
122
- class TestDocument
123
- {
124
- public function getPath ()
125
- {
91
+ $ this ->assertSame ($ this ->document2 , $ contentRepository ->findById ('id-123 ' ));
126
92
}
127
93
}
0 commit comments