Skip to content

Commit

Permalink
Stop using deprecated ContainerAwareLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed Sep 12, 2023
1 parent 0f9add3 commit 0dc1623
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Loader/SymfonyFixturesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\DataFixtures\Loader;
use LogicException;
use ReflectionClass;
use RuntimeException;
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;

use function array_key_exists;
use function array_values;
use function get_class;
use function sprintf;

final class SymfonyFixturesLoader extends ContainerAwareLoader
final class SymfonyFixturesLoader extends Loader
{
/** @var FixtureInterface[] */
private $loadedFixtures = [];
Expand Down
5 changes: 2 additions & 3 deletions Tests/Command/LoadDataFixturesDoctrineCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Doctrine\Bundle\FixturesBundle\Loader\SymfonyFixturesLoader;
use Doctrine\Persistence\ManagerRegistry;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Container;
use TypeError;

use function sprintf;
Expand All @@ -24,7 +23,7 @@ class LoadDataFixturesDoctrineCommandTest extends TestCase
*/
public function testInstantiatingWithoutManagerRegistry(): void
{
$loader = new SymfonyFixturesLoader(new Container());
$loader = new SymfonyFixturesLoader();

try {
new LoadDataFixturesDoctrineCommand($loader);
Expand All @@ -47,7 +46,7 @@ public function testInstantiatingWithoutManagerRegistry(): void
public function testInstantiatingWithManagerRegistry(): void
{
$registry = $this->createMock(ManagerRegistry::class);
$loader = new SymfonyFixturesLoader(new Container());
$loader = new SymfonyFixturesLoader();

new LoadDataFixturesDoctrineCommand($loader, $registry);
}
Expand Down
7 changes: 3 additions & 4 deletions Tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use LogicException;
use PHPUnit\Framework\TestCase;
use RuntimeException;
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -51,7 +50,7 @@ public function testFixturesLoader(): void
$container = $kernel->getContainer();

$loader = $container->get('test.doctrine.fixtures.loader');
assert($loader instanceof ContainerAwareLoader);
assert($loader instanceof Loader);

$actualFixtures = $loader->getFixtures();
$this->assertCount(2, $actualFixtures);
Expand Down Expand Up @@ -84,7 +83,7 @@ public function testFixturesLoaderWhenFixtureHasDepdencenyThatIsNotYetLoaded():
$container = $kernel->getContainer();

$loader = $container->get('test.doctrine.fixtures.loader');
assert($loader instanceof ContainerAwareLoader);
assert($loader instanceof Loader);

$actualFixtures = $loader->getFixtures();
$this->assertCount(2, $actualFixtures);
Expand Down Expand Up @@ -123,7 +122,7 @@ public function testExceptionWithDependenciesWithRequiredArguments(): void
$container = $kernel->getContainer();

$loader = $container->get('test.doctrine.fixtures.loader');
assert($loader instanceof ContainerAwareLoader);
assert($loader instanceof Loader);

$this->expectException(LogicException::class);
$this->expectExceptionMessage('The getDependencies() method returned a class (Doctrine\Bundle\FixturesBundle\Tests\Fixtures\FooBundle\DataFixtures\RequiredConstructorArgsFixtures) that has required constructor arguments. Upgrade to "doctrine/data-fixtures" version 1.3 or higher to support this.');
Expand Down

0 comments on commit 0dc1623

Please sign in to comment.