/** * Get a Doctrine database connection handler * * Get a ConnectionHandler, which can be used to interact with the configured * database. The database connection string is read from an optional * environment variable "DATABASE" and defaults to an in-memory SQLite * database. * * @return \eZ\Publish\Core\Persistence\Doctrine\ConnectionHandler */ public function getDatabaseHandler() { if (!$this->handler) { $this->handler = ConnectionHandler::createFromDSN($this->getDsn()); $this->db = $this->handler->getName(); } return $this->handler; }
public function setUp() { $dsn = getenv('DATABASE'); if (!$dsn) { $dsn = 'sqlite://:memory:'; } $doctrineParams = ConnectionHandler::parseDSN($dsn); $this->connection = DriverManager::getConnection($doctrineParams); $this->handler = new ConnectionHandler($this->connection); }
/** * Get native Doctrine database connection. * * @return \Doctrine\DBAL\Connection */ public function getDatabaseConnection() { if (!$this->connection) { $this->connection = ConnectionHandler::createConnectionFromDSN($this->getDsn()); } return $this->connection; }
public function testSqliteConnectionSubtype() { $handler = ConnectionHandler::createFromDSN('sqlite://:memory:'); $this->assertInstanceOf('eZ\\Publish\\Core\\Persistence\\Doctrine\\ConnectionHandler\\SqliteConnectionHandler', $handler); }