@@ -474,21 +474,26 @@ public function testCanRenderWithChildViewModel()
474
474
$ path = __DIR__ . '/TestAsset ' ;
475
475
$ renderer = new ZendViewRenderer ();
476
476
$ renderer ->addPath ($ path );
477
- $ viewModelParent = new ViewModel ();
477
+
478
478
$ viewModelChild = new ViewModel ();
479
479
$ viewModelChild ->setTemplate ('zendview-null ' );
480
+
481
+ $ viewModelParent = new ViewModel ();
480
482
$ viewModelParent ->setVariables ([
481
- 'layout ' => 'zendview-layout ' ,
483
+ 'layout ' => 'zendview-layout ' ,
482
484
]);
483
485
$ viewModelParent ->addChild ($ viewModelChild , 'name ' );
486
+
484
487
$ result = $ renderer ->render ('zendview ' , $ viewModelParent );
485
488
486
- $ content = file_get_contents ("$ path/zendview-null.phtml " );
487
- $ contentParent = file_get_contents ("$ path/zendview.phtml " );
488
- $ contentParentLayout = file_get_contents ("$ path/zendview-layout.phtml " );
489
- //trim is used here, because rendering engine is trimming content too
489
+ $ content = file_get_contents (sprintf ('%s/zendview-null.phtml ' , $ path ));
490
+ $ contentParent = file_get_contents (sprintf ('%s/zendview.phtml ' , $ path ));
491
+ $ contentParentLayout = file_get_contents (sprintf ('%s/zendview-layout.phtml ' , $ path ));
492
+
493
+ // trim is used here, because rendering engine is trimming content too
490
494
$ content = trim (str_replace ('<?php echo $name ?> ' , $ content , $ contentParent ));
491
495
$ content = str_replace ('<?= $this->content ?> ' , $ content , $ contentParentLayout );
496
+
492
497
$ this ->assertEquals ($ content , $ result );
493
498
}
494
499
}
0 commit comments