@@ -44,7 +44,49 @@ public function testFindById()
44
44
45
45
public function testGetContentId ()
46
46
{
47
- $ this ->markTestIncomplete ();
47
+ $ uow = $ this ->getMockBuilder ('Doctrine\ODM\PHPCR\UnitOfWork ' )->disableOriginalConstructor ()->getMock ();
48
+ $ uow ->expects ($ this ->once ())
49
+ ->method ('getDocumentId ' )
50
+ ->with ($ this ->document )
51
+ ->will ($ this ->returnValue ('id-123 ' ))
52
+ ;
53
+
54
+ $ dm = $ this ->getMockBuilder ('Doctrine\ODM\PHPCR\DocumentManager ' )->disableOriginalConstructor ()->getMock ();
55
+ $ dm
56
+ ->expects ($ this ->once ())
57
+ ->method ('getUnitOfWork ' )
58
+ ->will ($ this ->returnValue ($ uow ))
59
+ ;
60
+ $ this ->managerRegistry
61
+ ->expects ($ this ->once ())
62
+ ->method ('getManager ' )
63
+ ->will ($ this ->returnValue ($ dm ))
64
+ ;
65
+
66
+ $ contentRepository = new ContentRepository ($ this ->managerRegistry );
67
+ $ contentRepository ->setManagerName ('default ' );
68
+
69
+ $ this ->assertEquals ('id-123 ' , $ contentRepository ->getContentId ($ this ->document ));
70
+ }
71
+
72
+ public function testGetContentIdNoObject ()
73
+ {
74
+ $ contentRepository = new ContentRepository ($ this ->managerRegistry );
75
+ $ this ->assertNull ($ contentRepository ->getContentId ('hello ' ));
76
+ }
77
+
78
+ public function testGetContentIdException ()
79
+ {
80
+ $ this ->managerRegistry
81
+ ->expects ($ this ->once ())
82
+ ->method ('getManager ' )
83
+ ->will ($ this ->throwException (new \Exception ()))
84
+ ;
85
+
86
+ $ contentRepository = new ContentRepository ($ this ->managerRegistry );
87
+ $ contentRepository ->setManagerName ('default ' );
88
+
89
+ $ this ->assertNull ($ contentRepository ->getContentId ($ this ->document ));
48
90
}
49
91
50
92
/**
0 commit comments