1
0
mirror of synced 2025-01-19 15:01:40 +03:00

#881 DDC-2825 - refactoring test logic, removing dead private method

This commit is contained in:
Marco Pivetta 2015-01-14 19:04:58 +01:00
parent 80ce601eae
commit 962f479318

View File

@ -30,12 +30,32 @@ class DDC2825Test extends \Doctrine\Tests\OrmFunctionalTestCase
* @dataProvider getTestedClasses * @dataProvider getTestedClasses
* *
* @param string $className * @param string $className
* @param string $schema * @param string $expectedSchemaName
* @param string $table * @param string $expectedTableName
*/ */
public function testClassSchemaMappingsValidity($className, $schema, $table) public function testClassSchemaMappingsValidity($className, $expectedSchemaName, $expectedTableName)
{ {
$this->checkClassMetadata($className, $schema, $table); $classMetadata = $this->_em->getClassMetadata($className);
$platform = $this->_em->getConnection()->getDatabasePlatform();
$quotedTableName = $this->_em->getConfiguration()->getQuoteStrategy()->getTableName($classMetadata, $platform);
// Check if table name and schema properties are defined in the class metadata
$this->assertEquals($expectedTableName, $classMetadata->table['name']);
$this->assertEquals($expectedSchemaName, $classMetadata->table['schema']);
if ($this->_em->getConnection()->getDatabasePlatform()->supportsSchemas()) {
$fullTableName = sprintf('%s.%s', $expectedSchemaName, $expectedTableName);
} else {
$fullTableName = sprintf('%s__%s', $expectedSchemaName, $expectedTableName);
}
$this->assertEquals($fullTableName, $quotedTableName);
// Checks sequence name validity
$this->assertEquals(
$fullTableName . '_' . $classMetadata->getSingleIdentifierColumnName() . '_seq',
$classMetadata->getSequenceName($platform)
);
} }
/** /**
@ -71,40 +91,6 @@ class DDC2825Test extends \Doctrine\Tests\OrmFunctionalTestCase
array(DDC2825ClassWithImplicitlyDefinedSchemaAndQuotedTableName::CLASSNAME, 'myschema', 'order'), array(DDC2825ClassWithImplicitlyDefinedSchemaAndQuotedTableName::CLASSNAME, 'myschema', 'order'),
); );
} }
/**
* Checks that class metadata is correctly stored when a database schema is used and
* checks that the table name is correctly converted whether the platform supports database
* schemas or not
*
* @param string $className Class metadata
* @param string $expectedSchemaName Expected schema name
* @param string $expectedTableName Expected table name
*/
private function checkClassMetadata($className, $expectedSchemaName, $expectedTableName)
{
$classMetadata = $this->_em->getClassMetadata($className);
$platform = $this->_em->getConnection()->getDatabasePlatform();
$quotedTableName = $this->_em->getConfiguration()->getQuoteStrategy()->getTableName($classMetadata, $platform);
// Check if table name and schema properties are defined in the class metadata
$this->assertEquals($expectedTableName, $classMetadata->table['name']);
$this->assertEquals($expectedSchemaName, $classMetadata->table['schema']);
if ($this->_em->getConnection()->getDatabasePlatform()->supportsSchemas()) {
$fullTableName = sprintf('%s.%s', $expectedSchemaName, $expectedTableName);
} else {
$fullTableName = sprintf('%s__%s', $expectedSchemaName, $expectedTableName);
}
$this->assertEquals($fullTableName, $quotedTableName);
// Checks sequence name validity
$this->assertEquals(
$fullTableName . '_' . $classMetadata->getSingleIdentifierColumnName() . '_seq',
$classMetadata->getSequenceName($platform)
);
}
} }
/** /**