forked from schmittjoh/JMSDiExtraBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix unmapped subclass of a mapped super class problem issue schmittjo…
- Loading branch information
1 parent
8fc65b1
commit 3182d8a
Showing
5 changed files
with
79 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
vendor | ||
composer.lock | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
Tests/Functional/Bundle/TestBundle/Inheritance/MappedSuperClass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
13
Tests/Functional/Bundle/TestBundle/Inheritance/UnmapedSubClass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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([]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |