I'm pretty new to php testing involving databases, and I'm kind of stuck here. The code below should in my opinion prepare the given database in a certain state and then run the test, however it does not prepare the database, moreover the getDataset etc methods are never called, and I can't figure out why.
Here's the code:
Code: Select all
class PublicTest extends PHPUnit_Extensions_Database_TestCase
{
protected $pdo;
protected $config;
protected $CUT;
public function __construct() {
$this->config = new TestConfigurator();
$this->pdo = new PDO( 'mysql:host='.$this->config->getMYSQL('host').';dbname='.$this->config->getMYSQL('db'),
$this->config->getMYSQL('usr'),
$this->config->getMYSQL('pass'));
}
protected function getConnection()
{
echo "getConnection\n";
return $this->createDefaultDBConnection($this->pdo, $this->config->getMYSQL('db'));
}
protected function getDataSet()
{
echo "getDataSet\n";
return $this->createXMLDataSet(dirname(__FILE__).'/datasets/UpdateCustomerPasswordStatePre.xml');
}
protected function getSetUpOperation()
{
return $this->getOperations()->CLEAN_INSERT();
}
public function testConstructor() {
//do something, throws exception, if database is not in expected state
}
protected function setUp() {
//...
}
protected function tearDown() {
//...
}
}
I'd highly appreciate it if someone could point out my mistake !
Thanks a lot in advance
Cheers
Mischa