20
20
use Zend \Expressive \ZendView \ZendViewRendererFactory ;
21
21
use Zend \View \HelperPluginManager ;
22
22
use Zend \View \Model \ModelInterface ;
23
+ use Zend \View \Renderer \PhpRenderer ;
23
24
use Zend \View \Resolver \AggregateResolver ;
24
25
use Zend \View \Resolver \TemplateMapResolver ;
25
26
@@ -125,6 +126,7 @@ public function testCallingFactoryWithNoConfigReturnsZendViewInstance()
125
126
{
126
127
$ this ->container ->has ('config ' )->willReturn (false );
127
128
$ this ->container ->has (HelperPluginManager::class)->willReturn (false );
129
+ $ this ->container ->has (PhpRenderer::class)->willReturn (false );
128
130
$ this ->injectBaseHelpers ();
129
131
$ factory = new ZendViewRendererFactory ();
130
132
$ view = $ factory ($ this ->container ->reveal ());
@@ -154,6 +156,7 @@ public function testConfiguresLayout()
154
156
$ this ->container ->has ('config ' )->willReturn (true );
155
157
$ this ->container ->get ('config ' )->willReturn ($ config );
156
158
$ this ->container ->has (HelperPluginManager::class)->willReturn (false );
159
+ $ this ->container ->has (PhpRenderer::class)->willReturn (false );
157
160
$ this ->injectBaseHelpers ();
158
161
$ factory = new ZendViewRendererFactory ();
159
162
$ view = $ factory ($ this ->container ->reveal ());
@@ -175,6 +178,7 @@ public function testConfiguresPaths()
175
178
$ this ->container ->has ('config ' )->willReturn (true );
176
179
$ this ->container ->get ('config ' )->willReturn ($ config );
177
180
$ this ->container ->has (HelperPluginManager::class)->willReturn (false );
181
+ $ this ->container ->has (PhpRenderer::class)->willReturn (false );
178
182
$ this ->injectBaseHelpers ();
179
183
$ factory = new ZendViewRendererFactory ();
180
184
$ view = $ factory ($ this ->container ->reveal ());
@@ -212,6 +216,7 @@ public function testConfiguresTemplateMap()
212
216
$ this ->container ->has ('config ' )->willReturn (true );
213
217
$ this ->container ->get ('config ' )->willReturn ($ config );
214
218
$ this ->container ->has (HelperPluginManager::class)->willReturn (false );
219
+ $ this ->container ->has (PhpRenderer::class)->willReturn (false );
215
220
$ this ->injectBaseHelpers ();
216
221
$ factory = new ZendViewRendererFactory ();
217
222
$ view = $ factory ($ this ->container ->reveal ());
@@ -238,6 +243,7 @@ public function testInjectsCustomHelpersIntoHelperManager()
238
243
{
239
244
$ this ->container ->has ('config ' )->willReturn (false );
240
245
$ this ->container ->has (HelperPluginManager::class)->willReturn (false );
246
+ $ this ->container ->has (PhpRenderer::class)->willReturn (false );
241
247
$ this ->injectBaseHelpers ();
242
248
$ factory = new ZendViewRendererFactory ();
243
249
$ view = $ factory ($ this ->container ->reveal ());
@@ -255,6 +261,7 @@ public function testInjectsCustomHelpersIntoHelperManager()
255
261
public function testWillUseHelperManagerFromContainer ()
256
262
{
257
263
$ this ->container ->has ('config ' )->willReturn (false );
264
+ $ this ->container ->has (PhpRenderer::class)->willReturn (false );
258
265
$ this ->injectBaseHelpers ();
259
266
260
267
$ helpers = new HelperPluginManager ($ this ->container ->reveal ());
@@ -281,4 +288,18 @@ public function testInjectsCustomHelpersIntoHelperManagerFromContainer(HelperPlu
281
288
$ this ->assertInstanceOf (UrlHelper::class, $ helpers ->get ('url ' ));
282
289
$ this ->assertInstanceOf (ServerUrlHelper::class, $ helpers ->get ('serverurl ' ));
283
290
}
291
+
292
+ public function testWillUseRendererFromContainer ()
293
+ {
294
+ $ engine = new PhpRenderer ;
295
+ $ this ->container ->has ('config ' )->willReturn (false );
296
+ $ this ->container ->has (HelperPluginManager::class)->willReturn (false );
297
+ $ this ->injectContainerService (PhpRenderer::class, $ engine );
298
+
299
+ $ factory = new ZendViewRendererFactory ();
300
+ $ view = $ factory ($ this ->container ->reveal ());
301
+
302
+ $ composed = $ this ->fetchPhpRenderer ($ view );
303
+ $ this ->assertSame ($ engine , $ composed );
304
+ }
284
305
}
0 commit comments