Skip to content

Commit 9c0e62a

Browse files
authored
Merge pull request #11686 from greg0ire/3.3.x
Merge 2.20.x up into 3.3.x
2 parents 5aad44c + 94702d1 commit 9c0e62a

File tree

8 files changed

+74
-207
lines changed

8 files changed

+74
-207
lines changed

docs/en/_exts/configurationblock.py

Lines changed: 0 additions & 91 deletions
This file was deleted.

docs/en/make.bat

Lines changed: 0 additions & 113 deletions
This file was deleted.

doctrine-mapping.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321
<xs:choice minOccurs="0" maxOccurs="unbounded">
322322
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
323323
</xs:choice>
324-
<xs:attribute name="value" type="xs:NMTOKEN" use="required"/>
324+
<xs:attribute name="value" type="orm:type" use="required"/>
325325
<xs:attribute name="class" type="orm:fqcn" use="required"/>
326326
<xs:anyAttribute namespace="##other"/>
327327
</xs:complexType>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\Tests\Models\Customer;
6+
7+
class CustomerType
8+
{
9+
/** @var string */
10+
public $name;
11+
12+
public function __construct(string $name)
13+
{
14+
$this->name = $name;
15+
}
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\Tests\Models\Customer;
6+
7+
final class ExternalCustomer extends CustomerType
8+
{
9+
public function __construct(string $name)
10+
{
11+
parent::__construct($name);
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\Tests\Models\Customer;
6+
7+
final class InternalCustomer extends CustomerType
8+
{
9+
public function __construct(string $name)
10+
{
11+
parent::__construct($name);
12+
}
13+
}

tests/Tests/ORM/Mapping/ClassMetadataTest.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\ORM\Mapping\DefaultNamingStrategy;
1515
use Doctrine\ORM\Mapping\DefaultTypedFieldMapper;
1616
use Doctrine\ORM\Mapping\DiscriminatorColumnMapping;
17+
use Doctrine\ORM\Mapping\Driver\XmlDriver;
1718
use Doctrine\ORM\Mapping\JoinTableMapping;
1819
use Doctrine\ORM\Mapping\MappedSuperclass;
1920
use Doctrine\ORM\Mapping\MappingException;
@@ -33,6 +34,7 @@
3334
use Doctrine\Tests\Models\CMS\UserRepository;
3435
use Doctrine\Tests\Models\Company\CompanyContract;
3536
use Doctrine\Tests\Models\Company\CompanyContractListener;
37+
use Doctrine\Tests\Models\Customer\CustomerType;
3638
use Doctrine\Tests\Models\CustomType\CustomTypeParent;
3739
use Doctrine\Tests\Models\DDC117\DDC117Article;
3840
use Doctrine\Tests\Models\DDC117\DDC117ArticleDetails;
@@ -1080,14 +1082,27 @@ public function testItThrowsOnInvalidCallToGetAssociationMappedByTargetField():
10801082

10811083
$metadata->getAssociationMappedByTargetField('foo');
10821084
}
1085+
1086+
public function testClassNameMappingDiscriminatorValue(): void
1087+
{
1088+
$driver = new XmlDriver(
1089+
__DIR__ . '/xml',
1090+
XmlDriver::DEFAULT_FILE_EXTENSION,
1091+
true,
1092+
);
1093+
$xmlElement = $driver->getElement(CustomerType::class);
1094+
self::assertEquals(
1095+
'Doctrine\Tests\Models\Customer\InternalCustomer',
1096+
$xmlElement->children()->{'discriminator-map'}->{'discriminator-mapping'}[0]->attributes()['value'],
1097+
);
1098+
}
10831099
}
10841100

10851101
#[MappedSuperclass]
10861102
class DDC2700MappedSuperClass
10871103
{
1088-
/** @var mixed */
10891104
#[Column]
1090-
private $foo;
1105+
private mixed $foo;
10911106
}
10921107

10931108
class MyNamespacedNamingStrategy extends DefaultNamingStrategy
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
5+
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
6+
<entity name="Doctrine\Tests\Models\Customer\CustomerType" table="customers" inheritance-type="SINGLE_TABLE">
7+
<field name="name" column="name"/>
8+
<discriminator-column name="type" type="string"/>
9+
<discriminator-map>
10+
<discriminator-mapping value="Doctrine\Tests\Models\Customer\InternalCustomer" class="Doctrine\Tests\Models\Customer\InternalCustomer" />
11+
<discriminator-mapping value="Doctrine\Tests\Models\Customer\ExternalCustomer" class="Doctrine\Tests\Models\Customer\ExternalCustomer" />
12+
</discriminator-map>
13+
</entity>
14+
</doctrine-mapping>

0 commit comments

Comments
 (0)