public function testRenderWithTemplate()
{
$rows = array(array('id' => 1, 'name' => 'Test1', 'email' => '[email protected]'), array('id' => 2, 'name' => 'Test2', 'email' => '[email protected]'), array('id' => 3, 'name' => 'Test3', 'email' => '[email protected]'), array('id' => 4, 'name' => 'Test4', 'email' => '[email protected]'), array('id' => 5, 'name' => 'Test5', 'email' => '[email protected]'), array('id' => 6, 'name' => 'Test6', 'email' => '[email protected]'), array('id' => 7, 'name' => 'Test7', 'email' => '[email protected]'), array('id' => 8, 'name' => 'Test8', 'email' => '[email protected]'), array('id' => 9, 'name' => 'Test9', 'email' => '[email protected]'), array('id' => 10, 'name' => 'Test10', 'email' => '[email protected]'), array('id' => 11, 'name' => 'Test11', 'email' => '[email protected]'), array('id' => 12, 'name' => 'Test12', 'email' => '[email protected]'), array('id' => 13, 'name' => 'Test13', 'email' => '[email protected]'), array('id' => 14, 'name' => 'Test14', 'email' => '[email protected]'), array('id' => 15, 'name' => 'Test15', 'email' => '[email protected]'), array('id' => 16, 'name' => 'Test16', 'email' => '[email protected]'));
$header = <<<HEADER
<table class="paged-table" cellpadding="0" cellspacing="0">
<tr><td colspan="2">[{page_links}]</td></tr>
<tr><td><strong>Name</strong></td><td><strong>Email</strong></td></tr>
HEADER;
$rowTemplate = <<<TMPL
<tr><td><a href="./edit-user.php?id=[{id}]">[{name}]</a></td><td>[{email}]</td></tr>
TMPL;
$footer = <<<FOOTER
<tr><td colspan="2">[{page_links}]</td></tr>
</table>
FOOTER;
$p = new Paginator($rows, 3, 3);
$p->setHeader($header)->setRowTemplate($rowTemplate)->setFooter($footer);
$render = $p->render(1, true);
ob_start();
$p->render(1);
$output = ob_get_clean();
$this->assertContains('<tr><td><a href="./edit-user.php?id=1">Test1</a></td><td>[email protected]</td></tr>', $render);
$this->assertContains('<tr><td><a href="./edit-user.php?id=1">Test1</a></td><td>[email protected]</td></tr>', $output);
$this->assertContains('<tr><td><a href="./edit-user.php?id=1">Test1</a></td><td>[email protected]</td></tr>', (string) $p);
}