@@ -22,6 +22,10 @@ private function getDmMock($path)
22
22
->method ('getNode ' )
23
23
->with ($ path )
24
24
;
25
+ $ session ->expects ($ this ->once ())
26
+ ->method ('getNamespacePrefixes ' )
27
+ ->will ($ this ->returnValue (array ('jcr ' , 'nt ' )))
28
+ ;
25
29
$ dm = $ this
26
30
->getMockBuilder ('Doctrine\ODM\PHPCR\DocumentManager ' )
27
31
->disableOriginalConstructor ()
@@ -90,14 +94,53 @@ public function testHas($menuRoot, $name, $expectedPath)
90
94
$ menuRoot
91
95
);
92
96
93
- $ provider ->has ($ name );
97
+ $ this ->assertTrue ($ provider ->has ($ name ));
98
+ }
99
+
100
+ public function testHasNot ()
101
+ {
102
+ $ session = $ this ->getMock ('PHPCR\SessionInterface ' );
103
+ $ session ->expects ($ this ->never ())
104
+ ->method ('getNode ' )
105
+ ;
106
+ $ session ->expects ($ this ->any ())
107
+ ->method ('getNamespacePrefixes ' )
108
+ ->will ($ this ->returnValue (array ('jcr ' , 'nt ' )))
109
+ ;
110
+ $ objectManager = $ this
111
+ ->getMockBuilder ('Doctrine\ODM\PHPCR\DocumentManager ' )
112
+ ->disableOriginalConstructor ()
113
+ ->getMock ()
114
+ ;
115
+ $ objectManager ->expects ($ this ->any ())
116
+ ->method ('getPhpcrSession ' )
117
+ ->will ($ this ->returnValue ($ session ))
118
+ ;
119
+ $ objectManager ->expects ($ this ->never ())
120
+ ->method ('find ' )
121
+ ;
122
+
123
+ $ managerRegistry = $ this ->getMock ('Doctrine\Common\Persistence\ManagerRegistry ' );
124
+ $ managerRegistry ->expects ($ this ->any ())
125
+ ->method ('getManager ' )
126
+ ->will ($ this ->returnValue ($ objectManager ));
127
+
128
+ $ provider = new PhpcrMenuProvider (
129
+ $ this ->getMock ('Knp\Menu\FactoryInterface ' ),
130
+ $ managerRegistry ,
131
+ '/foo '
132
+ );
133
+
134
+ $ this ->assertFalse ($ provider ->has ('notavalidnamespace:bar ' ));
135
+ $ this ->assertFalse ($ provider ->has ('not:a:valid:name ' ));
94
136
}
95
137
96
138
public function getMenuTests ()
97
139
{
98
140
return array (
99
141
array ('/test/menu ' , 'foo ' , '/test/menu/foo ' ),
100
142
array ('/test/menu ' , '/another/menu/path ' , '/another/menu/path ' ),
143
+ array ('/test/menu ' , 'jcr:namespaced ' , '/test/menu/jcr:namespaced ' ),
101
144
);
102
145
}
103
146
}
0 commit comments