本文整理汇总了PHP中PHPUnit_Extensions_Database_Operation_Factory类的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Extensions_Database_Operation_Factory类的具体用法?PHP PHPUnit_Extensions_Database_Operation_Factory怎么用?PHP PHPUnit_Extensions_Database_Operation_Factory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPUnit_Extensions_Database_Operation_Factory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSetUpOperation
public function getSetUpOperation()
{
// whether you want cascading truncates
// set false if unsure
$cascadeTruncates = false;
return new PHPUnit_Extensions_Database_Operation_Composite(array(new PHPUnit_Extensions_Database_Operation_MySQL55Truncate($cascadeTruncates), PHPUnit_Extensions_Database_Operation_Factory::INSERT()));
}
示例2: seedDatabases
private function seedDatabases()
{
foreach (self::$conns as $i => $conn) {
$setUpOperation = \PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT();
$setUpOperation->execute($conn, $this->createXMLDataSet(dirname(__FILE__) . '/multi_seed' . $i . '.xml'));
}
}
示例3: getSetUpOperation
public function getSetUpOperation()
{
$cascadeTruncates = TRUE;
//if you want cascading truncates, false otherwise
//if unsure choose false
return new \PHPUnit_Extensions_Database_Operation_Composite(array(new Operation\MySQLTruncate($cascadeTruncates), \PHPUnit_Extensions_Database_Operation_Factory::INSERT()));
}
示例4: getDatabaseTester
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;
}
示例5: __construct
/**
* Creates a new default database tester using the given connection.
*
* @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection
*/
public function __construct(\PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection)
{
if (!$connection instanceof Connection) {
throw new InvalidArgumentException("Not a valid Zend_Test_PHPUnit_Db_Connection instance, " . get_class($connection) . " given!");
}
$this->connection = $connection;
$this->setUpOperation = new \PHPUnit_Extensions_Database_Operation_Composite(array(new Operation\Truncate(), new Operation\Insert()));
$this->tearDownOperation = \PHPUnit_Extensions_Database_Operation_Factory::NONE();
}
示例6: tearDown
/**
* Tear down operation - Executed when the test is complete
*/
public function tearDown()
{
// Tear down operation
$this->databaseTester->setTearDownOperation(PHPUnit_Extensions_Database_Operation_Factory::TRUNCATE());
$this->databaseTester->setDataSet($this->getDataSet());
$this->databaseTester->onTearDown();
// Garbage collection
unset($this->databaseTester);
}
示例7: getDatabaseTester
/**
* @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;
}
示例8: __construct
/**
* Creates a new default database tester using the given connection.
*
* @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection
*/
public function __construct(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection)
{
if (!$connection instanceof Zend_Test_PHPUnit_Db_Connection) {
#require_once "Zend/Test/PHPUnit/Db/Exception.php";
throw new Zend_Test_PHPUnit_Db_Exception("Not a valid Zend_Test_PHPUnit_Db_Connection instance, " . get_class($connection) . " given!");
}
$this->connection = $connection;
$this->setUpOperation = new PHPUnit_Extensions_Database_Operation_Composite(array(new Zend_Test_PHPUnit_Db_Operation_Truncate(), new Zend_Test_PHPUnit_Db_Operation_Insert()));
$this->tearDownOperation = PHPUnit_Extensions_Database_Operation_Factory::NONE();
}
示例9: applyTo
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();
}
示例10: getDatabaseTester
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;
}
示例11: __construct
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;
}
示例12: getSetUpOperation
protected function getSetUpOperation()
{
if (self::$_oldDataset == null)
{
return PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT(true);
}
else if (self::$_oldDataset != $this->_dataset)
{
$truncate = PHPUnit_Extensions_Database_Operation_Factory::TRUNCATE(true);
$truncate->execute($this->getConnection(),
$this->createFlatXMLDataSet(self::$_oldDataset));
return PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT(true);
}
else
{
return PHPUnit_Extensions_Database_Operation_Factory::NONE();
}
}
示例13: __construct
/**
* Creates a new database tester.
*
* @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection
*/
public function __construct()
{
$this->setUpOperation = PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT();
$this->tearDownOperation = PHPUnit_Extensions_Database_Operation_Factory::NONE();
}
示例14: getSetUpOperation
/**
* Use our own truncate operation so that we can work with InnoDB foreign
* keys constraints.
*
* @see http://stackoverflow.com/questions/10331445/phpunit-and-mysql-truncation-error
* @return \PHPUnit_Extensions_Database_Operation_Composite
*/
public function getSetUpOperation()
{
return new \PHPUnit_Extensions_Database_Operation_Composite(array(new TruncateOperation(true), \PHPUnit_Extensions_Database_Operation_Factory::INSERT()));
}
示例15: __construct
public function __construct(\PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection, $fixturePath)
{
parent::__construct($connection, $fixturePath);
$this->setUpOperation = \PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT(true);
}