diff --git a/doctrine-mapping.xsd b/doctrine-mapping.xsd
index ebdb12902b..162e45f774 100644
--- a/doctrine-mapping.xsd
+++ b/doctrine-mapping.xsd
@@ -302,7 +302,7 @@
-
+
@@ -414,7 +414,7 @@
-
+
@@ -446,6 +446,13 @@
+
+
+
+
+
+
+
@@ -630,7 +637,7 @@
-
+
diff --git a/tests/Doctrine/Tests/Models/Project/Project.php b/tests/Doctrine/Tests/Models/Project/Project.php
new file mode 100644
index 0000000000..fc64b43561
--- /dev/null
+++ b/tests/Doctrine/Tests/Models/Project/Project.php
@@ -0,0 +1,24 @@
+id = $id;
+ $this->name = $name;
+ }
+}
diff --git a/tests/Doctrine/Tests/Models/Project/ProjectId.php b/tests/Doctrine/Tests/Models/Project/ProjectId.php
new file mode 100644
index 0000000000..cedc0e5bd9
--- /dev/null
+++ b/tests/Doctrine/Tests/Models/Project/ProjectId.php
@@ -0,0 +1,18 @@
+id = $id;
+ }
+}
diff --git a/tests/Doctrine/Tests/Models/Project/ProjectInvalidMapping.php b/tests/Doctrine/Tests/Models/Project/ProjectInvalidMapping.php
new file mode 100644
index 0000000000..ceecd48f75
--- /dev/null
+++ b/tests/Doctrine/Tests/Models/Project/ProjectInvalidMapping.php
@@ -0,0 +1,24 @@
+id = $id;
+ $this->name = $name;
+ }
+}
diff --git a/tests/Doctrine/Tests/Models/Project/ProjectName.php b/tests/Doctrine/Tests/Models/Project/ProjectName.php
new file mode 100644
index 0000000000..ea2177996d
--- /dev/null
+++ b/tests/Doctrine/Tests/Models/Project/ProjectName.php
@@ -0,0 +1,18 @@
+name = $name;
+ }
+}
diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php
index df09f9613d..090a9d1769 100644
--- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php
+++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php
@@ -22,6 +22,10 @@
use Doctrine\Tests\Models\Generic\BooleanModel;
use Doctrine\Tests\Models\GH7141\GH7141Article;
use Doctrine\Tests\Models\GH7316\GH7316Article;
+use Doctrine\Tests\Models\Project\Project;
+use Doctrine\Tests\Models\Project\ProjectId;
+use Doctrine\Tests\Models\Project\ProjectInvalidMapping;
+use Doctrine\Tests\Models\Project\ProjectName;
use Doctrine\Tests\Models\ValueObjects\Name;
use Doctrine\Tests\Models\ValueObjects\Person;
@@ -239,6 +243,10 @@ public static function dataInvalidSchema(): array
UserMissingAttributes::class,
['The attribute \'name\' is required but missing' => 1],
],
+ [
+ ProjectInvalidMapping::class,
+ ['attribute \'type\': [facet \'pattern\'] The value' => 2],
+ ],
];
}
@@ -279,6 +287,23 @@ public function testInvalidEntityOrMappedSuperClassShouldMentionParentClasses():
$this->createClassMetadata(DDC889Class::class);
}
+
+ public function testClassNameInFieldOrId(): void
+ {
+ $class = new ClassMetadata(Project::class);
+ $class->initializeReflection(new RuntimeReflectionService());
+
+ $driver = $this->loadDriver();
+ $driver->loadMetadataForClass(Project::class, $class);
+
+ /** @var array{type: string} $id */
+ $id = $class->getFieldMapping('id');
+ /** @var array{type: string} $name */
+ $name = $class->getFieldMapping('name');
+
+ self::assertEquals(ProjectId::class, $id['type']);
+ self::assertEquals(ProjectName::class, $name['type']);
+ }
}
class CTI
diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.Project.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.Project.dcm.xml
new file mode 100644
index 0000000000..05ad513b7b
--- /dev/null
+++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.Project.dcm.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.ProjectInvalidMapping.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.ProjectInvalidMapping.dcm.xml
new file mode 100644
index 0000000000..d70800a355
--- /dev/null
+++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.Models.Project.ProjectInvalidMapping.dcm.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+