Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to use the parital as described #53

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions tests/src/ViewTest.php
Expand Up @@ -89,4 +89,43 @@ public function testInvokeTwoStep()
$expect = "before -- Hello Index! -- after";
$this->assertSame($expect, $actual);
}

public function testPartials()
{
// add templates to the view registry
$view_registry = $this->view->getViewRegistry();

$view_registry->set('item_rows', function () {
foreach ($this->items as $item) {
echo $this->render('item_row', array('item' => $item));
};
});

$view_registry->set('item_row', function () {
echo $item['name'] . ' costs ' . $item['price'] . PHP_EOL;
});

// set the data and the view template name
$this->view->setData(array(
'items' => array(
array(
'name' => 'A',
'price' => 20
),
array(
'name' => 'B',
'price' => 20
),
array(
'name' => 'C',
'price' => 20
)
)
));
$this->view->setView('item_rows');

// execute the view
$output = $this->view->__invoke();
$this->assertNotEmpty($output);
}
}