1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Zenify\DoctrineFilters\Tests\Console; |
6
|
|
|
|
7
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
use Symfony\Component\Console\Application; |
10
|
|
|
use Symfony\Component\Console\Input\ArgvInput; |
11
|
|
|
use Symfony\Component\Console\Output\NullOutput; |
12
|
|
|
use Zenify\DoctrineFilters\Tests\ContainerFactory; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
final class ConsoleTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var Application |
20
|
|
|
*/ |
21
|
|
|
private $consoleApplication; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var EntityManagerInterface |
25
|
|
|
*/ |
26
|
|
|
private $entityManager; |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
protected function setUp() |
30
|
|
|
{ |
31
|
|
|
$container = (new ContainerFactory)->create(); |
32
|
|
|
$this->consoleApplication = $container->getByType(Application::class); |
33
|
|
|
$this->consoleApplication->setAutoExit(FALSE); |
34
|
|
|
$this->entityManager = $container->getByType(EntityManagerInterface::class); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
public function test() |
39
|
|
|
{ |
40
|
|
|
$this->assertCount(0, $this->entityManager->getFilters()->getEnabledFilters()); |
41
|
|
|
|
42
|
|
|
$this->consoleApplication->run(new ArgvInput, new NullOutput); |
43
|
|
|
|
44
|
|
|
$this->assertCount(2, $this->entityManager->getFilters()->getEnabledFilters()); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
public function testEnablingOnlyOnce() |
49
|
|
|
{ |
50
|
|
|
$this->assertCount(0, $this->entityManager->getFilters()->getEnabledFilters()); |
51
|
|
|
|
52
|
|
|
$this->consoleApplication->run(new ArgvInput, new NullOutput); |
53
|
|
|
|
54
|
|
|
$this->assertCount(2, $this->entityManager->getFilters()->getEnabledFilters()); |
55
|
|
|
|
56
|
|
|
$this->consoleApplication->run(new ArgvInput, new NullOutput); |
57
|
|
|
|
58
|
|
|
$this->assertCount(2, $this->entityManager->getFilters()->getEnabledFilters()); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
} |
62
|
|
|
|