[2.0] Some fixes for ClassExporterTest.
This commit is contained in:
parent
32d43c365f
commit
87fd08e427
@ -181,6 +181,16 @@ class Connection
|
|||||||
$this->_transactionIsolationLevel = $this->_platform->getDefaultTransactionIsolationLevel();
|
$this->_transactionIsolationLevel = $this->_platform->getDefaultTransactionIsolationLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the DBAL driver instance.
|
||||||
|
*
|
||||||
|
* @return Doctrine\DBAL\Driver
|
||||||
|
*/
|
||||||
|
public function getDriver()
|
||||||
|
{
|
||||||
|
return $this->_driver;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Configuration used by the Connection.
|
* Gets the Configuration used by the Connection.
|
||||||
*
|
*
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* This software consists of voluntary contributions made by many individuals
|
* This software consists of voluntary contributions made by many individuals
|
||||||
* and is licensed under the LGPL. For more information, see
|
* and is licensed under the LGPL. For more information, see
|
||||||
* <http://www.phpdoctrine.org>.
|
* <http://www.doctrine-project.org>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Doctrine\DBAL;
|
namespace Doctrine\DBAL;
|
||||||
|
@ -1013,13 +1013,13 @@ abstract class AbstractPlatform
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = 'CREATE TABLE ' . $this->conn->quoteIdentifier($name, true) . ' (' . $queryFields;
|
$query = 'CREATE TABLE ' . $this->quoteIdentifier($table, true) . ' (' . $queryFields;
|
||||||
|
|
||||||
$check = $this->getCheckDeclaration($columns);
|
/*$check = $this->getCheckDeclaration($columns);
|
||||||
|
|
||||||
if ( ! empty($check)) {
|
if ( ! empty($check)) {
|
||||||
$query .= ', ' . $check;
|
$query .= ', ' . $check;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
$query .= ')';
|
$query .= ')';
|
||||||
|
|
||||||
|
@ -114,7 +114,6 @@ class MySqlPlatform extends AbstractPlatform
|
|||||||
);*/
|
);*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
|
||||||
* Creates a new MySqlPlatform instance.
|
* Creates a new MySqlPlatform instance.
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@ -1041,56 +1040,43 @@ class MySqlPlatform extends AbstractPlatform
|
|||||||
*/
|
*/
|
||||||
public function getIntegerTypeDeclarationSql(array $field)
|
public function getIntegerTypeDeclarationSql(array $field)
|
||||||
{
|
{
|
||||||
return 'INT ' . $this->_getCommonIntegerTypeDeclarationSql($field);
|
return 'INT' . $this->_getCommonIntegerTypeDeclarationSql($field);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
public function getBigIntTypeDeclarationSql(array $field)
|
public function getBigIntTypeDeclarationSql(array $field)
|
||||||
{
|
{
|
||||||
return 'BIGINT ' . $this->_getCommonIntegerTypeDeclarationSql($field);
|
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSql($field);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
public function getTinyIntTypeDeclarationSql(array $field)
|
public function getTinyIntTypeDeclarationSql(array $field)
|
||||||
{
|
{
|
||||||
return 'TINYINT ' . $this->_getCommonIntegerTypeDeclarationSql($field);
|
return 'TINYINT' . $this->_getCommonIntegerTypeDeclarationSql($field);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
public function getSmallIntTypeDeclarationSql(array $field)
|
public function getSmallIntTypeDeclarationSql(array $field)
|
||||||
{
|
{
|
||||||
return 'SMALLINT ' . $this->_getCommonIntegerTypeDeclarationSql($field);
|
return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSql($field);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
public function getMediumIntTypeDeclarationSql(array $field)
|
public function getMediumIntTypeDeclarationSql(array $field)
|
||||||
{
|
{
|
||||||
return 'MEDIUMINT ' . $this->_getCommonIntegerTypeDeclarationSql($field);
|
return 'MEDIUMINT' . $this->_getCommonIntegerTypeDeclarationSql($field);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
protected function _getCommonIntegerTypeDeclarationSql(array $columnDef)
|
protected function _getCommonIntegerTypeDeclarationSql(array $columnDef)
|
||||||
{
|
{
|
||||||
$default = $autoinc = '';
|
$autoinc = '';
|
||||||
if ( ! empty($columnDef['autoincrement'])) {
|
if ( ! empty($columnDef['autoincrement'])) {
|
||||||
$autoinc = ' AUTO_INCREMENT';
|
$autoinc = ' AUTO_INCREMENT';
|
||||||
} elseif (array_key_exists('default', $columnDef)) {
|
|
||||||
if ($columnDef['default'] === '') {
|
|
||||||
$columnDef['default'] = empty($columnDef['notnull']) ? null : 0;
|
|
||||||
}
|
}
|
||||||
if (is_null($columnDef['default'])) {
|
|
||||||
$default = ' DEFAULT NULL';
|
|
||||||
} else {
|
|
||||||
$default = ' DEFAULT '.$this->quote($columnDef['default']);
|
|
||||||
}
|
|
||||||
} elseif (empty($columnDef['notnull'])) {
|
|
||||||
$default = ' DEFAULT NULL';
|
|
||||||
}
|
|
||||||
|
|
||||||
$notnull = (isset($columnDef['notnull']) && $columnDef['notnull']) ? ' NOT NULL' : '';
|
|
||||||
$unsigned = (isset($columnDef['unsigned']) && $columnDef['unsigned']) ? ' UNSIGNED' : '';
|
$unsigned = (isset($columnDef['unsigned']) && $columnDef['unsigned']) ? ' UNSIGNED' : '';
|
||||||
|
|
||||||
return $unsigned . $default . $notnull . $autoinc;
|
return $unsigned . $autoinc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1104,33 +1090,31 @@ class MySqlPlatform extends AbstractPlatform
|
|||||||
*/
|
*/
|
||||||
public function getDefaultFieldDeclarationSql($field)
|
public function getDefaultFieldDeclarationSql($field)
|
||||||
{
|
{
|
||||||
$default = empty($field['notnull']) && !in_array($field['type'], array('clob', 'blob'))
|
$default = empty($field['notnull']) ? ' DEFAULT NULL' : '';
|
||||||
? ' DEFAULT NULL' : '';
|
|
||||||
|
|
||||||
if (isset($field['default']) && ( ! isset($field['length']) || $field['length'] <= 255)) {
|
if (isset($field['default']) && ( ! isset($field['length']) || $field['length'] <= 255)) {
|
||||||
if ($field['default'] === '') {
|
if ($field['default'] === '') {
|
||||||
$field['default'] = null;
|
$field['default'] = null;
|
||||||
if (! empty($field['notnull']) && array_key_exists($field['type'], $this->valid_default_values)) {
|
/*if ( ! empty($field['notnull']) && array_key_exists($field['type'], $this->valid_default_values)) {
|
||||||
$field['default'] = $this->valid_default_values[$field['type']];
|
$field['default'] = $this->valid_default_values[$field['type']];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($field['default'] === ''
|
if ($field['default'] === ''
|
||||||
&& ($this->_conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_EMPTY_TO_NULL)
|
&& ($this->_conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_EMPTY_TO_NULL)
|
||||||
) {
|
) {
|
||||||
$field['default'] = ' ';
|
$field['default'] = ' ';
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($field['type'] == 'enum' && $this->_conn->getAttribute(Doctrine::ATTR_USE_NATIVE_ENUM)) {
|
/*if ($field['type'] == 'enum' && $this->_conn->getAttribute(Doctrine::ATTR_USE_NATIVE_ENUM)) {
|
||||||
$fieldType = 'varchar';
|
$fieldType = 'varchar';
|
||||||
} else {
|
} else {
|
||||||
if ($field['type'] === 'boolean') {
|
if ($field['type'] === 'boolean') {
|
||||||
$fields['default'] = $this->convertBooleans($field['default']);
|
$fields['default'] = $this->convertBooleans($field['default']);
|
||||||
}
|
}
|
||||||
$fieldType = $field['type'];
|
$fieldType = $field['type'];
|
||||||
}
|
}*/
|
||||||
|
|
||||||
$default = ' DEFAULT ' . $this->quote($field['default'], $fieldType);
|
$default = ' DEFAULT ' . $this->quote($field['default'], $field['type']);
|
||||||
}
|
}
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
@ -450,10 +450,10 @@ class SqlitePlatform extends AbstractPlatform
|
|||||||
/** @override */
|
/** @override */
|
||||||
protected function _getCommonIntegerTypeDeclarationSql(array $columnDef)
|
protected function _getCommonIntegerTypeDeclarationSql(array $columnDef)
|
||||||
{
|
{
|
||||||
$autoinc = ! empty($columnDef['autoincrement']) ? 'AUTOINCREMENT' : '';
|
$autoinc = ! empty($columnDef['autoincrement']) ? ' AUTOINCREMENT' : '';
|
||||||
$pk = ! empty($columnDef['primary']) && ! empty($autoinc) ? 'PRIMARY KEY' : '';
|
$pk = ! empty($columnDef['primary']) && ! empty($autoinc) ? ' PRIMARY KEY' : '';
|
||||||
|
|
||||||
return "INTEGER $pk $autoinc";
|
return "INTEGER" . $pk . $autoinc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -513,13 +513,13 @@ class SqlitePlatform extends AbstractPlatform
|
|||||||
$name = $this->quoteIdentifier($name, true);
|
$name = $this->quoteIdentifier($name, true);
|
||||||
$sql = 'CREATE TABLE ' . $name . ' (' . $queryFields;
|
$sql = 'CREATE TABLE ' . $name . ' (' . $queryFields;
|
||||||
|
|
||||||
if ($check = $this->getCheckDeclarationSql($fields)) {
|
/*if ($check = $this->getCheckDeclarationSql($fields)) {
|
||||||
$sql .= ', ' . $check;
|
$sql .= ', ' . $check;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['checks']) && $check = $this->getCheckDeclarationSql($options['checks'])) {
|
if (isset($options['checks']) && $check = $this->getCheckDeclarationSql($options['checks'])) {
|
||||||
$sql .= ', ' . $check;
|
$sql .= ', ' . $check;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
$sql .= ')';
|
$sql .= ')';
|
||||||
|
|
||||||
@ -527,7 +527,7 @@ class SqlitePlatform extends AbstractPlatform
|
|||||||
|
|
||||||
if (isset($options['indexes']) && ! empty($options['indexes'])) {
|
if (isset($options['indexes']) && ! empty($options['indexes'])) {
|
||||||
foreach ($options['indexes'] as $index => $definition) {
|
foreach ($options['indexes'] as $index => $definition) {
|
||||||
$query[] = $this->createIndexSql($name, $index, $definition);
|
$query[] = $this->getCreateIndexSql($name, $index, $definition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $query;
|
return $query;
|
||||||
|
@ -94,6 +94,7 @@ class ClassExporter
|
|||||||
$column['notnull'] = ! $mapping['nullable'];
|
$column['notnull'] = ! $mapping['nullable'];
|
||||||
if ($class->isIdentifier($fieldName)) {
|
if ($class->isIdentifier($fieldName)) {
|
||||||
$column['primary'] = true;
|
$column['primary'] = true;
|
||||||
|
$options['primary'][] = $mapping['columnName'];
|
||||||
if ($class->isIdGeneratorIdentity()) {
|
if ($class->isIdGeneratorIdentity()) {
|
||||||
$column['autoincrement'] = true;
|
$column['autoincrement'] = true;
|
||||||
}
|
}
|
||||||
@ -124,6 +125,7 @@ class ClassExporter
|
|||||||
} else if ($mapping->isManyToMany() && $mapping->isOwningSide()) {
|
} else if ($mapping->isManyToMany() && $mapping->isOwningSide()) {
|
||||||
//... create join table
|
//... create join table
|
||||||
$joinTableColumns = array();
|
$joinTableColumns = array();
|
||||||
|
$joinTableOptions = array();
|
||||||
$joinTable = $mapping->getJoinTable();
|
$joinTable = $mapping->getJoinTable();
|
||||||
$constraint1 = array();
|
$constraint1 = array();
|
||||||
$constraint1['tableName'] = $joinTable['name'];
|
$constraint1['tableName'] = $joinTable['name'];
|
||||||
@ -133,6 +135,7 @@ class ClassExporter
|
|||||||
foreach ($joinTable['joinColumns'] as $joinColumn) {
|
foreach ($joinTable['joinColumns'] as $joinColumn) {
|
||||||
$column = array();
|
$column = array();
|
||||||
$column['primary'] = true;
|
$column['primary'] = true;
|
||||||
|
$joinTableOptions['primary'][] = $joinColumn['name'];
|
||||||
$column['name'] = $joinColumn['name'];
|
$column['name'] = $joinColumn['name'];
|
||||||
$column['type'] = $class->getTypeOfColumn($joinColumn['referencedColumnName']);
|
$column['type'] = $class->getTypeOfColumn($joinColumn['referencedColumnName']);
|
||||||
$joinTableColumns[$joinColumn['name']] = $column;
|
$joinTableColumns[$joinColumn['name']] = $column;
|
||||||
@ -149,6 +152,7 @@ class ClassExporter
|
|||||||
foreach ($joinTable['inverseJoinColumns'] as $inverseJoinColumn) {
|
foreach ($joinTable['inverseJoinColumns'] as $inverseJoinColumn) {
|
||||||
$column = array();
|
$column = array();
|
||||||
$column['primary'] = true;
|
$column['primary'] = true;
|
||||||
|
$joinTableOptions['primary'][] = $inverseJoinColumn['name'];
|
||||||
$column['name'] = $inverseJoinColumn['name'];
|
$column['name'] = $inverseJoinColumn['name'];
|
||||||
$column['type'] = $this->_em->getClassMetadata($mapping->getTargetEntityName())
|
$column['type'] = $this->_em->getClassMetadata($mapping->getTargetEntityName())
|
||||||
->getTypeOfColumn($inverseJoinColumn['referencedColumnName']);
|
->getTypeOfColumn($inverseJoinColumn['referencedColumnName']);
|
||||||
@ -158,7 +162,8 @@ class ClassExporter
|
|||||||
}
|
}
|
||||||
$foreignKeyConstraints[] = $constraint2;
|
$foreignKeyConstraints[] = $constraint2;
|
||||||
|
|
||||||
$sql = array_merge($sql, $this->_platform->getCreateTableSql($joinTable['name'], $joinTableColumns, array()));
|
$sql = array_merge($sql, $this->_platform->getCreateTableSql(
|
||||||
|
$joinTable['name'], $joinTableColumns, $joinTableOptions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +173,7 @@ class ClassExporter
|
|||||||
// Now create the foreign key constraints
|
// Now create the foreign key constraints
|
||||||
if ($this->_platform->supportsForeignKeyConstraints()) {
|
if ($this->_platform->supportsForeignKeyConstraints()) {
|
||||||
foreach ($foreignKeyConstraints as $fkConstraint) {
|
foreach ($foreignKeyConstraints as $fkConstraint) {
|
||||||
$sql = array_merge($sql, $this->_platform->getCreateForeignKeySql($fkConstraint['tableName'], $fkConstraint));
|
$sql = array_merge($sql, (array)$this->_platform->getCreateForeignKeySql($fkConstraint['tableName'], $fkConstraint));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ class ConnectionMock extends \Doctrine\DBAL\Connection
|
|||||||
private $_lastInsertId = 0;
|
private $_lastInsertId = 0;
|
||||||
private $_inserts = array();
|
private $_inserts = array();
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct(array $params, $driver, $config = null, $eventManager = null) {
|
||||||
|
parent::__construct($params, $driver, $config, $eventManager);
|
||||||
$this->_platformMock = new DatabasePlatformMock();
|
$this->_platformMock = new DatabasePlatformMock();
|
||||||
$this->_platform = $this->_platformMock;
|
$this->_platform = $this->_platformMock;
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,10 @@
|
|||||||
namespace Doctrine\Tests\Mocks;
|
namespace Doctrine\Tests\Mocks;
|
||||||
|
|
||||||
|
|
||||||
// THIS FILE DOES NOT EXIST YET!!!!
|
|
||||||
//require_once 'lib/mocks/Doctrine_SchemaManagerMock.php';
|
|
||||||
|
|
||||||
class DriverMock implements \Doctrine\DBAL\Driver
|
class DriverMock implements \Doctrine\DBAL\Driver
|
||||||
{
|
{
|
||||||
|
private $_platformMock;
|
||||||
|
|
||||||
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
|
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
|
||||||
{
|
{
|
||||||
return new DriverConnectionMock();
|
return new DriverConnectionMock();
|
||||||
@ -24,14 +23,30 @@ class DriverMock implements \Doctrine\DBAL\Driver
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @override
|
||||||
|
*/
|
||||||
public function getDatabasePlatform()
|
public function getDatabasePlatform()
|
||||||
{
|
{
|
||||||
return new DatabasePlatformMock();
|
if ( ! $this->_platformMock) {
|
||||||
|
$this->_platformMock = new DatabasePlatformMock;
|
||||||
|
}
|
||||||
|
return $this->_platformMock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @override
|
||||||
|
*/
|
||||||
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
|
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
|
||||||
{
|
{
|
||||||
return new SchemaManagerMock($conn);
|
return new SchemaManagerMock($conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* MOCK API */
|
||||||
|
|
||||||
|
public function setDatabasePlatform(\Doctrine\DBAL\Platforms\AbstractPlatform $platform)
|
||||||
|
{
|
||||||
|
$this->_platformMock = $platform;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
tests/Doctrine/Tests/Mocks/SchemaManagerMock.php
Normal file
20
tests/Doctrine/Tests/Mocks/SchemaManagerMock.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Doctrine\Tests\Mocks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of SchemaManagerMock
|
||||||
|
*
|
||||||
|
* @author robo
|
||||||
|
*/
|
||||||
|
class SchemaManagerMock extends \Doctrine\DBAL\Schema\AbstractSchemaManager
|
||||||
|
{
|
||||||
|
public function __construct(\Doctrine\DBAL\Connection $conn) {
|
||||||
|
parent::__construct($conn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -24,7 +24,7 @@ class EntityPersisterTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
|
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->_connMock = new ConnectionMock(array());
|
$this->_connMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock());
|
||||||
$this->_emMock = EntityManagerMock::create($this->_connMock);
|
$this->_emMock = EntityManagerMock::create($this->_connMock);
|
||||||
$this->_uowMock = new UnitOfWorkMock($this->_emMock);
|
$this->_uowMock = new UnitOfWorkMock($this->_emMock);
|
||||||
$this->_emMock->setUnitOfWork($this->_uowMock);
|
$this->_emMock->setUnitOfWork($this->_uowMock);
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* This software consists of voluntary contributions made by many individuals
|
* This software consists of voluntary contributions made by many individuals
|
||||||
* and is licensed under the LGPL. For more information, see
|
* and is licensed under the LGPL. For more information, see
|
||||||
* <http://www.phpdoctrine.org>.
|
* <http://www.doctrine-project.org>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Doctrine\Tests\ORM\Export;
|
namespace Doctrine\Tests\ORM\Export;
|
||||||
@ -40,15 +40,22 @@ class ClassExporterTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
{
|
{
|
||||||
public function testTest()
|
public function testTest()
|
||||||
{
|
{
|
||||||
/*
|
// DDL is platform dependant. We can inject the platform to test into the driver mock.
|
||||||
$em = $this->_getTestEntityManager();
|
$driver = new \Doctrine\Tests\Mocks\DriverMock;
|
||||||
|
$conn = new \Doctrine\Tests\Mocks\ConnectionMock(array(), $driver);
|
||||||
|
//$conn->setDatabasePlatform(new \Doctrine\DBAL\Platforms\SqlitePlatform());
|
||||||
|
$conn->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform());
|
||||||
|
|
||||||
$classes = array($em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), $em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'));
|
$em = $this->_getTestEntityManager($conn);
|
||||||
|
|
||||||
|
$classes = array(
|
||||||
|
$em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'),
|
||||||
|
$em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber')
|
||||||
|
);
|
||||||
|
|
||||||
$exporter = new ClassExporter($em);
|
$exporter = new ClassExporter($em);
|
||||||
$sql = $exporter->getExportClassesSql($classes);
|
$sql = $exporter->getExportClassesSql($classes);
|
||||||
print_r($sql);
|
print_r($sql);
|
||||||
exit('test');
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,7 +27,7 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
|
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->_connectionMock = new ConnectionMock(array());
|
$this->_connectionMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock());
|
||||||
$this->_emMock = EntityManagerMock::create($this->_connectionMock);
|
$this->_emMock = EntityManagerMock::create($this->_connectionMock);
|
||||||
// SUT
|
// SUT
|
||||||
$this->_unitOfWork = new UnitOfWorkMock($this->_emMock);
|
$this->_unitOfWork = new UnitOfWorkMock($this->_emMock);
|
||||||
|
@ -15,18 +15,20 @@ class OrmTestCase extends DoctrineTestCase
|
|||||||
*
|
*
|
||||||
* @return Doctrine\ORM\EntityManager
|
* @return Doctrine\ORM\EntityManager
|
||||||
*/
|
*/
|
||||||
protected function _getTestEntityManager($conf = null, $eventManager = null)
|
protected function _getTestEntityManager($conn = null, $conf = null, $eventManager = null)
|
||||||
{
|
{
|
||||||
$config = new \Doctrine\ORM\Configuration();
|
$config = new \Doctrine\ORM\Configuration();
|
||||||
$config->setMetadataCacheImpl(self::getSharedMetadataCacheImpl());
|
$config->setMetadataCacheImpl(self::getSharedMetadataCacheImpl());
|
||||||
$eventManager = new \Doctrine\Common\EventManager();
|
$eventManager = new \Doctrine\Common\EventManager();
|
||||||
$connectionOptions = array(
|
if (is_null($conn)) {
|
||||||
|
$conn = array(
|
||||||
'driverClass' => 'Doctrine\Tests\Mocks\DriverMock',
|
'driverClass' => 'Doctrine\Tests\Mocks\DriverMock',
|
||||||
'wrapperClass' => 'Doctrine\Tests\Mocks\ConnectionMock',
|
'wrapperClass' => 'Doctrine\Tests\Mocks\ConnectionMock',
|
||||||
'user' => 'john',
|
'user' => 'john',
|
||||||
'password' => 'wayne'
|
'password' => 'wayne'
|
||||||
);
|
);
|
||||||
return \Doctrine\ORM\EntityManager::create($connectionOptions, $config, $eventManager);
|
}
|
||||||
|
return \Doctrine\ORM\EntityManager::create($conn, $config, $eventManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getSharedMetadataCacheImpl()
|
private static function getSharedMetadataCacheImpl()
|
||||||
|
Loading…
Reference in New Issue
Block a user