Add failing test for #5715 (unit test for MetadataFilter)
This commit is contained in:
parent
c0f0fe060f
commit
824f62d3bb
@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Doctrine\Tests\ORM\Tools\Console;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Tools\Console\MetadataFilter;
|
||||||
|
use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@see \Doctrine\ORM\Tools\Console\MetadataFilter}
|
||||||
|
*
|
||||||
|
* @covers \Doctrine\ORM\Tools\Console\MetadataFilter
|
||||||
|
*/
|
||||||
|
class MetadataFilterTest extends \Doctrine\Tests\OrmTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var DisconnectedClassMetadataFactory
|
||||||
|
*/
|
||||||
|
private $cmf;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$driver = $this->createAnnotationDriver();
|
||||||
|
$em = $this->_getTestEntityManager();
|
||||||
|
$em->getConfiguration()->setMetadataDriverImpl($driver);
|
||||||
|
|
||||||
|
$this->cmf = new DisconnectedClassMetadataFactory();
|
||||||
|
$this->cmf->setEntityManager($em);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFilterWithArray()
|
||||||
|
{
|
||||||
|
$originalMetadatas = array(
|
||||||
|
$metadataAaa = $this->cmf->getMetadataFor(MetadataFilterTestEntityAaa::CLASSNAME),
|
||||||
|
$metadataBbb = $this->cmf->getMetadataFor(MetadataFilterTestEntityBbb::CLASSNAME),
|
||||||
|
$metadataCcc = $this->cmf->getMetadataFor(MetadataFilterTestEntityCcc::CLASSNAME),
|
||||||
|
);
|
||||||
|
|
||||||
|
$metadatas = $originalMetadatas;
|
||||||
|
$metadatas = MetadataFilter::filter($metadatas, array(
|
||||||
|
'MetadataFilterTestEntityAaa',
|
||||||
|
'MetadataFilterTestEntityCcc',
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertContains($metadataAaa, $metadatas);
|
||||||
|
$this->assertNotContains($metadataBbb, $metadatas);
|
||||||
|
$this->assertContains($metadataCcc, $metadatas);
|
||||||
|
$this->assertCount(2, $metadatas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @Entity */
|
||||||
|
class MetadataFilterTestEntityAaa
|
||||||
|
{
|
||||||
|
const CLASSNAME = __CLASS__;
|
||||||
|
|
||||||
|
/** @Id @Column(type="integer") */
|
||||||
|
protected $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @Entity */
|
||||||
|
class MetadataFilterTestEntityBbb
|
||||||
|
{
|
||||||
|
const CLASSNAME = __CLASS__;
|
||||||
|
|
||||||
|
/** @Id @Column(type="integer") */
|
||||||
|
protected $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @Entity */
|
||||||
|
class MetadataFilterTestEntityCcc
|
||||||
|
{
|
||||||
|
const CLASSNAME = __CLASS__;
|
||||||
|
|
||||||
|
/** @Id @Column(type="integer") */
|
||||||
|
protected $id;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user