本文整理汇总了PHP中PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT方法的具体用法?PHP PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT怎么用?PHP PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Extensions_Database_Operation_Factory
的用法示例。
在下文中一共展示了PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'));
}
}
示例2: 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;
}
示例3: 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();
}
示例4: 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;
}
示例5: setUpBeforeClass
public static function setUpBeforeClass()
{
$config = array('dbname' => 'DBALiteTest', 'username' => 'dbalite', 'password' => 'testme', 'host' => '127.0.0.1');
$csvfile = DATA_DIR . 'TABLE_Products.csv';
$pdoObj = new PDO("pgsql:host=127.0.0.1 dbname={$config['dbname']}", $config['username'], $config['password']);
self::$phpunitConn = new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($pdoObj);
self::$dataset = new PHPUnit_Extensions_Database_Dataset_CsvDataSet();
self::$dataset->addTable('Products', $csvfile);
$setupOperation = PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT();
$setupOperation->execute(self::$phpunitConn, self::$dataset);
$driver = DBALite::factory('pgsql', $config);
$sql = 'SELECT * FROM "Products" WHERE "CategoryID" = ?';
self::$dbaliteStmt = $driver->prepare($sql);
self::$dbaliteDriver = $driver;
}
示例6: setUpBeforeClass
public static function setUpBeforeClass()
{
$dbfile = DATA_DIR . 'SqliteTest.sqlite';
$csvfile = DATA_DIR . 'TABLE_Products.csv';
$pdoObj = new PDO("sqlite:{$dbfile}");
self::$phpunitConn = new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($pdoObj);
self::$dataset = new PHPUnit_Extensions_Database_Dataset_CsvDataSet();
self::$dataset->addTable('Products', $csvfile);
$setupOperation = PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT();
$setupOperation->execute(self::$phpunitConn, self::$dataset);
$driver = DBALite::factory('sqlite', array('dbname' => $dbfile));
$sql = 'SELECT * FROM Products WHERE CategoryID = ?';
self::$dbaliteStmt = $driver->prepare($sql);
self::$dbaliteDriver = $driver;
}
示例7: __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;
}
示例8: setUp
/**
* Executed when this test case is initialized
*/
public function setUp()
{
$this->databaseTester = NULL;
// Build the PDO datasource name (DSN)
$database_dsn = Kohana::config('database.default.connection.type') . ":" . "dbname=" . Kohana::config('database.default.connection.database') . ";" . "host=" . Kohana::config('database.default.connection.host');
// Create PDO object
$pdo = new PDO($database_dsn, Kohana::config('database.default.connection.user'), Kohana::config('database.default.connection.pass'));
// Create connection
$connection = new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($pdo, Kohana::config('database.default.connection.database'));
// Set up the database tester object, setup operation and dataset
$this->databaseTester = new PHPUnit_Extensions_Database_DefaultTester($connection);
$this->databaseTester->setSetUpOperation(PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT());
// Set the dataset for the tester
$this->databaseTester->setDataSet($this->getDataSet());
// Run setup
$this->databaseTester->onSetUp();
}
示例9: 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();
}
}
示例10: getSetUpOperation
/**
* Returns the database operation executed in test setup.
*
* @return PHPUnit_Extensions_Database_Operation_DatabaseOperation
*/
protected function getSetUpOperation()
{
return PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT();
}
示例11: __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();
}
示例12: testBuild_withDefaultOperationsHasDefaultSetUpOperation
/**
* @depends testConnection
*/
public function testBuild_withDefaultOperationsHasDefaultSetUpOperation($connection)
{
$dbConfig = $this->builder->connection($connection)->dataSet($this->dataSet)->build();
$this->assertEquals(PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT(), $dbConfig->getSetUpOperation());
}
示例13: __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);
}
示例14: array
break;
default:
case 'sqlite':
$params = array('path' => PSX_PATH_CACHE . '/fusio_ui.db', 'driver' => 'pdo_sqlite');
break;
}
$config = new Doctrine\DBAL\Configuration();
$connection = Doctrine\DBAL\DriverManager::getConnection($params, $config);
$container->set('connection', $connection);
if (isset($_SERVER['argv']) && in_array('--warmup', $_SERVER['argv'])) {
// warmup
$loader->addClassMap(['Fusio\\Impl\\Fixture' => __DIR__ . '/../tests/Fixture.php', 'Fusio\\Impl\\TestSchema' => __DIR__ . '/../tests/TestSchema.php']);
// create schema
$fromSchema = $connection->getSchemaManager()->createSchema();
$version = new Fusio\Impl\Database\Version\Version010();
$toSchema = $version->getSchema();
Fusio\Impl\TestSchema::appendSchema($toSchema);
$queries = $fromSchema->getMigrateToSql($toSchema, $connection->getDatabasePlatform());
foreach ($queries as $query) {
$connection->query($query);
}
// insert fixtures
$connection = new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($container->get('connection')->getWrappedConnection());
PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT()->execute($connection, Fusio\Impl\Fixture::getDataSet());
echo 'Warmup successful' . "\n";
} else {
// run
$request = $container->get('request_factory')->createRequest();
$response = $container->get('response_factory')->createResponse();
$container->get('dispatch')->route($request, $response);
}