Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit 92707d2

Browse files
authored
Added test case for PR #43
1 parent 4fc77b7 commit 92707d2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/ZendViewRendererTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,4 +430,27 @@ public function testWillRenderAViewModel()
430430
$content = str_replace('<?php echo $name ?>', 'Zend', $content);
431431
$this->assertEquals($content, $result);
432432
}
433+
434+
public function testCanRenderWithChildViewModel()
435+
{
436+
$path = __DIR__ . '/TestAsset';
437+
$renderer = new ZendViewRenderer();
438+
$renderer->addPath($path);
439+
$viewModelParent = new ViewModel();
440+
$viewModelChild = new ViewModel();
441+
$viewModelChild->setTemplate('zendview-null');
442+
$viewModelParent->setVariables([
443+
'layout' => 'zendview-layout',
444+
]);
445+
$viewModelParent->addChild($viewModelChild, 'name');
446+
$result = $renderer->render('zendview', $viewModelParent);
447+
448+
$content = file_get_contents("$path/zendview-null.phtml");
449+
$contentParent = file_get_contents("$path/zendview.phtml");
450+
$contentParentLayout = file_get_contents("$path/zendview-layout.phtml");
451+
//trim is used here, because rendering engine is trimming content too
452+
$content = trim(str_replace('<?php echo $name ?>', $content, $contentParent));
453+
$content = str_replace('<?= $this->content ?>', $content, $contentParentLayout);
454+
$this->assertEquals($content, $result);
455+
}
433456
}

0 commit comments

Comments
 (0)