2020use Zend \Expressive \ZendView \ZendViewRendererFactory ;
2121use Zend \View \HelperPluginManager ;
2222use Zend \View \Model \ModelInterface ;
23+ use Zend \View \Renderer \PhpRenderer ;
2324use Zend \View \Resolver \AggregateResolver ;
2425use Zend \View \Resolver \TemplateMapResolver ;
2526
@@ -125,6 +126,7 @@ public function testCallingFactoryWithNoConfigReturnsZendViewInstance()
125126 {
126127 $ this ->container ->has ('config ' )->willReturn (false );
127128 $ this ->container ->has (HelperPluginManager::class)->willReturn (false );
129+ $ this ->container ->has (PhpRenderer::class)->willReturn (false );
128130 $ this ->injectBaseHelpers ();
129131 $ factory = new ZendViewRendererFactory ();
130132 $ view = $ factory ($ this ->container ->reveal ());
@@ -154,6 +156,7 @@ public function testConfiguresLayout()
154156 $ this ->container ->has ('config ' )->willReturn (true );
155157 $ this ->container ->get ('config ' )->willReturn ($ config );
156158 $ this ->container ->has (HelperPluginManager::class)->willReturn (false );
159+ $ this ->container ->has (PhpRenderer::class)->willReturn (false );
157160 $ this ->injectBaseHelpers ();
158161 $ factory = new ZendViewRendererFactory ();
159162 $ view = $ factory ($ this ->container ->reveal ());
@@ -175,6 +178,7 @@ public function testConfiguresPaths()
175178 $ this ->container ->has ('config ' )->willReturn (true );
176179 $ this ->container ->get ('config ' )->willReturn ($ config );
177180 $ this ->container ->has (HelperPluginManager::class)->willReturn (false );
181+ $ this ->container ->has (PhpRenderer::class)->willReturn (false );
178182 $ this ->injectBaseHelpers ();
179183 $ factory = new ZendViewRendererFactory ();
180184 $ view = $ factory ($ this ->container ->reveal ());
@@ -212,6 +216,7 @@ public function testConfiguresTemplateMap()
212216 $ this ->container ->has ('config ' )->willReturn (true );
213217 $ this ->container ->get ('config ' )->willReturn ($ config );
214218 $ this ->container ->has (HelperPluginManager::class)->willReturn (false );
219+ $ this ->container ->has (PhpRenderer::class)->willReturn (false );
215220 $ this ->injectBaseHelpers ();
216221 $ factory = new ZendViewRendererFactory ();
217222 $ view = $ factory ($ this ->container ->reveal ());
@@ -238,6 +243,7 @@ public function testInjectsCustomHelpersIntoHelperManager()
238243 {
239244 $ this ->container ->has ('config ' )->willReturn (false );
240245 $ this ->container ->has (HelperPluginManager::class)->willReturn (false );
246+ $ this ->container ->has (PhpRenderer::class)->willReturn (false );
241247 $ this ->injectBaseHelpers ();
242248 $ factory = new ZendViewRendererFactory ();
243249 $ view = $ factory ($ this ->container ->reveal ());
@@ -255,6 +261,7 @@ public function testInjectsCustomHelpersIntoHelperManager()
255261 public function testWillUseHelperManagerFromContainer ()
256262 {
257263 $ this ->container ->has ('config ' )->willReturn (false );
264+ $ this ->container ->has (PhpRenderer::class)->willReturn (false );
258265 $ this ->injectBaseHelpers ();
259266
260267 $ helpers = new HelperPluginManager ($ this ->container ->reveal ());
@@ -281,4 +288,18 @@ public function testInjectsCustomHelpersIntoHelperManagerFromContainer(HelperPlu
281288 $ this ->assertInstanceOf (UrlHelper::class, $ helpers ->get ('url ' ));
282289 $ this ->assertInstanceOf (ServerUrlHelper::class, $ helpers ->get ('serverurl ' ));
283290 }
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+ }
284305}
0 commit comments