[DoctrineAbstractBundle] added test for new Loader

This commit is contained in:
Bulat Shakirzyanov 2011-02-07 20:03:00 -05:00 committed by Fabien Potencier
parent d447d22809
commit 97679e5bda
4 changed files with 56 additions and 1 deletions

View File

@ -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);

View File

@ -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)
{
}
}

View File

@ -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);
}
}

View 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.');
}
}
}