From c35f1310bc9a64973f64e7eaedccab888357028b Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 4 Dec 2014 13:29:09 +0100 Subject: [PATCH] #1204 - using specific XML assertions to build a less-fragile test (asserting on the entire string may cause failures if the XML structure changes) --- .../Export/XmlClassMetadataExporterTest.php | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php index a5e44dccb..0fe58b4ec 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/XmlClassMetadataExporterTest.php @@ -20,6 +20,9 @@ */ namespace Doctrine\Tests\ORM\Tools\Export; +use Doctrine\ORM\Mapping\ClassMetadataInfo; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Tools\Export\Driver\XmlExporter; /** * Test case for XmlClassMetadataExporterTest @@ -38,10 +41,13 @@ class XmlClassMetadataExporterTest extends AbstractClassMetadataExporterTest return 'xml'; } - + /** + * @group DDC-3428 + */ public function testSequenceGenerator() { - $exporter = new \Doctrine\ORM\Tools\Export\Driver\XmlExporter(); - $metadata = new \Doctrine\ORM\Mapping\ClassMetadata('entityTest'); + $exporter = new XmlExporter(); + $metadata = new ClassMetadata('entityTest'); + $metadata->mapField(array( "fieldName" => 'id', "type" => 'integer', @@ -49,24 +55,29 @@ class XmlClassMetadataExporterTest extends AbstractClassMetadataExporterTest "id" => true, )); - $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); + $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE); $metadata->setSequenceGeneratorDefinition(array( 'sequenceName' => 'seq_entity_test_id', 'allocationSize' => 5, 'initialValue' => 1 )); + $expectedFileContent = <<<'XML' + + + + + + + + + +XML; - $fileContent = ''."\n". -''."\n". -' '."\n". -' '."\n". -' '."\n". -' '."\n". -' '."\n". -' '."\n". -''."\n"; - $exportClassMetadata = $exporter->exportClassMetadata($metadata); - $this->assertEquals($fileContent, $exportClassMetadata); + $this->assertXmlStringEqualsXmlString($expectedFileContent, $exporter->exportClassMetadata($metadata)); } }