I am trying to run very simple PHPUnit testing class with Database simulation. I am trying to create dataset with some values. I am using MySQL XML object.
My MySQL XML Object is:
<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="some_test_db">
<table_data name="some_test_table">
<row>
<field name="id">1</field>
<field name="content_time">1382774967</field>
<field name="ip">10.0.0.10</field>
<field name="content">test message</field>
</row>
</table_data>
</database>
</mysqldump>
My PHP code in the testing class is:
<?php
class TestOfDatabase extends PHPUnit_Extensions_Database_TestCase {
protected $pdo;
public function __construct() {
$this->pdo = new PDO('sqlite::memory:');
}
protected function setUp() {
$this->getConnection()->createDataSet();
}
/**
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
*/
public function getConnection() {
return $this->createDefaultDBConnection($this->pdo, 'sqlite');
}
/**
* @return PHPUnit_Extensions_Database_DataSet_IDataSet
*/
public function getDataSet() {
return $this->createMySQLXMLDataSet(dirname(__FILE__).'/dataset.xml');
}
public function testGetInstance() {
$this->assertGreaterThan(0, $this->getConnection()->getRowCount('some_test_table'));
}
}
When I am running TestofDatabase I get "General error 1: no such table: some_test_table".
I can't understand why the mock DB is not being populated with the data that I inserted to dataset.xml.
I already checked that the path is OK.