From a8b11a14d1033deaef2358222467d821a89a37a5 Mon Sep 17 00:00:00 2001 From: MatteoFeltrin Date: Mon, 13 May 2024 10:48:39 +0200 Subject: [PATCH] allow classname in 'value' attribute of xml discriminator-mapping field --- doctrine-mapping.xsd | 2 +- tests/Tests/Models/Customer/CustomerType.php | 10 ++++++++++ tests/Tests/Models/Customer/ExternalCustomer.php | 13 +++++++++++++ tests/Tests/Models/Customer/InternalCustomer.php | 13 +++++++++++++ tests/Tests/ORM/Mapping/XmlMappingDriverTest.php | 15 +++++++++++++++ ...ine.Tests.Models.Customer.CustomerType.dcm.xml | 14 ++++++++++++++ 6 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 tests/Tests/Models/Customer/CustomerType.php create mode 100644 tests/Tests/Models/Customer/ExternalCustomer.php create mode 100644 tests/Tests/Models/Customer/InternalCustomer.php create mode 100644 tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Customer.CustomerType.dcm.xml diff --git a/doctrine-mapping.xsd b/doctrine-mapping.xsd index 58175a2e8dd..6131026f5f6 100644 --- a/doctrine-mapping.xsd +++ b/doctrine-mapping.xsd @@ -321,7 +321,7 @@ - + diff --git a/tests/Tests/Models/Customer/CustomerType.php b/tests/Tests/Models/Customer/CustomerType.php new file mode 100644 index 00000000000..e66f90ccd06 --- /dev/null +++ b/tests/Tests/Models/Customer/CustomerType.php @@ -0,0 +1,10 @@ +type); } + public function testClassNameMappingDiscriminatorValue(): void + { + $driver = new XmlDriver( + __DIR__ . '/xml', + XmlDriver::DEFAULT_FILE_EXTENSION, + true, + ); + $xmlElement = $driver->getElement(CustomerType::class); + self::assertEquals( + 'Doctrine\Tests\Models\Customer\InternalCustomer', + $xmlElement->children()->{'discriminator-map'}->{'discriminator-mapping'}[0]->attributes()['value'] + ); + } + public function testDisablingXmlValidationIsPossible(): void { $this->expectNotToPerformAssertions(); diff --git a/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Customer.CustomerType.dcm.xml b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Customer.CustomerType.dcm.xml new file mode 100644 index 00000000000..8cb22900428 --- /dev/null +++ b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Customer.CustomerType.dcm.xml @@ -0,0 +1,14 @@ + + + + + + + + + + +