public function testSimpleTesterSetupAndRowsetEquals() { $dataSet = new \PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet(__DIR__ . "/_files/sqliteIntegrationFixture.xml"); $fooDataTable = $dataSet->getTable("foo"); $tester = new \Zend\Test\PHPUnit\Db\SimpleTester($this->getConnection()); $tester->setUpDatabase($dataSet); $fooTable = $this->createFooTable(); $rows = $fooTable->fetchAll(); $this->assertEquals(3, count($rows)); $rowsetTable = new DataSet\DbRowset($rows); $rowsetTable->assertEquals($fooDataTable); }
public function testSimpleTesterSetupAndRowsetEquals() { $dataSet = new PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet(dirname(__FILE__) . "/_files/sqliteIntegrationFixture.xml"); $fooDataTable = $dataSet->getTable("foo"); $tester = new Zend_Test_PHPUnit_Db_SimpleTester($this->getConnection()); $tester->setUpDatabase($dataSet); $fooTable = $this->createFooTable(); $rows = $fooTable->fetchAll(); $this->assertEquals(3, count($rows)); $rowsetTable = new Zend_Test_PHPUnit_Db_DataSet_DbRowset($rows); if (method_exists($rowsetTable, 'assertEquals')) { $rowsetTable->assertEquals($fooDataTable); } else { $rowsetTable->matches($fooDataTable); } }
public function testFlatXml() { $dataSetFile = dirname(__FILE__) . '/../_files/XmlDataSets/FlatXmlWriter.xml'; $filename = dirname(__FILE__) . '/' . uniqid() . '.xml'; $dataSet = new PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet($dataSetFile); PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet::write($dataSet, $filename); $this->assertXmlFileEqualsXmlFile($dataSetFile, $filename); unlink($filename); }
public function testEntitiesFlatXml() { $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/FlatXmlWriterEntities.xml'; $filename = dirname(__FILE__) . '/' . uniqid() . '.xml'; PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet::write($dataSet, $filename); $this->assertXmlFileEqualsXmlFile($expectedFile, $filename); unlink($filename); }
public function testUpdatePost() { $post = Post::findOne(2); $post->title = 'Updated post title 2'; $post->body = 'Updated post body 2'; $post->translate('de-DE')->title = 'Aktualisiert post titel 2'; $post->translate('de-DE')->body = 'Aktualisiert post inhalt 2'; $post->translate('ru-RU')->title = 'Обновленный заголовок поста 2'; $post->translate('ru-RU')->body = 'Обновленное тело поста 2'; $this->assertTrue($post->save()); $dataSet = $this->getConnection()->createDataSet(['post', 'post_translation']); \PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet::write($dataSet, __DIR__ . '/data/test-update-post.xml'); $expectedDataSet = $this->createFlatXMLDataSet(__DIR__ . '/data/test-update-post.xml'); $this->assertDataSetsEqual($expectedDataSet, $dataSet); }