Skip to content

Commit

Permalink
fix unmapped subclass of a mapped super class problem issue schmittjo…
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonatanTeixeira committed Jun 8, 2016
1 parent 8fc65b1 commit 3182d8a
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
vendor
composer.lock
composer.lock
4 changes: 0 additions & 4 deletions Metadata/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,6 @@ public function loadMetadataForClass(\ReflectionClass $class)
}
}

if (null == $metadata->id && !$hasInjection) {
return null;
}

return $metadata;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Inheritance;

use JMS\DiExtraBundle\Annotation as DI;

class MappedSuperClass
{
private $foo;
private $bar;

/**
* @DI\InjectParams
*
* @param stdClass $foo
* @param stdClass $bar
*/
public function __construct($foo, $bar)
{
$this->foo = $foo;
$this->bar = $bar;
}

public function getFoo()
{
return $this->foo;
}

public function getBar()
{
return $this->bar;
}
}
13 changes: 13 additions & 0 deletions Tests/Functional/Bundle/TestBundle/Inheritance/UnmapedSubClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Inheritance;

use JMS\DiExtraBundle\Annotation as DI;

class UnmapedSubClass extends MappedSuperClass
{
public function getFoo()
{
return new \ArrayObject([]);
}
}
32 changes: 32 additions & 0 deletions Tests/Functional/MetadataFactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace JMS\DiExtraBundle\Tests\Functional;

use JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\Inheritance\UnmapedSubClass;
use Metadata\MetadataFactory;

class MetadataFactoryTest extends BaseTestCase
{
/**
* @runInSeparateProcess
*/
public function testGetMetadataFromMappedSuperClass()
{
$metadataFactory = $this->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');
}
}

0 comments on commit 3182d8a

Please sign in to comment.