From 97e572e2d886a730f1b5d0dc2ccfd8653ef2eea5 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei <kontakt@beberlei.de> Date: Wed, 15 Sep 2010 21:51:44 +0200 Subject: [PATCH] DDC-806 - Fix xsd schema not allowing entities without id (in inheritance hierachies) --- doctrine-mapping.xsd | 2 +- .../ORM/Mapping/XmlMappingDriverTest.php | 21 +++++++++++++------ .../Tests/ORM/Mapping/xml/CatNoId.dcm.xml | 8 +++++++ 3 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 tests/Doctrine/Tests/ORM/Mapping/xml/CatNoId.dcm.xml diff --git a/doctrine-mapping.xsd b/doctrine-mapping.xsd index 3a09f24b3..badd28f4f 100644 --- a/doctrine-mapping.xsd +++ b/doctrine-mapping.xsd @@ -63,7 +63,7 @@ <xs:element name="discriminator-column" type="orm:discriminator-column" minOccurs="0"/> <xs:element name="discriminator-map" type="orm:discriminator-map" minOccurs="0"/> <xs:element name="lifecycle-callbacks" type="orm:lifecycle-callbacks" minOccurs="0" maxOccurs="1" /> - <xs:element name="id" type="orm:id" /> + <xs:element name="id" type="orm:id" minOccurs="0" maxOccurs="1" /> <xs:element name="field" type="orm:field" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="one-to-one" type="orm:one-to-one" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="one-to-many" type="orm:one-to-many" minOccurs="0" maxOccurs="unbounded" /> diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index 5c2edff5b..8308ea260 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -33,18 +33,27 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest $this->assertEquals($expectedMap, $class->discriminatorMap); } - public function testValidateXmlSchema() + /** + * @param string $xmlMappingFile + * @dataProvider dataValidSchema + */ + public function testValidateXmlSchema($xmlMappingFile) { $xsdSchemaFile = __DIR__ . "/../../../../../doctrine-mapping.xsd"; $dom = new \DOMDocument('UTF-8'); - $dom->load(__DIR__ . "/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml"); - $this->assertTrue($dom->schemaValidate($xsdSchemaFile)); - - $dom = new \DOMDocument('UTF-8'); - $dom->load(__DIR__ . "/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml"); + $dom->load($xmlMappingFile); $this->assertTrue($dom->schemaValidate($xsdSchemaFile)); } + + static public function dataValidSchema() + { + return array( + array(__DIR__ . "/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml"), + array(__DIR__ . "/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml"), + array(__DIR__ . "/xml/CatNoId.dcm.xml"), + ); + } } class CTI diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/CatNoId.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/CatNoId.dcm.xml new file mode 100644 index 000000000..6025d350f --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/CatNoId.dcm.xml @@ -0,0 +1,8 @@ +<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping + http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> + <entity name="CatNoId"> + <field name="can_has_cheezburgers" type="boolean" /> + </entity> +</doctrine-mapping>