[DoctrineAbstractBundle] added test for new Loader
This commit is contained in:
parent
d447d22809
commit
97679e5bda
@ -19,7 +19,7 @@ class Loader extends BaseLoader
|
||||
public function addFixture(FixtureInterface $fixture)
|
||||
{
|
||||
if ($fixture instanceof ContainerAwareInterface) {
|
||||
$fixture->setContainer($container);
|
||||
$fixture->setContainer($this->container);
|
||||
}
|
||||
|
||||
parent::addFixture($fixture);
|
||||
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Bundle\DoctrineAbstractBundle\Tests\Common;
|
||||
|
||||
use Doctrine\Common\DataFixtures\FixtureInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
|
||||
class ContainerAwareFixture implements FixtureInterface, ContainerAwareInterface
|
||||
{
|
||||
public $container;
|
||||
|
||||
public function setContainer(ContainerInterface $container = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function load($manager)
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Bundle\DoctrineAbstractBundle\Tests\Common\DataFixtures;
|
||||
|
||||
use Symfony\Bundle\DoctrineAbstractBundle\Tests\TestCase;
|
||||
use Symfony\Bundle\DoctrineAbstractBundle\Tests\Common\ContainerAwareFixture;
|
||||
use Symfony\Bundle\DoctrineAbstractBundle\Common\DataFixtures\Loader;
|
||||
|
||||
class LoaderTest extends TestCase
|
||||
{
|
||||
public function testShouldSetContainerOnContainerAwareFixture()
|
||||
{
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$loader = new Loader($container);
|
||||
$fixture = new ContainerAwareFixture();
|
||||
|
||||
$loader->addFixture($fixture);
|
||||
|
||||
$this->assertSame($container, $fixture->container);
|
||||
}
|
||||
}
|
13
src/Symfony/Bundle/DoctrineAbstractBundle/Tests/TestCase.php
Normal file
13
src/Symfony/Bundle/DoctrineAbstractBundle/Tests/TestCase.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Bundle\DoctrineAbstractBundle\Tests;
|
||||
|
||||
class TestCase extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
if (!class_exists('Doctrine\Common\DataFixtures\Loader')) {
|
||||
$this->markTestSkipped('Doctrine Data Fixtures is not available.');
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user