Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[DoctrineBridge] Add tests for data fixture ContainerAwareLoader

  • Loading branch information...
commit 48a288e9dbfce291cf4e0d1bbca0261dd4a5cb1a 1 parent 3de31c6
Jeremy Mikola jmikola authored
36 tests/Symfony/Tests/Bridge/Doctrine/DataFixtures/ContainerAwareLoaderTest.php
... ... @@ -0,0 +1,36 @@
  1 +<?php
  2 +
  3 +/*
  4 + * This file is part of the Symfony package.
  5 + *
  6 + * (c) Fabien Potencier <fabien@symfony.com>
  7 + *
  8 + * For the full copyright and license information, please view the LICENSE
  9 + * file that was distributed with this source code.
  10 + */
  11 +
  12 +namespace Symfony\Tests\Bridge\Doctrine\DataFixtures;
  13 +
  14 +use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
  15 +use Symfony\Tests\Bridge\Doctrine\Fixtures\ContainerAwareFixture;
  16 +
  17 +class ContainerAwareLoaderTest extends \PHPUnit_Framework_TestCase
  18 +{
  19 + protected function setUp()
  20 + {
  21 + if (!class_exists('Doctrine\Common\DataFixtures\Loader')) {
  22 + $this->markTestSkipped('Doctrine Data Fixtures is not available.');
  23 + }
  24 + }
  25 +
  26 + public function testShouldSetContainerOnContainerAwareFixture()
  27 + {
  28 + $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
  29 + $loader = new ContainerAwareLoader($container);
  30 + $fixture = new ContainerAwareFixture();
  31 +
  32 + $loader->addFixture($fixture);
  33 +
  34 + $this->assertSame($container, $fixture->container);
  35 + }
  36 +}
22 tests/Symfony/Tests/Bridge/Doctrine/Fixtures/ContainerAwareFixture.php
... ... @@ -0,0 +1,22 @@
  1 +<?php
  2 +
  3 +namespace Symfony\Tests\Bridge\Doctrine\Fixtures;
  4 +
  5 +use Doctrine\Common\DataFixtures\FixtureInterface;
  6 +use Doctrine\Common\Persistence\ObjectManager;
  7 +use Symfony\Component\DependencyInjection\ContainerInterface;
  8 +use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  9 +
  10 +class ContainerAwareFixture implements FixtureInterface, ContainerAwareInterface
  11 +{
  12 + public $container;
  13 +
  14 + public function setContainer(ContainerInterface $container = null)
  15 + {
  16 + $this->container = $container;
  17 + }
  18 +
  19 + public function load(ObjectManager $manager)
  20 + {
  21 + }
  22 +}

0 comments on commit 48a288e

Please sign in to comment.
Something went wrong with that request. Please try again.