From 73e30df52bae96f54e583b72074e67094197f5af Mon Sep 17 00:00:00 2001 From: MatteoFeltrin Date: Tue, 14 May 2024 15:06:47 +0200 Subject: [PATCH] allow classname in 'value' attribute of xml discriminator-mapping field --- doctrine-mapping.xsd | 2 +- tests/Tests/Models/Customer/CustomerType.php | 16 ++++++++++++++++ tests/Tests/Models/Customer/ExternalCustomer.php | 13 +++++++++++++ tests/Tests/Models/Customer/InternalCustomer.php | 13 +++++++++++++ tests/Tests/ORM/Mapping/ClassMetadataTest.php | 16 ++++++++++++++++ ...ne.Tests.Models.Customer.CustomerType.dcm.xml | 14 ++++++++++++++ 6 files changed, 73 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 a058787746c..651c9d29c09 100644 --- a/doctrine-mapping.xsd +++ b/doctrine-mapping.xsd @@ -375,7 +375,7 @@ - + diff --git a/tests/Tests/Models/Customer/CustomerType.php b/tests/Tests/Models/Customer/CustomerType.php new file mode 100644 index 00000000000..bd68c07ecf2 --- /dev/null +++ b/tests/Tests/Models/Customer/CustomerType.php @@ -0,0 +1,16 @@ +name = $name; + } +} diff --git a/tests/Tests/Models/Customer/ExternalCustomer.php b/tests/Tests/Models/Customer/ExternalCustomer.php new file mode 100644 index 00000000000..cf50d3e85e0 --- /dev/null +++ b/tests/Tests/Models/Customer/ExternalCustomer.php @@ -0,0 +1,13 @@ +getAssociationMappedByTargetField('foo'); } + + 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'] + ); + } } /** @MappedSuperclass */ 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..8767e3220a8 --- /dev/null +++ b/tests/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Customer.CustomerType.dcm.xml @@ -0,0 +1,14 @@ + + + + + + + + + + +