-
-
Notifications
You must be signed in to change notification settings - Fork 201
/
LoadDataFixturesDoctrineCommandTest.php
54 lines (42 loc) · 1.89 KB
/
LoadDataFixturesDoctrineCommandTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
declare(strict_types=1);
namespace Doctrine\Bundle\FixturesBundle\Tests\Command;
use Doctrine\Bundle\DoctrineBundle\Command\DoctrineCommand;
use Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand;
use Doctrine\Bundle\FixturesBundle\Loader\SymfonyFixturesLoader;
use Doctrine\Persistence\ManagerRegistry;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\DependencyInjection\Container;
use TypeError;
use function sprintf;
use const PHP_VERSION_ID;
class LoadDataFixturesDoctrineCommandTest extends TestCase
{
use ExpectDeprecationTrait;
/** @group legacy */
public function testInstantiatingWithoutManagerRegistry(): void
{
$loader = new SymfonyFixturesLoader(new Container());
$this->expectDeprecation('Since doctrine/fixtures-bundle 3.2: Argument 2 of Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand::__construct() expects an instance of Doctrine\Persistence\ManagerRegistry, not passing it will throw a \TypeError in DoctrineFixturesBundle 4.0.');
try {
new LoadDataFixturesDoctrineCommand($loader);
} catch (TypeError $e) {
$this->expectExceptionMessage(sprintf(
PHP_VERSION_ID >= 80000 ?
'%s::__construct(): Argument #1 ($doctrine) must be of type %s, null given' :
'Argument 1 passed to %s::__construct() must be an instance of %s, null given',
DoctrineCommand::class,
ManagerRegistry::class,
));
throw $e;
}
}
/** @doesNotPerformAssertions */
public function testInstantiatingWithManagerRegistry(): void
{
$registry = $this->createMock(ManagerRegistry::class);
$loader = new SymfonyFixturesLoader(new Container());
new LoadDataFixturesDoctrineCommand($loader, $registry);
}
}