getRowCount() public method

Returns the number of rows in this table.
public getRowCount ( ) : integer
return integer
Example #1
0
 /**
  * @param PHPUnit_Extensions_Database_DataSet_ITable $table
  */
 protected function saveTable(PHPUnit_Extensions_Database_DataSet_ITable $table)
 {
     $rowCount = $table->getRowCount();
     $this->startTable($table);
     for ($i = 0; $i < $rowCount; $i++) {
         $this->row($table->getRow($i), $table);
     }
     $this->endTable($table);
 }
 /**
  * Adds the rows in the passed table to the current table.
  *
  * @param PHPUnit_Extensions_Database_DataSet_ITable $table
  */
 public function addTableRows(PHPUnit_Extensions_Database_DataSet_ITable $table)
 {
     $tableColumns = $this->getTableMetaData()->getColumns();
     $rowCount = $table->getRowCount();
     for ($i = 0; $i < $rowCount; $i++) {
         $newRow = array();
         foreach ($tableColumns as $columnName) {
             $newRow[$columnName] = $table->getValue($i, $columnName);
         }
         $this->addRow($newRow);
     }
 }
Example #3
0
 /**
  * Loads data into local data table if it's not already loaded
  */
 protected function loadData()
 {
     if ($this->data === NULL) {
         $data = array();
         for ($row = 0; $row < $this->originalTable->getRowCount(); $row++) {
             $tRow = array();
             foreach ($this->getTableMetaData()->getColumns() as $col) {
                 $tRow[$col] = $this->getValue($row, $col);
             }
             $data[$row] = $tRow;
         }
         $this->data = $data;
     }
 }
 /**
  * Asserts that the given table matches this table.
  *
  * @param PHPUnit_Extensions_Database_DataSet_ITable $other
  */
 public function matches(PHPUnit_Extensions_Database_DataSet_ITable $other)
 {
     $thisMetaData = $this->getTableMetaData();
     $otherMetaData = $other->getTableMetaData();
     if (!$thisMetaData->matches($otherMetaData) || $this->getRowCount() != $other->getRowCount()) {
         return FALSE;
     }
     $columns = $thisMetaData->getColumns();
     $rowCount = $this->getRowCount();
     for ($i = 0; $i < $rowCount; $i++) {
         foreach ($columns as $columnName) {
             if ($this->getValue($i, $columnName) != $other->getValue($i, $columnName)) {
                 return FALSE;
             }
         }
     }
     return TRUE;
 }
Example #5
0
 /**
  * Returns the number of rows in this table.
  *
  * @return int
  */
 public function getRowCount()
 {
     return $this->originalTable->getRowCount();
 }
Example #6
0
 /**
  * Override to save the start of a table.
  *
  * @param PHPUnit_Extensions_Database_DataSet_ITable $table
  */
 protected function startTable(PHPUnit_Extensions_Database_DataSet_ITable $table)
 {
     if ($table->getRowCount() == 0) {
         fwrite($this->fh, "\t<{$table->getTableMetaData()->getTableName()} />\n");
     }
 }
 /**
  * Asserts that the given table matches this table.
  *
  * @param PHPUnit_Extensions_Database_DataSet_ITable $other
  */
 public function assertEquals(PHPUnit_Extensions_Database_DataSet_ITable $other)
 {
     $thisMetaData = $this->getTableMetaData();
     $otherMetaData = $other->getTableMetaData();
     $thisMetaData->assertEquals($otherMetaData);
     if ($this->getRowCount() != $other->getRowCount()) {
         throw new Exception("Expected row count of {$this->getRowCount()}, has a row count of {$other->getRowCount()}");
     }
     $columns = $thisMetaData->getColumns();
     for ($i = 0; $i < $this->getRowCount(); $i++) {
         foreach ($columns as $columnName) {
             if ($this->getValue($i, $columnName) != $other->getValue($i, $columnName)) {
                 throw new Exception("Expected value of {$this->getValue($i, $columnName)} for row {$i} column {$columnName}, has a value of {$other->getValue($i, $columnName)}");
             }
         }
     }
     return TRUE;
 }