@@ -96,6 +96,52 @@ public function testGetUserWithEmptyContainer()
96
96
$ controller ->getUser ();
97
97
}
98
98
99
+ // public function testRenderWithTwig()
100
+ // {
101
+ //
102
+ // }
103
+ //
104
+ // public function testRenderWithTemplating()
105
+ // {
106
+ //
107
+ // }
108
+
109
+ /**
110
+ * @expectedException \LogicException
111
+ * @expectedExceptionMessage You can not use the render method if the Templating Component or the Twig Bundle are not available.
112
+ */
113
+ public function testRenderWithEmptyContainer ()
114
+ {
115
+ $ container = $ this ->getContainerWithoutTwigAndTemplating ();
116
+ $ controller = new TestController ();
117
+ $ controller ->setContainer ($ container );
118
+ $ controller ->render ('dummy.html.twig ' );
119
+ }
120
+
121
+ /**
122
+ * @expectedException \LogicException
123
+ * @expectedExceptionMessage You can not use the renderView method if the Templating Component or the Twig Bundle are not available.
12
B41A
4
+ */
125
+ public function testRenderViewWithEmptyContainer ()
126
+ {
127
+ $ container = $ this ->getContainerWithoutTwigAndTemplating ();
128
+ $ controller = new TestController ();
129
+ $ controller ->setContainer ($ container );
130
+ $ controller ->renderView ('dummy.html.twig ' );
131
+ }
132
+
133
+ /**
134
+ * @expectedException \LogicException
135
+ * @expectedExceptionMessage You can not use the stream method if the Templating Component or the Twig Bundle are not available.
136
+ */
137
+ public function testStreamWithEmptyContainer ()
138
+ {
139
+ $ container = $ this ->getContainerWithoutTwigAndTemplating ();
140
+ $ controller = new TestController ();
141
+ $ controller ->setContainer ($ container );
142
+ $ controller ->stream ('dummy.html.twig ' );
143
+ }
144
+
99
145
/**
100
146
* @param $token
101
147
*
@@ -124,6 +170,71 @@ private function getContainerWithTokenStorage($token = null)
124
170
125
171
return $ container ;
126
172
}
173
+
174
+ /**
175
+ * @return ContainerInterface
176
+ */
177
+ private function getContainerWithTwig ()
178
+ {
179
+ $ container = $ this ->getMock ('Symfony\Component\DependencyInjection\ContainerInterface ' );
180
+ $ container
181
+ ->expects ($ this ->once ())
182
+ ->method ('has ' )
183
+ ->with ('twig ' )
184
+ ->will ($ this ->returnValue (true ));
185
+
186
+ $ twig = $ this ->getMock ('Twig_Environment ' );
187
+ $ container
188
+ ->expects ($ this ->once ())
189
+ ->method ('get ' )
190
+ ->with ('twig ' )
191
+ ->will ($ this ->returnValue ($ twig ));
192
+
193
+ return $ container ;
194
+ }
195
+
196
+ /**
197
+ * @return ContainerInterface
198
+ */
199
+ private function getContainerWithTemplating ()
200
+ {
201
+ $ container = $ this ->getMock ('Symfony\Component\DependencyInjection\ContainerInterface ' );
202
+ $ container
203
+ ->expects ($ this ->once ())
204
+ ->method ('has ' )
205
+ ->with ('templating ' )
206
+ ->will ($ this ->returnValue (true ));
207
+
208
+ $ templating = $ this ->getMock ('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface ' );
209
+ $ container
210
+ ->expects ($ this ->once ())
211
+ ->method ('get ' )
212
+ ->with ('templating ' )
213
+ ->will ($ this ->returnValue ($ templating ));
214
+
215
+ return $ container ;
216
+ }
217
+
218
+ /**
219
+ * @return ContainerInterface
220
+ */
221
+ public function getContainerWithoutTwigAndTemplating ()
222
+ {
223
+ $ container = $ this ->getMock ('Symfony\Component\DependencyInjection\ContainerInterface ' );
224
+ $ container
225
+ ->expects ($ this ->once ())
226
+ ->method ('has ' )
227
+ ->with ('twig ' )
228
+ ->will ($ this ->returnValue (false ));
229
+
230
+ $ container
231
+ ->expects ($ this ->once ())
232
+ ->method ('has ' )
233
+ ->with ('templating ' )
234
+ ->will ($ this ->returnValue (false ));
235
+
236
+ return $ container ;
237
+ }
127
238
}
128
239
129
240
class TestController extends Controller
0 commit comments