Php 内存中Sqlite的带条令的Init模式
我想在单元测试中使用内存中的sqlite库 dbunit的文档以sqlite为例():Php 内存中Sqlite的带条令的Init模式,php,sqlite,doctrine-orm,phpunit,Php,Sqlite,Doctrine Orm,Phpunit,我想在单元测试中使用内存中的sqlite库 dbunit的文档以sqlite为例(): 但是我找不到使用条令初始化数据库模式的方法。我终于找到了一种方法(灵感使用::将DBunit与条令ORM一起使用) public function getConnection() { $pdo = new PDO('sqlite::memory:'); return $this->createDefaultDBConnection($pdo, ':memory:'); } public
但是我找不到使用条令初始化数据库模式的方法。我终于找到了一种方法(灵感使用::将DBunit与条令ORM一起使用)
public function getConnection() {
$pdo = new PDO('sqlite::memory:');
return $this->createDefaultDBConnection($pdo, ':memory:');
}
public function getConnection() {
// create entity manager following the doctrine way
$this->entityManager = require(__DIR__ . '/config/bootstrap.php');
// init database schema
$schemaTool = new SchemaTool($this->entityManager);
$schemaTool->createSchema($this->entityManager->getMetadataFactory()->getAllMetadata());
// get pdo
$pdo = $this->entityManager->getConnection()->getWrappedConnection();
// create connection
return $this->createDefaultDBConnection($pdo, ':memory:');
}