public function testTableHilightRow() { $context = ContextFactory::fromYaml(dirname(__FILE__) . '/../fixtures/simpletable.yaml'); $context->ids('column', 'name,email'); $context->select('row[id=17]')->add('tr', array('class' => 'hilight')); $data = array(array('id' => 23, 'name' => 'Peter', 'email' => '*****@*****.**'), array('id' => 17, 'name' => 'Heidi', 'email' => '*****@*****.**')); $context->setContent($data); $expected = '<table><tr><td>Peter</td><td>peter@alps.ch</td></tr><tr class="hilight"><td>Heidi</td><td>heidi@alps.ch</td></tr></table>'; $actual = $context->render(); $this->assertEquals($expected, $actual); }
public function testBootstrapTable() { $context = ContextFactory::fromYaml(__DIR__ . '/../fixtures/bootstrap_table.yaml'); $apiResults = array(array('state' => 'OK', 'text' => 'All ok', 'host' => 'www.example.com'), array('state' => 'KO', 'text' => '8 Failures', 'host' => 'backend.example.com')); // only display the key 'text' $context->ids('column', 'text'); // set header text to fixed string $context->select('header column')->add('content', 'Result'); // add tag warning to rows with the state set to 'KO' $context->select('row[state=KO]')->addTag('warning'); $actual = $context->render($apiResults); $expected = file_get_contents(__DIR__ . '/../fixtures/bootstrap_table.html'); $this->assertEquals($expected, $actual); }
public function testEmptyColumn() { $context = ContextFactory::fromXML(dirname(__FILE__) . '/../fixtures/simpletable.xml'); $context->ids('column', 'name,email'); $context->select('column:empty')->insteadOf('content')->add('text', 'Empty column!'); $data = array(array('name' => 'Peter', 'email' => '*****@*****.**'), array('name' => 'Heidi', 'email' => '')); $context->setContent($data); $expected = '<table><tr><td>Peter</td><td>peter@alps.ch</td></tr><tr><td>Heidi</td><td>Empty column!</td></tr></table>'; $actual = $context->render(); $this->assertEquals($expected, $actual); }