本文整理汇总了PHP中PHPUnit_Extensions_Database_DataSet_DefaultTable::addRow方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Extensions_Database_DataSet_DefaultTable::addRow方法的具体用法?PHP PHPUnit_Extensions_Database_DataSet_DefaultTable::addRow怎么用?PHP PHPUnit_Extensions_Database_DataSet_DefaultTable::addRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Extensions_Database_DataSet_DefaultTable
的用法示例。
在下文中一共展示了PHPUnit_Extensions_Database_DataSet_DefaultTable::addRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetTable_b
public function testGetTable_b()
{
$expected = new PHPUnit_Extensions_Database_DataSet_DefaultTable(new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData('table_b', array('id', 'pet')));
$expected->addRow(array('id' => 1, 'pet' => 'dog'));
$expected->addRow(array('id' => 2, 'pet' => 'cat'));
$this->assertThat($this->data_set->getTable('table_b'), new PHPUnit_Extensions_Database_Constraint_TableIsEqual($expected));
}
示例2: testAssertEqualsFails
public function testAssertEqualsFails()
{
$expected_table = new PHPUnit_Extensions_Database_DataSet_DefaultTable(new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData('table1', array('col1', 'col2', 'col3')));
$expected_table->addRow(array('col1' => 'value1', 'col2' => 'value2', 'col3' => 'value3'));
$expected_table->addRow(array('col1' => 'value4', 'col2' => 'value5', 'col3' => 'value6'));
$expected_table->addRow(array('col1' => 'value7', 'col2' => 'value8', 'col3' => 'value9'));
$this->assertFalse($this->table->matches($expected_table));
}
示例3: testConstructorReplacements
public function testConstructorReplacements()
{
$tableMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData('table1', array('table1_id', 'column1', 'column2', 'column3', 'column4'));
$table = new PHPUnit_Extensions_Database_DataSet_DefaultTable($tableMetaData);
$table->addRow(array('table1_id' => 1, 'column1' => 'My name is Mike Lively', 'column2' => 200, 'column3' => 34.64, 'column4' => 'yghkf;a hahfg8ja h;'));
$table->addRow(array('table1_id' => 2, 'column1' => 'hk;afg', 'column2' => 654, 'column3' => 46.54, 'column4' => '24rwehhads'));
$table->addRow(array('table1_id' => 3, 'column1' => 'ha;gyt', 'column2' => 462, 'column3' => '[NULL] not really', 'column4' => NULL));
$actual = new PHPUnit_Extensions_Database_DataSet_ReplacementTable($this->startingTable, array('[NULL]' => NULL), array('%%%name%%%' => 'Mike Lively'));
PHPUnit_Extensions_Database_TestCase::assertTablesEqual($table, $actual);
}
示例4: setUp
public function setUp()
{
$table1MetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData('table1', array('table1_id', 'column1', 'column2', 'column3', 'column4'));
$table2MetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData('table2', array('table2_id', 'column5', 'column6', 'column7', 'column8'));
$table1 = new PHPUnit_Extensions_Database_DataSet_DefaultTable($table1MetaData);
$table2 = new PHPUnit_Extensions_Database_DataSet_DefaultTable($table2MetaData);
$table1->addRow(array('table1_id' => 1, 'column1' => 'tgfahgasdf', 'column2' => 200, 'column3' => 34.64, 'column4' => 'yghkf;a hahfg8ja h;'));
$table1->addRow(array('table1_id' => 2, 'column1' => 'hk;afg', 'column2' => 654, 'column3' => 46.54, 'column4' => '24rwehhads'));
$table1->addRow(array('table1_id' => 3, 'column1' => 'ha;gyt', 'column2' => 462, 'column3' => 1654.4, 'column4' => 'asfgklg'));
$table2->addRow(array('table2_id' => 1, 'column5' => 'fhah', 'column6' => 456, 'column7' => 46.5, 'column8' => 'fsdbghfdas'));
$table2->addRow(array('table2_id' => 2, 'column5' => 'asdhfoih', 'column6' => 654, 'column7' => NULL, 'column8' => '43asdfhgj'));
$table2->addRow(array('table2_id' => 3, 'column5' => 'ajsdlkfguitah', 'column6' => 654, 'column7' => NULL, 'column8' => NULL));
$this->expectedDataSet = new PHPUnit_Extensions_Database_DataSet_DefaultDataSet(array($table1, $table2));
}
示例5: testConstructorReplacements
public function testConstructorReplacements()
{
$table1MetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData('table1', array('table1_id', 'column1', 'column2', 'column3', 'column4'));
$table2MetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData('table2', array('table2_id', 'column5', 'column6', 'column7', 'column8'));
$table1 = new PHPUnit_Extensions_Database_DataSet_DefaultTable($table1MetaData);
$table2 = new PHPUnit_Extensions_Database_DataSet_DefaultTable($table2MetaData);
$table1->addRow(array('table1_id' => 1, 'column1' => 'My name is Mike Lively', 'column2' => 200, 'column3' => 34.64, 'column4' => 'yghkf;a hahfg8ja h;'));
$table1->addRow(array('table1_id' => 2, 'column1' => 'hk;afg', 'column2' => 654, 'column3' => 46.54, 'column4' => '24rwehhads'));
$table1->addRow(array('table1_id' => 3, 'column1' => 'ha;gyt', 'column2' => 462, 'column3' => 1654.4, 'column4' => NULL));
$table2->addRow(array('table2_id' => 1, 'column5' => 'fhah', 'column6' => 456, 'column7' => 46.5, 'column8' => 'My name is Mike Lively'));
$table2->addRow(array('table2_id' => 2, 'column5' => 'asdhfoih', 'column6' => 654, 'column7' => NULL, 'column8' => '43asdfhgj'));
$table2->addRow(array('table2_id' => 3, 'column5' => 'ajsdlkfguitah', 'column6' => 654, 'column7' => NULL, 'column8' => '[NULL] not really'));
$expected = new PHPUnit_Extensions_Database_DataSet_DefaultDataSet(array($table1, $table2));
$actual = new PHPUnit_Extensions_Database_DataSet_ReplacementDataSet($this->startingDataSet, array('[NULL]' => NULL), array('%%%name%%%' => 'Mike Lively'));
PHPUnit_Extensions_Database_TestCase::assertDataSetsEqual($expected, $actual);
}
示例6: __construct
/**
* Construct a new PHPUnit_ArrayDataSet object.
* @param array $data An array of data.
* @param True if the data array is a result of a PDO query, false otherwise.
*/
public function __construct(array $data, $pdo = false)
{
if ($pdo) {
$tableName = 'Table';
$columns = array();
if (isset($data[0])) {
$columns = array_keys(get_object_vars($data[0]));
}
$metaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $columns);
$table = new PHPUnit_Extensions_Database_DataSet_DefaultTable($metaData);
foreach ($data as $row) {
$table->addRow(get_object_vars($row));
}
$this->tables[$tableName] = $table;
} else {
foreach ($data as $tableName => $rows) {
$columns = array();
if (isset($rows[0])) {
$columns = array_keys($rows[0]);
}
$metaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $columns);
$table = new PHPUnit_Extensions_Database_DataSet_DefaultTable($metaData);
foreach ($rows as $row) {
$table->addRow($row);
}
$this->tables[$tableName] = $table;
}
}
}
示例7: __construct
/**
* @param array $data
*/
public function __construct(array $data)
{
foreach ($data as $tableName => $rows) {
$firstrow = reset($rows);
if (array_key_exists(0, $firstrow)) {
// columns in first row
$columnsInFirstRow = true;
$columns = $firstrow;
$key = key($rows);
unset($rows[$key]);
} else {
// column name is in each row as key
$columnsInFirstRow = false;
$columns = array_keys($firstrow);
}
$metaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $columns);
$table = new PHPUnit_Extensions_Database_DataSet_DefaultTable($metaData);
foreach ($rows as $row) {
if ($columnsInFirstRow) {
$row = array_combine($columns, $row);
}
$table->addRow($row);
}
$this->tables[$tableName] = $table;
}
}
示例8: testExceptionOnIncompatibleTablesSameTableNames2
/**
* @expectedException InvalidArgumentException
* @expectedExceptionMessage There is already a table named table3 with different table definition
*/
public function testExceptionOnIncompatibleTablesSameTableNames2()
{
$inCompatibleTableMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData('table3', array('table3_id', 'column13', 'column14', 'column15', 'column16'));
$inCompatibleTable = new PHPUnit_Extensions_Database_DataSet_DefaultTable($inCompatibleTableMetaData);
$inCompatibleTable->addRow(array('column13' => 'asdasda asdasd', 'column14' => 'aiafsjas asd', 'column15' => 'asdasdasd', 'column16' => 2141));
$compositeDataSet = new PHPUnit_Extensions_Database_DataSet_CompositeDataSet(array(new PHPUnit_Extensions_Database_DataSet_DefaultDataSet(array($inCompatibleTable)), $this->expectedDataSet2));
}
示例9: testYamlDataSet
public function testYamlDataSet()
{
$table1MetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData('table1', array('table1_id', 'column1', 'column2', 'column3', 'column4'));
$table2MetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData('table2', array('table2_id', 'column5', 'column6', 'column7', 'column8'));
$table1 = new PHPUnit_Extensions_Database_DataSet_DefaultTable($table1MetaData);
$table2 = new PHPUnit_Extensions_Database_DataSet_DefaultTable($table2MetaData);
$table1->addRow(array('table1_id' => 1, 'column1' => 'tgfahgasdf', 'column2' => 200, 'column3' => 34.64, 'column4' => 'yghkf;a hahfg8ja h;'));
$table1->addRow(array('table1_id' => 2, 'column1' => 'hk;afg', 'column2' => 654, 'column3' => 46.54, 'column4' => '24rwehhads'));
$table1->addRow(array('table1_id' => 3, 'column1' => 'ha;gyt', 'column2' => 462, 'column3' => 1654.4, 'column4' => 'asfgklg'));
$table2->addRow(array('table2_id' => 1, 'column5' => 'fhah', 'column6' => 456, 'column7' => 46.5, 'column8' => 'fsdb, ghfdas'));
$table2->addRow(array('table2_id' => 2, 'column5' => 'asdhfoih', 'column6' => 654, 'column7' => 'blah', 'column8' => '43asd "fhgj" sfadh'));
$table2->addRow(array('table2_id' => 3, 'column5' => 'ajsdlkfguitah', 'column6' => 654, 'column7' => 'blah', 'column8' => 'thesethasdl
asdflkjsadf asdfsadfhl "adsf, halsdf" sadfhlasdf'));
$expectedDataSet = new PHPUnit_Extensions_Database_DataSet_DefaultDataSet(array($table1, $table2));
$yamlDataSet = new PHPUnit_Extensions_Database_DataSet_YamlDataSet(dirname(__FILE__) . '/../_files/YamlDataSets/testDataSet.yaml');
PHPUnit_Extensions_Database_DataSet_YamlDataSet::write($yamlDataSet, '/tmp/yaml.dataset');
PHPUnit_Extensions_Database_TestCase::assertDataSetsEqual($expectedDataSet, $yamlDataSet);
}
示例10: testCSVDataSet
public function testCSVDataSet()
{
$table1MetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData('table1', ['table1_id', 'column1', 'column2', 'column3', 'column4']);
$table2MetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData('table2', ['table2_id', 'column5', 'column6', 'column7', 'column8']);
$table1 = new PHPUnit_Extensions_Database_DataSet_DefaultTable($table1MetaData);
$table2 = new PHPUnit_Extensions_Database_DataSet_DefaultTable($table2MetaData);
$table1->addRow(['table1_id' => 1, 'column1' => 'tgfahgasdf', 'column2' => 200, 'column3' => 34.64, 'column4' => 'yghkf;a hahfg8ja h;']);
$table1->addRow(['table1_id' => 2, 'column1' => 'hk;afg', 'column2' => 654, 'column3' => 46.54, 'column4' => '24rwehhads']);
$table1->addRow(['table1_id' => 3, 'column1' => 'ha;gyt', 'column2' => 462, 'column3' => 1654.4, 'column4' => 'asfgklg']);
$table2->addRow(['table2_id' => 1, 'column5' => 'fhah', 'column6' => 456, 'column7' => 46.5, 'column8' => 'fsdb, ghfdas']);
$table2->addRow(['table2_id' => 2, 'column5' => 'asdhfoih', 'column6' => 654, 'column7' => 'blah', 'column8' => '43asd "fhgj" sfadh']);
$table2->addRow(['table2_id' => 3, 'column5' => 'ajsdlkfguitah', 'column6' => 654, 'column7' => 'blah', 'column8' => 'thesethasdl
asdflkjsadf asdfsadfhl "adsf, halsdf" sadfhlasdf']);
$expectedDataSet = new PHPUnit_Extensions_Database_DataSet_DefaultDataSet([$table1, $table2]);
$csvDataSet = new PHPUnit_Extensions_Database_DataSet_CsvDataSet();
$csvDataSet->addTable('table1', dirname(__FILE__) . '/../_files/CsvDataSets/table1.csv');
$csvDataSet->addTable('table2', dirname(__FILE__) . '/../_files/CsvDataSets/table2.csv');
PHPUnit_Extensions_Database_TestCase::assertDataSetsEqual($expectedDataSet, $csvDataSet);
}
示例11: testAlternateParser
public function testAlternateParser()
{
$table1MetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData('math_table', ['answer']);
$table1 = new PHPUnit_Extensions_Database_DataSet_DefaultTable($table1MetaData);
$table1->addRow(['answer' => 'pi/2']);
$expectedDataSet = new PHPUnit_Extensions_Database_DataSet_DefaultDataSet([$table1]);
$parser = new Extensions_Database_DataSet_YamlDataSetTest_PiOver2Parser();
$yamlDataSet = new PHPUnit_Extensions_Database_DataSet_YamlDataSet(dirname(__FILE__) . '/../_files/YamlDataSets/testDataSet.yaml', $parser);
PHPUnit_Extensions_Database_TestCase::assertDataSetsEqual($expectedDataSet, $yamlDataSet);
}
示例12: __construct
/**
* @param array $data
*/
public function __construct(array $data)
{
foreach ($data as $tableName => $rows) {
$meta = new \PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, isset($rows[0]) ? array_keys($rows[0]) : array());
$table = new \PHPUnit_Extensions_Database_DataSet_DefaultTable($meta);
foreach ($rows as $row) {
$table->addRow($row);
}
$this->_tables[$tableName] = $table;
}
}
示例13: __construct
public function __construct(array $data, array $tables = array())
{
$this->tables = $tables;
foreach ($data as $table_name => $rows) {
$table = new PHPUnit_Extensions_Database_DataSet_DefaultTable(new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($table_name, $this->getColumns($rows)));
foreach ($rows as $row) {
$table->addRow($row);
}
$this->tables[$table_name] = $table;
}
}
示例14: testEntitiesXml
public function testEntitiesXml()
{
$metaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData('table1', array('col1', 'col2'), array('col1'));
$table = new PHPUnit_Extensions_Database_DataSet_DefaultTable($metaData);
$table->addRow(array('col1' => 1, 'col2' => '<?xml version="1.0"?><myxml>test</myxml>'));
$dataSet = new PHPUnit_Extensions_Database_DataSet_DefaultDataSet(array($table));
$expectedFile = dirname(__FILE__) . '/../_files/XmlDataSets/XmlWriterEntities.xml';
$filename = dirname(__FILE__) . '/' . uniqid() . '.xml';
PHPUnit_Extensions_Database_DataSet_XmlDataSet::write($dataSet, $filename);
$this->assertXmlFileEqualsXmlFile($expectedFile, $filename);
unlink($filename);
}
示例15: _arrayToDataSet
private function _arrayToDataSet(array $toConvert, $tableName = 'theTable')
{
$columns = array();
if (isset($toConvert[0])) {
$columns = array_keys($toConvert[0]);
}
$metaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $columns);
$table = new PHPUnit_Extensions_Database_DataSet_DefaultTable($metaData);
foreach ($toConvert as $row) {
$table->addRow($row);
}
return $table;
}