Автор: Mike Lively (m@digitalsandwich.com)
Наследование: extends PHPUnit_Extensions_Database_AbstractTester
Пример #1
0
 protected function getDatabaseTester()
 {
     $tester = new PHPUnit_Extensions_Database_DefaultTester($this->_conn);
     $tester->setSetUpOperation(new PHPUnit_Extensions_Database_Operation_Composite(array(new DB_operation_set_env('foreign_key_checks', 0), PHPUnit_Extensions_Database_Operation_Factory::DELETE_ALL(), new DB_operation_set_env('foreign_key_checks', 1), PHPUnit_Extensions_Database_Operation_Factory::INSERT())));
     $tester->setTearDownOperation(PHPUnit_Extensions_Database_Operation_Factory::NONE());
     return $tester;
 }
 /**
  * @return PHPUnit_Extensions_Database_DefaultTester
  */
 protected function getDatabaseTester()
 {
     $connection = new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($this->pdo, 'sqlite');
     $tester = new PHPUnit_Extensions_Database_DefaultTester($connection);
     $tester->setSetUpOperation(PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT());
     $tester->setTearDownOperation(PHPUnit_Extensions_Database_Operation_Factory::NONE());
     $tester->setDataSet(new PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet(dirname(__FILE__) . '/_files/bank-account-seed.xml'));
     return $tester;
 }
Пример #3
0
 protected function getDatabaseTester()
 {
     $pdo = new PDO('mysql:host=localhost;dbname=c3op', 'root', '');
     $connection = new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($pdo, 'c3op');
     $tester = new PHPUnit_Extensions_Database_DefaultTester($connection);
     $tester->setSetUpOperation(PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT());
     $tester->setTearDownOperation(PHPUnit_Extensions_Database_Operation_Factory::NONE());
     $tester->setDataSet(new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet(dirname(__FILE__) . '/fixture/projects_seed.xml'));
     return $tester;
 }
Пример #4
0
 public function applyTo(Database $db)
 {
     $pdo = $db->getPdo();
     $connection = new \PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($pdo, $db->getName());
     $databasetester = new \PHPUnit_Extensions_Database_DefaultTester($connection);
     $setupoperation = \PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT();
     $databasetester->setSetUpOperation($setupoperation);
     $databasetester->setDataSet($this->dataset);
     $databasetester->onSetUp();
 }
    function __construct()
    {
    // connect for unit testing framework
        $pdo = new PDO('mysql:host=' . HOST . ';dbname=' .
            DB_NAME, USERNAME, PASSWORD);

        $connection = new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($pdo, 'test');
        $tester     = new PHPUnit_Extensions_Database_DefaultTester($connection);

        $tester->setSetUpOperation(PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT());
        $tester->setTearDownOperation(PHPUnit_Extensions_Database_Operation_Factory::NONE());
        $tester->setDataSet(new PHPUnit_Extensions_Database_DataSet_FlatXMLDataSet
            (dirname(__FILE__).'/../models/files/users.xml'));

        $this->tester = $tester;
    }
Пример #6
0
 /**
  * @param PHPUnit_Extensions_MultipleDatabase_DatabaseConfig
  */
 public function __construct($dbConfig)
 {
     parent::__construct($dbConfig->getConnection());
     $this->setDataSet($dbConfig->getDataSet());
     $this->setSetUpOperation($dbConfig->getSetUpOperation());
     $this->setTearDownOperation($dbConfig->getTearDownOperation());
 }