From 962f4793185974800c0d0f4fb104a338f68a4e8b Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Wed, 14 Jan 2015 19:04:58 +0100 Subject: [PATCH] #881 DDC-2825 - refactoring test logic, removing dead private method --- .../ORM/Functional/Ticket/DDC2825Test.php | 62 +++++++------------ 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php index b33d2fa30..c5de5ccf6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2825Test.php @@ -30,12 +30,32 @@ class DDC2825Test extends \Doctrine\Tests\OrmFunctionalTestCase * @dataProvider getTestedClasses * * @param string $className - * @param string $schema - * @param string $table + * @param string $expectedSchemaName + * @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'), ); } - - /** - * 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) - ); - } } /**