public function testFromArray() { foreach ($this->getTestValidColumn() as $dataColumn) { $this->assertEquals($dataColumn['obj'], DataColumn::fromArray($dataColumn['array'])); } }
public function testAddRowObject() { $cols = $this->getColArray(); $rows = $this->getRowsArray(); $table = $this->getFromArrayDataTable($cols, $rows); $dataRow = new DataRow(array('id1' => array('v' => 'the first value', 'f' => 'label 1'), 'id2' => 19, 'id5' => new DataCell(false, 'label 3'))); $dataRowStrict = array(array('v' => 'the first value', 'f' => 'label 1'), array('v' => 19), array('v' => null), array('v' => null), array('v' => false, 'f' => 'label 3')); $table->addRowObject($dataRow); $colArray = array(); foreach ($cols as $col) { $colArray[] = DataColumn::fromArray($col); } $toCompare = $this->getRowsArrayToCompare($rows); $newRow = array(); foreach ($dataRowStrict as $cell) { $newRow['c'][] = $cell; } $toCompare[] = $newRow; $expected = array('cols' => $this->getColArray(), 'rows' => $toCompare, 'p' => array()); /*var_dump($table->toStrictArray()); echo "=======\n"; var_dump($expected);die();*/ $this->assertEquals($table->toStrictArray(), $expected); }