本文整理汇总了PHP中PHPUnit_Extensions_Database_DataSet_DefaultTable类的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Extensions_Database_DataSet_DefaultTable类的具体用法?PHP PHPUnit_Extensions_Database_DataSet_DefaultTable怎么用?PHP PHPUnit_Extensions_Database_DataSet_DefaultTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPUnit_Extensions_Database_DataSet_DefaultTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例2: 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));
}
示例3: __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;
}
}
}
示例4: __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;
}
}
示例5: 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));
}
示例6: testMatchesWithNonMatchingMetaData
public function testMatchesWithNonMatchingMetaData()
{
$tableMetaData = $this->getMock('PHPUnit_Extensions_Database_DataSet_ITableMetaData');
$otherMetaData = $this->getMock('PHPUnit_Extensions_Database_DataSet_ITableMetaData');
$otherTable = $this->getMock('PHPUnit_Extensions_Database_DataSet_ITable');
$otherTable->expects($this->once())->method('getTableMetaData')->will($this->returnValue($otherMetaData));
$tableMetaData->expects($this->once())->method('matches')->with($otherMetaData)->will($this->returnValue(false));
$table = new PHPUnit_Extensions_Database_DataSet_DefaultTable($tableMetaData);
$this->assertFalse($table->matches($otherTable));
}
示例7: 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);
}
示例8: 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);
}
示例9: __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;
}
}
示例10: __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;
}
}
示例11: 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);
}
示例12: _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;
}
示例13: 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));
}
示例14: __construct
/**
* __construct
*
* @param array $data
* @access public
* @return void
*/
public function __construct(array $data)
{
foreach ($data as $table_name => $rows) {
$columns = array();
if (isset($rows[0])) {
$columns = array_keys($rows[0]);
}
$meta_data = new \PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($table_name, $columns);
$table = new \PHPUnit_Extensions_Database_DataSet_DefaultTable($meta_data);
foreach ($rows as $row) {
$table->addRow($row);
}
$this->__tables[$table_name] = $table;
}
}
示例15: 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);
}