getTableMetaData() public method

Returns the table's meta data.
public getTableMetaData ( ) : PHPUnit_Extensions_Database_DataSet_ITableMetaData
return PHPUnit_Extensions_Database_DataSet_ITableMetaData
 protected function buildOperationQuery(PHPUnit_Extensions_Database_DataSet_ITableMetaData $databaseTableMetaData, PHPUnit_Extensions_Database_DataSet_ITable $table, PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection)
 {
     $keys = $databaseTableMetaData->getPrimaryKeys();
     $whereStatement = 'WHERE ' . implode(' AND ', $this->buildPreparedColumnArray($keys, $connection));
     $query = "\n\t\t\tDELETE FROM {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}\n\t\t\t{$whereStatement}\n\t\t";
     return $query;
 }
Beispiel #2
0
 protected function buildOperationQuery(PHPUnit_Extensions_Database_DataSet_ITableMetaData $databaseTableMetaData, PHPUnit_Extensions_Database_DataSet_ITable $table)
 {
     $keys = $databaseTableMetaData->getPrimaryKeys();
     $whereStatement = 'WHERE ' . implode(' AND ', $this->buildPreparedColumnArray($keys));
     $query = "\n        \tSELECT COUNT(*)\n        \tFROM {$table->getTableMetaData()->getTableName()}\n        \t{$whereStatement}\n        ";
     return $query;
 }
Beispiel #3
0
 protected function buildOperationArguments(PHPUnit_Extensions_Database_DataSet_ITableMetaData $databaseTableMetaData, PHPUnit_Extensions_Database_DataSet_ITable $table, $row)
 {
     $args = array();
     foreach ($table->getTableMetaData()->getColumns() as $columnName) {
         $args[] = $table->getValue($row, $columnName);
     }
     return $args;
 }
Beispiel #4
0
 /**
  *
  * @param PHPUnit_Extensions_Database_DataSet_ITable $table
  * @param int $rowNum
  * @return array
  */
 protected function buildInsertValues(\PHPUnit_Extensions_Database_DataSet_ITable $table, $rowNum)
 {
     $values = array();
     foreach ($table->getTableMetaData()->getColumns() as $columnName) {
         $values[$columnName] = $table->getValue($rowNum, $columnName);
     }
     return $values;
 }
Beispiel #5
0
 /**
  * Override to save a table row.
  *
  * @param array                                      $row
  * @param PHPUnit_Extensions_Database_DataSet_ITable $table
  */
 protected function row(array $row, PHPUnit_Extensions_Database_DataSet_ITable $table)
 {
     fwrite($this->fh, "\t<{$table->getTableMetaData()->getTableName()}\n");
     foreach ($table->getTableMetaData()->getColumns() as $columnName) {
         if (isset($row[$columnName])) {
             fwrite($this->fh, "\t\t{$columnName}=\"" . htmlspecialchars($row[$columnName]) . "\"\n");
         }
     }
     fwrite($this->fh, "\t/>\n");
 }
Beispiel #6
0
 /**
  *
  * @param \PHPUnit_Extensions_Database_DataSet_ITable $table
  * @param int $rowNum
  * @return array
  */
 protected function buildInsertValues(\PHPUnit_Extensions_Database_DataSet_ITable $table, $rowNum)
 {
     $values = array();
     foreach ($table->getTableMetaData()->getColumns() as $columnName) {
         try {
             $values[$columnName] = $table->getValue($rowNum, $columnName);
         } catch (FixtureValueNotExistsException $doNothing) {
         }
     }
     return $values;
 }
 /**
  * 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;
 }
Beispiel #8
0
 /**
  * Override to save a table row.
  *
  * @param array $row
  * @param PHPUnit_Extensions_Database_DataSet_ITable $table
  */
 protected function row(array $row, PHPUnit_Extensions_Database_DataSet_ITable $table)
 {
     fwrite($this->fh, "\t" . '<row>' . "\n");
     foreach ($table->getTableMetaData()->getColumns() as $columnName) {
         fwrite($this->fh, "\t\t" . '<field name="' . $columnName . '"');
         if (isset($row[$columnName])) {
             fwrite($this->fh, '>' . htmlspecialchars($row[$columnName]) . '</field>' . "\n");
         } else {
             fwrite($this->fh, ' xsi:nil="true" />' . "\n");
         }
     }
     fwrite($this->fh, "\t" . '</row>' . "\n");
 }
Beispiel #9
0
 /**
  * Creates a new table filter using the original table
  *
  * @param $originalTable PHPUnit_Extensions_Database_DataSet_ITable
  * @param $excludeColumns Array @deprecated, use the set* methods instead.
  */
 public function __construct(PHPUnit_Extensions_Database_DataSet_ITable $originalTable, array $excludeColumns = array())
 {
     $this->originalTable = $originalTable;
     $this->setTableMetaData(new PHPUnit_Extensions_Database_DataSet_TableMetaDataFilter($originalTable->getTableMetaData()));
     $this->addExcludeColumns($excludeColumns);
 }
 /**
  * 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;
 }
Beispiel #11
0
 /**
  * Override to save a table row.
  *
  * @param array $row
  * @param PHPUnit_Extensions_Database_DataSet_ITable $table
  */
 protected function row(array $row, PHPUnit_Extensions_Database_DataSet_ITable $table)
 {
     fwrite($this->fh, "\t\t<row>\n");
     foreach ($table->getTableMetaData()->getColumns() as $columnName) {
         if (isset($row[$columnName])) {
             fwrite($this->fh, "\t\t\t<value>" . htmlspecialchars($row[$columnName]) . "</value>\n");
         } else {
             fwrite($this->fh, "\t\t\t<null />\n");
         }
     }
     fwrite($this->fh, "\t\t</row>\n");
 }