@@ -66,6 +66,7 @@ public function testGetRouteByName()
66
66
$ routeProvider = new RouteProvider ($ this ->managerRegistry );
67
67
$ routeProvider ->setManagerName ('default ' );
68
68
69
+ $ routeProvider ->setPrefix ('/cms/routes/ ' );
69
70
$ foundRoute = $ routeProvider ->getRouteByName ('/cms/routes/test-route ' );
70
71
71
72
$ this ->assertInstanceOf ('Symfony\Component\Routing\Route ' , $ foundRoute );
@@ -92,7 +93,7 @@ public function testGetRouteByNameNotFound()
92
93
93
94
$ routeProvider = new RouteProvider ($ this ->managerRegistry );
94
95
$ routeProvider ->setManagerName ('default ' );
95
-
96
+ $ routeProvider -> setPrefix ( ' /cms/routes/ ' );
96
97
$ routeProvider ->getRouteByName ('/cms/routes/test-route ' );
97
98
}
98
99
@@ -116,6 +117,112 @@ public function testGetRouteByNameNoRoute()
116
117
117
118
$ routeProvider = new RouteProvider ($ this ->managerRegistry );
118
119
$ routeProvider ->setManagerName ('default ' );
120
+ $ routeProvider ->setPrefix ('/cms/routes/ ' );
121
+ $ routeProvider ->getRouteByName ('/cms/routes/test-route ' );
122
+ }
123
+
124
+ /**
125
+ * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
126
+ */
127
+ public function testGetRouteByNameInvalidRoute ()
128
+ {
129
+ $ this ->objectManager
130
+ ->expects ($ this ->never ())
131
+ ->method ('find ' )
132
+ ;
133
+
134
+ $ this ->managerRegistry
135
+ ->expects ($ this ->any ())
136
+ ->method ('getManager ' )
137
+ ->will ($ this ->returnValue ($ this ->objectManager ))
138
+ ;
139
+
140
+ $ routeProvider = new RouteProvider ($ this ->managerRegistry );
141
+ $ routeProvider ->setManagerName ('default ' );
142
+
143
+ $ routeProvider ->setPrefix ('/cms/routes ' );
144
+
145
+ $ routeProvider ->getRouteByName ('invalid_route ' );
146
+ }
147
+
148
+ public function testGetRouteByNameIdPrefixEmptyString ()
149
+ {
150
+
151
+ $ this ->route
152
+ ->expects ($ this ->any ())
153
+ ->method ('getPath ' )
154
+ ->will ($ this ->returnValue ('/cms/routes/test-route ' ))
155
+ ;
156
+
157
+ $ this ->objectManager
158
+ ->expects ($ this ->any ())
159
+ ->method ('find ' )
160
+ ->with (null , '/cms/routes/test-route ' )
161
+ ->will ($ this ->returnValue ($ this ->route ))
162
+ ;
163
+
164
+ $ this ->managerRegistry
165
+ ->expects ($ this ->any ())
166
+ ->method ('getManager ' )
167
+ ->will ($ this ->returnValue ($ this ->objectManager ))
168
+ ;
169
+
170
+ $ routeProvider = new RouteProvider ($ this ->managerRegistry );
171
+ $ routeProvider ->setManagerName ('default ' );
172
+
173
+ $ routeProvider ->setPrefix ('' );
174
+ $ foundRoute = $ routeProvider ->getRouteByName ('/cms/routes/test-route ' );
175
+
176
+ $ this ->assertInstanceOf ('Symfony\Component\Routing\Route ' , $ foundRoute );
177
+ $ this ->assertEquals ('/cms/routes/test-route ' , $ foundRoute ->getPath ());
178
+ }
179
+
180
+
181
+ /**
182
+ * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
183
+ */
184
+ public function testGetRouteByNameNotFoundIdPrefixEmptyString ()
185
+ {
186
+ $ this ->objectManager
187
+ ->expects ($ this ->any ())
188
+ ->method ('find ' )
189
+ ->with (null , '/cms/routes/test-route ' )
190
+ ->will ($ this ->returnValue (null ))
191
+ ;
192
+
193
+ $ this ->managerRegistry
194
+ ->expects ($ this ->any ())
195
+ ->method ('getManager ' )
196
+ ->will ($ this ->returnValue ($ this ->objectManager ))
197
+ ;
198
+
199
+ $ routeProvider = new RouteProvider ($ this ->managerRegistry );
200
+ $ routeProvider ->setManagerName ('default ' );
201
+ $ routeProvider ->setPrefix ('' );
202
+ $ routeProvider ->getRouteByName ('/cms/routes/test-route ' );
203
+ }
204
+
205
+ /**
206
+ * @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
207
+ */
208
+ public function testGetRouteByNameNoRoutePrefixEmptyString ()
209
+ {
210
+ $ this ->objectManager
211
+ ->expects ($ this ->any ())
212
+ ->method ('find ' )
213
+ ->with (null , '/cms/routes/test-route ' )
214
+ ->will ($ this ->returnValue ($ this ))
215
+ ;
216
+
217
+ $ this ->managerRegistry
218
+ ->expects ($ this ->any ())
219
+ ->method ('getManager ' )
220
+ ->will ($ this ->returnValue ($ this ->objectManager ))
221
+ ;
222
+
223
+ $ routeProvider = new RouteProvider ($ this ->managerRegistry );
224
+ $ routeProvider ->setManagerName ('default ' );
225
+ $ routeProvider ->setPrefix ('' );
119
226
120
227
$ routeProvider ->getRouteByName ('/cms/routes/test-route ' );
121
228
}
@@ -173,6 +280,8 @@ function ($name) use ($objectManagers) {
173
280
$ routeProvider = new RouteProvider ($ this ->managerRegistry );
174
281
175
282
$ routeProvider ->setManagerName ('default ' );
283
+ $ routeProvider ->setPrefix ('/cms/routes/ ' );
284
+
176
285
$ foundRoute = $ routeProvider ->getRouteByName ('/cms/routes/test-route ' );
177
286
$ this ->assertInstanceOf ('Symfony\Component\Routing\Route ' , $ foundRoute );
178
287
$ this ->assertEquals ('/cms/routes/test-route ' , $ foundRoute ->getPath ());
0 commit comments