public function testTableFromArrayCreation() { $table1 = new TableNode(); $table1->addRow(array('username', 'password')); $table1->addRow(array('everzet', 'qwerty')); $table1->addRow(array('antono', 'pa$sword')); $table2 = new TableNode(<<<TABLE | username | password | | everzet | qwerty | | antono | pa\$sword| TABLE ); $this->assertEquals($table2->getRows(), $table1->getRows()); $this->assertEquals(array(array('username' => 'everzet', 'password' => 'qwerty'), array('username' => 'antono', 'password' => 'pa$sword')), $table1->getHash()); $this->assertEquals(array('username' => 'password', 'everzet' => 'qwerty', 'antono' => 'pa$sword'), $table2->getRowsHash()); }
/** * Get TableNode HTML representation. * * @param TableNode $table table node * @param string $class optional css class * * @return string HTML */ protected function getTableHtml(TableNode $table, $class = null) { if (null === $class) { $html = '<table><tbody>'; } else { $html = '<table class="' . $class . '"><tbody>'; } foreach ($table->getHash() as $row) { $html .= $this->getTableRow($row); } $html .= '</tbody></table>'; return $html; }