From 3182d8a59993c5e89f4230f092c0bc85bb34a4f0 Mon Sep 17 00:00:00 2001 From: Jhonatan Teixeira Date: Tue, 7 Jun 2016 23:44:37 -0300 Subject: [PATCH] fix unmapped subclass of a mapped super class problem issue #39 #186 #228 --- .gitignore | 2 +- Metadata/Driver/AnnotationDriver.php | 4 --- .../Inheritance/MappedSuperClass.php | 33 +++++++++++++++++++ .../Inheritance/UnmapedSubClass.php | 13 ++++++++ Tests/Functional/MetadataFactoryTest.php | 32 ++++++++++++++++++ 5 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 Tests/Functional/Bundle/TestBundle/Inheritance/MappedSuperClass.php create mode 100644 Tests/Functional/Bundle/TestBundle/Inheritance/UnmapedSubClass.php create mode 100644 Tests/Functional/MetadataFactoryTest.php diff --git a/.gitignore b/.gitignore index 7579f74..88e99d5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ vendor -composer.lock +composer.lock \ No newline at end of file diff --git a/Metadata/Driver/AnnotationDriver.php b/Metadata/Driver/AnnotationDriver.php index 53c32d2..f2a02d9 100644 --- a/Metadata/Driver/AnnotationDriver.php +++ b/Metadata/Driver/AnnotationDriver.php @@ -224,10 +224,6 @@ public function loadMetadataForClass(\ReflectionClass $class) } } - if (null == $metadata->id && !$hasInjection) { - return null; - } - return $metadata; } diff --git a/Tests/Functional/Bundle/TestBundle/Inheritance/MappedSuperClass.php b/Tests/Functional/Bundle/TestBundle/Inheritance/MappedSuperClass.php new file mode 100644 index 0000000..8c615fc --- /dev/null +++ b/Tests/Functional/Bundle/TestBundle/Inheritance/MappedSuperClass.php @@ -0,0 +1,33 @@ +foo = $foo; + $this->bar = $bar; + } + + public function getFoo() + { + return $this->foo; + } + + public function getBar() + { + return $this->bar; + } +} diff --git a/Tests/Functional/Bundle/TestBundle/Inheritance/UnmapedSubClass.php b/Tests/Functional/Bundle/TestBundle/Inheritance/UnmapedSubClass.php new file mode 100644 index 0000000..85d6494 --- /dev/null +++ b/Tests/Functional/Bundle/TestBundle/Inheritance/UnmapedSubClass.php @@ -0,0 +1,13 @@ +getMetadataFactory(); + + $this->assertInstanceOf('\Metadata\MetadataFactory', $metadataFactory); + + $metadata = $metadataFactory->getMetadataForClass(UnmapedSubClass::class); + + $this->assertCount(2, $metadata->classMetadata); + $this->assertEquals(UnmapedSubClass::class, $metadata->getOutsideClassMetadata()->name); + } + + /** + * @return MetadataFactory + */ + private function getMetadataFactory() + { + return $this->createClient()->getContainer()->get('jms_di_extra.metadata.metadata_factory'); + } +}