[2.0] DDC-169 - Stripped case handling since its just a load of complex crap and doesn't solve any problem! Idea: just implement case-insensitivity in the comparator.
This commit is contained in:
parent
70075d8f80
commit
0788cdf15e
@ -44,11 +44,6 @@ abstract class AbstractAsset
|
|||||||
*/
|
*/
|
||||||
protected $_name;
|
protected $_name;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $_caseMode = self::CASE_KEEP;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set name of this asset
|
* Set name of this asset
|
||||||
*
|
*
|
||||||
@ -66,7 +61,7 @@ abstract class AbstractAsset
|
|||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return $this->_foldIdentifier($this->_name);
|
return $this->_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,47 +86,4 @@ abstract class AbstractAsset
|
|||||||
$parts[] = $postfix;
|
$parts[] = $postfix;
|
||||||
return trim(implode("_", $parts), '_');
|
return trim(implode("_", $parts), '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the case mode of this asset.
|
|
||||||
*
|
|
||||||
* @param string $caseMode
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setCaseMode($caseMode)
|
|
||||||
{
|
|
||||||
if (!in_array($caseMode, array(self::CASE_KEEP, self::CASE_LOWER, self::CASE_UPPER))) {
|
|
||||||
throw SchemaException::invalidCaseModeGiven($caseMode);
|
|
||||||
}
|
|
||||||
$this->_caseMode = $caseMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fold the case of the identifier based on the CASE_* constants.
|
|
||||||
*
|
|
||||||
* This has never to be applied on write operation, only on read! This ensures that you can change
|
|
||||||
* the case at any point. For the keys of arrays however we always store them in lower-case which
|
|
||||||
* makes it easy to access them. This affects the maps in Schema and Table instances.
|
|
||||||
*
|
|
||||||
* @param string $identifier
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function _foldIdentifier($identifier)
|
|
||||||
{
|
|
||||||
if ($this->_caseMode == self::CASE_UPPER) {
|
|
||||||
return strtoupper($identifier);
|
|
||||||
} else if ($this->_caseMode == self::CASE_LOWER) {
|
|
||||||
return strtolower($identifier);
|
|
||||||
}
|
|
||||||
return $identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $identifiers
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function _foldIdentifiers($identifiers)
|
|
||||||
{
|
|
||||||
return array_map(array($this, '_foldIdentifier'), $identifiers);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -55,11 +55,6 @@ abstract class AbstractSchemaManager
|
|||||||
*/
|
*/
|
||||||
protected $_platform;
|
protected $_platform;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $_caseMode = AbstractAsset::CASE_KEEP;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Accepts the Connection instance to manage the schema for
|
* Constructor. Accepts the Connection instance to manage the schema for
|
||||||
*
|
*
|
||||||
@ -71,22 +66,6 @@ abstract class AbstractSchemaManager
|
|||||||
$this->_platform = $this->_conn->getDatabasePlatform();
|
$this->_platform = $this->_conn->getDatabasePlatform();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $caseMode
|
|
||||||
*/
|
|
||||||
public function setCaseMode($caseMode)
|
|
||||||
{
|
|
||||||
$this->_caseMode = $caseMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCaseMode()
|
|
||||||
{
|
|
||||||
return $this->_caseMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return associated platform.
|
* Return associated platform.
|
||||||
*
|
*
|
||||||
@ -288,9 +267,7 @@ abstract class AbstractSchemaManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$table = new Table($tableName, $columns, $indexes, $foreignKeys, $idGeneratorType, array());
|
$tables[] = new Table($tableName, $columns, $indexes, $foreignKeys, $idGeneratorType, array());
|
||||||
$table->setCaseMode($this->_caseMode);
|
|
||||||
$tables[] = $table;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tables;
|
return $tables;
|
||||||
@ -928,7 +905,6 @@ abstract class AbstractSchemaManager
|
|||||||
$indexes = array();
|
$indexes = array();
|
||||||
foreach($result AS $indexKey => $data) {
|
foreach($result AS $indexKey => $data) {
|
||||||
$indexes[$indexKey] = new Index($data['name'], $data['columns'], $data['unique'], $data['primary']);
|
$indexes[$indexKey] = new Index($data['name'], $data['columns'], $data['unique'], $data['primary']);
|
||||||
$indexes[$indexKey]->setCaseMode($this->_caseMode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $indexes;
|
return $indexes;
|
||||||
@ -1018,9 +994,6 @@ abstract class AbstractSchemaManager
|
|||||||
}
|
}
|
||||||
$tables = $this->listTables();
|
$tables = $this->listTables();
|
||||||
|
|
||||||
$schema = new Schema($tables, $sequences);
|
return new Schema($tables, $sequences);
|
||||||
$schema->setCaseMode($this->_caseMode);
|
|
||||||
|
|
||||||
return $schema;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -72,12 +72,12 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
|
|||||||
*/
|
*/
|
||||||
public function getLocalColumns()
|
public function getLocalColumns()
|
||||||
{
|
{
|
||||||
return $this->_foldIdentifiers($this->_localColumnNames);
|
return $this->_localColumnNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getColumns()
|
public function getColumns()
|
||||||
{
|
{
|
||||||
return $this->_foldIdentifiers($this->_localColumnNames);
|
return $this->_localColumnNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,7 +85,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
|
|||||||
*/
|
*/
|
||||||
public function getForeignTableName()
|
public function getForeignTableName()
|
||||||
{
|
{
|
||||||
return $this->_foldIdentifier($this->_foreignTableName);
|
return $this->_foreignTableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,7 +93,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
|
|||||||
*/
|
*/
|
||||||
public function getForeignColumns()
|
public function getForeignColumns()
|
||||||
{
|
{
|
||||||
return $this->_foldIdentifiers($this->_foreignColumnNames);
|
return $this->_foreignColumnNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasOption($name)
|
public function hasOption($name)
|
||||||
|
@ -76,7 +76,7 @@ class Index extends AbstractAsset implements Constraint
|
|||||||
*/
|
*/
|
||||||
public function getColumns()
|
public function getColumns()
|
||||||
{
|
{
|
||||||
return $this->_foldIdentifiers($this->_columns);
|
return $this->_columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,7 +102,6 @@ class Index extends AbstractAsset implements Constraint
|
|||||||
*/
|
*/
|
||||||
public function hasColumnAtPosition($columnName, $pos=0)
|
public function hasColumnAtPosition($columnName, $pos=0)
|
||||||
{
|
{
|
||||||
$columnName = $this->_foldIdentifier($columnName);
|
|
||||||
return \array_search($columnName, $this->getColumns()) === $pos;
|
return \array_search($columnName, $this->getColumns()) === $pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -259,23 +259,19 @@ class MySqlSchemaManager extends AbstractSchemaManager
|
|||||||
$options['precision'] = $precision;
|
$options['precision'] = $precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
$column = new Column($tableColumn['Field'], \Doctrine\DBAL\Types\Type::getType($type), $options);
|
return new Column($tableColumn['Field'], \Doctrine\DBAL\Types\Type::getType($type), $options);
|
||||||
$column->setCaseMode($this->getCaseMode());
|
|
||||||
return $column;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _getPortableTableForeignKeyDefinition($tableForeignKey)
|
public function _getPortableTableForeignKeyDefinition($tableForeignKey)
|
||||||
{
|
{
|
||||||
$tableForeignKey = array_change_key_case($tableForeignKey, CASE_LOWER);
|
$tableForeignKey = array_change_key_case($tableForeignKey, CASE_LOWER);
|
||||||
|
|
||||||
$fk = new ForeignKeyConstraint(
|
return new ForeignKeyConstraint(
|
||||||
(array)$tableForeignKey['column_name'],
|
(array)$tableForeignKey['column_name'],
|
||||||
$tableForeignKey['referenced_table_name'],
|
$tableForeignKey['referenced_table_name'],
|
||||||
(array)$tableForeignKey['referenced_column_name'],
|
(array)$tableForeignKey['referenced_column_name'],
|
||||||
$tableForeignKey['constraint_name'],
|
$tableForeignKey['constraint_name'],
|
||||||
array()
|
array()
|
||||||
);
|
);
|
||||||
$fk->setCaseMode($this->getCaseMode());
|
|
||||||
return $fk;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -189,9 +189,7 @@ class OracleSchemaManager extends AbstractSchemaManager
|
|||||||
'platformDetails' => array(),
|
'platformDetails' => array(),
|
||||||
);
|
);
|
||||||
|
|
||||||
$column = new Column($tableColumn['column_name'], \Doctrine\DBAL\Types\Type::getType($type), $options);
|
return new Column($tableColumn['column_name'], \Doctrine\DBAL\Types\Type::getType($type), $options);
|
||||||
$column->setCaseMode($this->getCaseMode());
|
|
||||||
return $column;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _getPortableTableForeignKeysList($tableForeignKeys)
|
protected function _getPortableTableForeignKeysList($tableForeignKeys)
|
||||||
@ -214,13 +212,11 @@ class OracleSchemaManager extends AbstractSchemaManager
|
|||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach($list AS $constraint) {
|
foreach($list AS $constraint) {
|
||||||
$fk = new ForeignKeyConstraint(
|
$result[] = new ForeignKeyConstraint(
|
||||||
array_values($constraint['local']), $constraint['foreignTable'],
|
array_values($constraint['local']), $constraint['foreignTable'],
|
||||||
array_values($constraint['foreign']), $constraint['name'],
|
array_values($constraint['foreign']), $constraint['name'],
|
||||||
array('onDelete' => $constraint['onDelete'])
|
array('onDelete' => $constraint['onDelete'])
|
||||||
);
|
);
|
||||||
$fk->setCaseMode($this->getCaseMode());
|
|
||||||
$result[] = $fk;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@ -229,9 +225,7 @@ class OracleSchemaManager extends AbstractSchemaManager
|
|||||||
protected function _getPortableSequenceDefinition($sequence)
|
protected function _getPortableSequenceDefinition($sequence)
|
||||||
{
|
{
|
||||||
$sequence = \array_change_key_case($sequence, CASE_LOWER);
|
$sequence = \array_change_key_case($sequence, CASE_LOWER);
|
||||||
$sequence = new Sequence($sequence['sequence_name'], $sequence['increment_by'], $sequence['min_value']);
|
return new Sequence($sequence['sequence_name'], $sequence['increment_by'], $sequence['min_value']);
|
||||||
$sequence->setCaseMode($this->getCaseMode());
|
|
||||||
return $sequence;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _getPortableTableConstraintDefinition($tableConstraint)
|
protected function _getPortableTableConstraintDefinition($tableConstraint)
|
||||||
|
@ -51,12 +51,10 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
|
|||||||
$foreignTable = $values[2];
|
$foreignTable = $values[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
$fk = new ForeignKeyConstraint(
|
return new ForeignKeyConstraint(
|
||||||
$localColumns, $foreignTable, $foreignColumns, $tableForeignKey['conname'],
|
$localColumns, $foreignTable, $foreignColumns, $tableForeignKey['conname'],
|
||||||
array('onUpdate' => $onUpdate, 'onDelete' => $onDelete)
|
array('onUpdate' => $onUpdate, 'onDelete' => $onDelete)
|
||||||
);
|
);
|
||||||
$fk->setCaseMode($this->getCaseMode());
|
|
||||||
return $fk;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dropDatabase($database)
|
public function dropDatabase($database)
|
||||||
@ -156,9 +154,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
|
|||||||
protected function _getPortableSequenceDefinition($sequence)
|
protected function _getPortableSequenceDefinition($sequence)
|
||||||
{
|
{
|
||||||
$data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM '.$sequence['relname']);
|
$data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM '.$sequence['relname']);
|
||||||
$sequence = new Sequence($sequence['relname'], $data[0]['increment_by'], $data[0]['min_value']);
|
return new Sequence($sequence['relname'], $data[0]['increment_by'], $data[0]['min_value']);
|
||||||
$sequence->setCaseMode($this->getCaseMode());
|
|
||||||
return $sequence;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _getPortableTableConstraintDefinition($tableConstraint)
|
protected function _getPortableTableConstraintDefinition($tableConstraint)
|
||||||
@ -334,8 +330,6 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$column = new Column($tableColumn['field'], \Doctrine\DBAL\Types\Type::getType($type), $options);
|
return new Column($tableColumn['field'], \Doctrine\DBAL\Types\Type::getType($type), $options);
|
||||||
$column->setCaseMode($this->getCaseMode());
|
|
||||||
return $column;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -65,8 +65,6 @@ class Schema extends AbstractAsset
|
|||||||
*/
|
*/
|
||||||
protected function _addTable(Table $table)
|
protected function _addTable(Table $table)
|
||||||
{
|
{
|
||||||
$table->setCaseMode($this->_caseMode);
|
|
||||||
|
|
||||||
$tableName = strtolower($table->getName());
|
$tableName = strtolower($table->getName());
|
||||||
if(isset($this->_tables[$tableName])) {
|
if(isset($this->_tables[$tableName])) {
|
||||||
throw SchemaException::tableAlreadyExists($tableName);
|
throw SchemaException::tableAlreadyExists($tableName);
|
||||||
@ -80,8 +78,6 @@ class Schema extends AbstractAsset
|
|||||||
*/
|
*/
|
||||||
protected function _addSequence(Sequence $sequence)
|
protected function _addSequence(Sequence $sequence)
|
||||||
{
|
{
|
||||||
$sequence->setCaseMode($this->_caseMode);
|
|
||||||
|
|
||||||
$seqName = strtolower($sequence->getName());
|
$seqName = strtolower($sequence->getName());
|
||||||
if (isset($this->_sequences[$seqName])) {
|
if (isset($this->_sequences[$seqName])) {
|
||||||
throw SchemaException::sequenceAlreadyExists($seqName);
|
throw SchemaException::sequenceAlreadyExists($seqName);
|
||||||
|
@ -255,8 +255,6 @@ class SqliteSchemaManager extends AbstractSchemaManager
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$column = new Column($tableColumn['name'], \Doctrine\DBAL\Types\Type::getType($type), $options);
|
return new Column($tableColumn['name'], \Doctrine\DBAL\Types\Type::getType($type), $options);
|
||||||
$column->setCaseMode($this->getCaseMode());
|
|
||||||
return $column;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -337,8 +337,6 @@ class Table extends AbstractAsset
|
|||||||
*/
|
*/
|
||||||
protected function _addColumn(Column $column)
|
protected function _addColumn(Column $column)
|
||||||
{
|
{
|
||||||
$column->setCaseMode($this->_caseMode);
|
|
||||||
|
|
||||||
$columnName = $column->getName();
|
$columnName = $column->getName();
|
||||||
$columnName = strtolower($columnName);
|
$columnName = strtolower($columnName);
|
||||||
|
|
||||||
@ -357,8 +355,6 @@ class Table extends AbstractAsset
|
|||||||
*/
|
*/
|
||||||
protected function _addIndex(Index $index)
|
protected function _addIndex(Index $index)
|
||||||
{
|
{
|
||||||
$index->setCaseMode($this->_caseMode);
|
|
||||||
|
|
||||||
$indexName = $index->getName();
|
$indexName = $index->getName();
|
||||||
$indexName = strtolower($indexName);
|
$indexName = strtolower($indexName);
|
||||||
|
|
||||||
@ -379,8 +375,6 @@ class Table extends AbstractAsset
|
|||||||
*/
|
*/
|
||||||
protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint)
|
protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint)
|
||||||
{
|
{
|
||||||
$constraint->setCaseMode($this->_caseMode);
|
|
||||||
|
|
||||||
if(strlen($constraint->getName())) {
|
if(strlen($constraint->getName())) {
|
||||||
$name = $constraint->getName();
|
$name = $constraint->getName();
|
||||||
} else {
|
} else {
|
||||||
|
@ -95,12 +95,8 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
|
|||||||
|
|
||||||
$columns = $this->_sm->listTableColumns('list_table_columns');
|
$columns = $this->_sm->listTableColumns('list_table_columns');
|
||||||
|
|
||||||
foreach ($columns AS $column) {
|
|
||||||
$column->setCaseMode("lower");
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertArrayHasKey('id', $columns);
|
$this->assertArrayHasKey('id', $columns);
|
||||||
$this->assertEquals('id', $columns['id']->getname());
|
$this->assertEquals('id', strtolower($columns['id']->getname()));
|
||||||
$this->assertType('Doctrine\DBAL\Types\IntegerType', $columns['id']->gettype());
|
$this->assertType('Doctrine\DBAL\Types\IntegerType', $columns['id']->gettype());
|
||||||
$this->assertEquals(false, $columns['id']->getunsigned());
|
$this->assertEquals(false, $columns['id']->getunsigned());
|
||||||
$this->assertEquals(true, $columns['id']->getnotnull());
|
$this->assertEquals(true, $columns['id']->getnotnull());
|
||||||
@ -108,7 +104,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
|
|||||||
$this->assertType('array', $columns['id']->getPlatformOptions());
|
$this->assertType('array', $columns['id']->getPlatformOptions());
|
||||||
|
|
||||||
$this->assertArrayHasKey('test', $columns);
|
$this->assertArrayHasKey('test', $columns);
|
||||||
$this->assertEquals('test', $columns['test']->getname());
|
$this->assertEquals('test', strtolower($columns['test']->getname()));
|
||||||
$this->assertType('Doctrine\DBAL\Types\StringType', $columns['test']->gettype());
|
$this->assertType('Doctrine\DBAL\Types\StringType', $columns['test']->gettype());
|
||||||
$this->assertEquals(255, $columns['test']->getlength());
|
$this->assertEquals(255, $columns['test']->getlength());
|
||||||
$this->assertEquals(false, $columns['test']->getfixed());
|
$this->assertEquals(false, $columns['test']->getfixed());
|
||||||
@ -116,7 +112,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
|
|||||||
$this->assertEquals(null, $columns['test']->getdefault());
|
$this->assertEquals(null, $columns['test']->getdefault());
|
||||||
$this->assertType('array', $columns['test']->getPlatformOptions());
|
$this->assertType('array', $columns['test']->getPlatformOptions());
|
||||||
|
|
||||||
$this->assertEquals('foo', ($columns['foo']->getname()));
|
$this->assertEquals('foo', strtolower($columns['foo']->getname()));
|
||||||
$this->assertType('Doctrine\DBAL\Types\TextType', $columns['foo']->gettype());
|
$this->assertType('Doctrine\DBAL\Types\TextType', $columns['foo']->gettype());
|
||||||
$this->assertEquals(null, $columns['foo']->getlength());
|
$this->assertEquals(null, $columns['foo']->getlength());
|
||||||
$this->assertEquals(false, $columns['foo']->getunsigned());
|
$this->assertEquals(false, $columns['foo']->getunsigned());
|
||||||
@ -125,7 +121,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
|
|||||||
$this->assertEquals(null, $columns['foo']->getdefault());
|
$this->assertEquals(null, $columns['foo']->getdefault());
|
||||||
$this->assertType('array', $columns['foo']->getPlatformOptions());
|
$this->assertType('array', $columns['foo']->getPlatformOptions());
|
||||||
|
|
||||||
$this->assertEquals('bar', ($columns['bar']->getname()));
|
$this->assertEquals('bar', strtolower($columns['bar']->getname()));
|
||||||
$this->assertType('Doctrine\DBAL\Types\DecimalType', $columns['bar']->gettype());
|
$this->assertType('Doctrine\DBAL\Types\DecimalType', $columns['bar']->gettype());
|
||||||
$this->assertEquals(null, $columns['bar']->getlength());
|
$this->assertEquals(null, $columns['bar']->getlength());
|
||||||
$this->assertEquals(10, $columns['bar']->getprecision());
|
$this->assertEquals(10, $columns['bar']->getprecision());
|
||||||
@ -136,19 +132,19 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
|
|||||||
$this->assertEquals(null, $columns['bar']->getdefault());
|
$this->assertEquals(null, $columns['bar']->getdefault());
|
||||||
$this->assertType('array', $columns['bar']->getPlatformOptions());
|
$this->assertType('array', $columns['bar']->getPlatformOptions());
|
||||||
|
|
||||||
$this->assertEquals('baz1', ($columns['baz1']->getname()));
|
$this->assertEquals('baz1', strtolower($columns['baz1']->getname()));
|
||||||
$this->assertType('Doctrine\DBAL\Types\DateTimeType', $columns['baz1']->gettype());
|
$this->assertType('Doctrine\DBAL\Types\DateTimeType', $columns['baz1']->gettype());
|
||||||
$this->assertEquals(true, $columns['baz1']->getnotnull());
|
$this->assertEquals(true, $columns['baz1']->getnotnull());
|
||||||
$this->assertEquals(null, $columns['baz1']->getdefault());
|
$this->assertEquals(null, $columns['baz1']->getdefault());
|
||||||
$this->assertType('array', $columns['baz1']->getPlatformOptions());
|
$this->assertType('array', $columns['baz1']->getPlatformOptions());
|
||||||
|
|
||||||
$this->assertEquals('baz2', ($columns['baz2']->getname()));
|
$this->assertEquals('baz2', strtolower($columns['baz2']->getname()));
|
||||||
$this->assertContains($columns['baz2']->gettype()->getName(), array('Time', 'Date', 'DateTime'));
|
$this->assertContains($columns['baz2']->gettype()->getName(), array('Time', 'Date', 'DateTime'));
|
||||||
$this->assertEquals(true, $columns['baz2']->getnotnull());
|
$this->assertEquals(true, $columns['baz2']->getnotnull());
|
||||||
$this->assertEquals(null, $columns['baz2']->getdefault());
|
$this->assertEquals(null, $columns['baz2']->getdefault());
|
||||||
$this->assertType('array', $columns['baz2']->getPlatformOptions());
|
$this->assertType('array', $columns['baz2']->getPlatformOptions());
|
||||||
|
|
||||||
$this->assertEquals('baz3', ($columns['baz3']->getname()));
|
$this->assertEquals('baz3', strtolower($columns['baz3']->getname()));
|
||||||
$this->assertContains($columns['baz2']->gettype()->getName(), array('Time', 'Date', 'DateTime'));
|
$this->assertContains($columns['baz2']->gettype()->getName(), array('Time', 'Date', 'DateTime'));
|
||||||
$this->assertEquals(true, $columns['baz3']->getnotnull());
|
$this->assertEquals(true, $columns['baz3']->getnotnull());
|
||||||
$this->assertEquals(null, $columns['baz3']->getdefault());
|
$this->assertEquals(null, $columns['baz3']->getdefault());
|
||||||
@ -192,7 +188,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
|
|||||||
$tableIndexes = $this->_sm->listTableIndexes('test_create_index');
|
$tableIndexes = $this->_sm->listTableIndexes('test_create_index');
|
||||||
$this->assertType('array', $tableIndexes);
|
$this->assertType('array', $tableIndexes);
|
||||||
|
|
||||||
$this->assertEquals('test', $tableIndexes['test']->getName());
|
$this->assertEquals('test', strtolower($tableIndexes['test']->getName()));
|
||||||
$this->assertEquals(array('test'), array_map('strtolower', $tableIndexes['test']->getColumns()));
|
$this->assertEquals(array('test'), array_map('strtolower', $tableIndexes['test']->getColumns()));
|
||||||
$this->assertTrue($tableIndexes['test']->isUnique());
|
$this->assertTrue($tableIndexes['test']->isUnique());
|
||||||
$this->assertFalse($tableIndexes['test']->isPrimary());
|
$this->assertFalse($tableIndexes['test']->isPrimary());
|
||||||
@ -217,10 +213,10 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
|
|||||||
$this->assertEquals(1, count($fkConstraints));
|
$this->assertEquals(1, count($fkConstraints));
|
||||||
|
|
||||||
$fkConstraint = current($fkConstraints);
|
$fkConstraint = current($fkConstraints);
|
||||||
$fkConstraint->setCaseMode("lower");
|
$this->assertType('\Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkConstraint);
|
||||||
$this->assertEquals('test_foreign', $fkConstraint->getForeignTableName());
|
$this->assertEquals('test_foreign', strtolower($fkConstraint->getForeignTableName()));
|
||||||
$this->assertEquals(array('foreign_key_test'), $fkConstraint->getColumns());
|
$this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkConstraint->getColumns()));
|
||||||
$this->assertEquals(array('id'), $fkConstraint->getForeignColumns());
|
$this->assertEquals(array('id'), array_map('strtolower', $fkConstraint->getForeignColumns()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testListForeignKeys()
|
public function testListForeignKeys()
|
||||||
@ -240,15 +236,11 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
|
|||||||
|
|
||||||
$fkeys = $this->_sm->listTableForeignKeys('test_create_fk1');
|
$fkeys = $this->_sm->listTableForeignKeys('test_create_fk1');
|
||||||
|
|
||||||
foreach ($fkeys AS $fkey) {
|
|
||||||
$fkey->setCaseMode("lower");
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals(1, count($fkeys));
|
$this->assertEquals(1, count($fkeys));
|
||||||
$this->assertType('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]);
|
$this->assertType('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]);
|
||||||
$this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkeys[0]->getLocalColumns()));
|
$this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkeys[0]->getLocalColumns()));
|
||||||
$this->assertEquals(array('id'), array_map('strtolower', $fkeys[0]->getForeignColumns()));
|
$this->assertEquals(array('id'), array_map('strtolower', $fkeys[0]->getForeignColumns()));
|
||||||
$this->assertEquals('test_create_fk2', ($fkeys[0]->getForeignTableName()));
|
$this->assertEquals('test_create_fk2', strtolower($fkeys[0]->getForeignTableName()));
|
||||||
|
|
||||||
if($fkeys[0]->hasOption('onUpdate')) {
|
if($fkeys[0]->hasOption('onUpdate')) {
|
||||||
$this->assertEquals('CASCADE', $fkeys[0]->getOption('onUpdate'));
|
$this->assertEquals('CASCADE', $fkeys[0]->getOption('onUpdate'));
|
||||||
|
@ -18,7 +18,6 @@ class DatabaseDriverTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->_sm = $this->_em->getConnection()->getSchemaManager();
|
$this->_sm = $this->_em->getConnection()->getSchemaManager();
|
||||||
$this->_sm->setCaseMode("lower");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateSimpleYamlFromDatabase()
|
public function testCreateSimpleYamlFromDatabase()
|
||||||
|
Loading…
Reference in New Issue
Block a user