I am currently using PHPUnit and DBUnit for my project. I have a problem in DBUnit because DBUnit PHPUnit_Extensions_Database_TestCaseSrc class does not seem to be truncating the existing data on the test db. So this makes my insertion tests fail after only working for one time.
I am using mysql and here is my code :
abstract class Generic_Tests_DatabaseTestCase extends PHPUnit_Extensions_Database_TestCase { // only instantiate pdo once for test clean-up/fixture load static private $pdo = null; // only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test private $conn = null; final public function getConnection() { if ($this->conn === null) { if (self::$pdo == null) { self::$pdo = new PDO( "mysql:dbname=db;host=localhost", "root", "pass" ); } $this->conn = $this->createDefaultDBConnection(self::$pdo, "db"); } return $this->conn; } } class DbopTest extends Generic_Tests_DatabaseTestCase { private $db; protected function setup(){ $this->db = null; } public function getDataSet(){ return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/../rows.xml'); } ... } So how can I fix this problem? What is it that I do wrong here?
setUp()method. Please check ifgetDataSet()is still being called.