Completed
Push — master ( fbdcb5...b8714e )
by Tomáš
36:22 queued 33:21
created

ConsoleTest::testEnablingOnlyOnce()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 12
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
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