From 3182d8a59993c5e89f4230f092c0bc85bb34a4f0 Mon Sep 17 00:00:00 2001 From: Jhonatan Teixeira Date: Tue, 7 Jun 2016 23:44:37 -0300 Subject: [PATCH 1/3] 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'); + } +} From 38ff3e4cdd65e3ab416bf1c18089d975c4422d54 Mon Sep 17 00:00:00 2001 From: Jhonatan Teixeira Date: Wed, 15 Jun 2016 17:38:36 -0300 Subject: [PATCH 2/3] metadata factory test fix for php 5.3 --- Tests/Functional/MetadataFactoryTest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Tests/Functional/MetadataFactoryTest.php b/Tests/Functional/MetadataFactoryTest.php index 3b99a4f..94b1a29 100644 --- a/Tests/Functional/MetadataFactoryTest.php +++ b/Tests/Functional/MetadataFactoryTest.php @@ -2,7 +2,6 @@ namespace JMS\DiExtraBundle\Tests\Functional; -use JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Inheritance\UnmapedSubClass; use Metadata\MetadataFactory; class MetadataFactoryTest extends BaseTestCase @@ -16,10 +15,15 @@ public function testGetMetadataFromMappedSuperClass() $this->assertInstanceOf('\Metadata\MetadataFactory', $metadataFactory); - $metadata = $metadataFactory->getMetadataForClass(UnmapedSubClass::class); + $metadata = $metadataFactory->getMetadataForClass( + 'JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Inheritance\UnmapedSubClass' + ); $this->assertCount(2, $metadata->classMetadata); - $this->assertEquals(UnmapedSubClass::class, $metadata->getOutsideClassMetadata()->name); + $this->assertEquals( + 'JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Inheritance\UnmapedSubClass', + $metadata->getOutsideClassMetadata()->name + ); } /** From bd7bb44c18b5a192b0ece63cb3fbe2812a61b4df Mon Sep 17 00:00:00 2001 From: Jhonatan Teixeira Date: Wed, 15 Jun 2016 17:42:20 -0300 Subject: [PATCH 3/3] fix deprecation notices --- Tests/Functional/config/framework.yml | 2 +- Tests/Functional/config/twig.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/Functional/config/framework.yml b/Tests/Functional/config/framework.yml index aba0cbf..58b789c 100644 --- a/Tests/Functional/config/framework.yml +++ b/Tests/Functional/config/framework.yml @@ -9,7 +9,7 @@ framework: enabled: true enable_annotations: true router: - resource: %kernel.root_dir%/config/routing.yml + resource: "%kernel.root_dir%/config/routing.yml" services: logger: diff --git a/Tests/Functional/config/twig.yml b/Tests/Functional/config/twig.yml index 105ae64..a6f61d0 100644 --- a/Tests/Functional/config/twig.yml +++ b/Tests/Functional/config/twig.yml @@ -3,5 +3,5 @@ framework: engines: [twig, php] twig: - debug: %kernel.debug% - strict_variables: %kernel.debug% + debug: "%kernel.debug%" + strict_variables: "%kernel.debug%"