EnableFiltersSubscriberTest::testDispatchEvent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 11
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 11
loc 11
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zenify\DoctrineFilters\Tests\EventSubscriber;
6
7
use Doctrine\ORM\EntityManagerInterface;
8
use Nette\Application\Application;
9
use Nette\Application\IPresenter;
10
use PHPUnit\Framework\TestCase;
11
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
12
use Symplify\SymfonyEventDispatcher\Adapter\Nette\Event\ApplicationStartupEvent;
13
use Symplify\SymfonyEventDispatcher\Adapter\Nette\Event\PresenterCreatedEvent;
14
use Zenify\DoctrineFilters\Tests\ContainerFactory;
15
16
17 View Code Duplication
final class EnableFiltersSubscriberTest extends TestCase
18
{
19
20
	/**
21
	 * @var EntityManagerInterface
22
	 */
23
	private $entityManager;
24
25
	/**
26
	 * @var EventDispatcherInterface
27
	 */
28
	private $eventDispatcher;
29
30
31
	protected function setUp()
32
	{
33
		$container = (new ContainerFactory)->create();
34
		$this->eventDispatcher = $container->getByType(EventDispatcherInterface::class);
35
		$this->entityManager = $container->getByType(EntityManagerInterface::class);
36
	}
37
38
39
	public function testDispatchEvent()
40
	{
41
		$filters = $this->entityManager->getFilters();
42
		$this->assertCount(0, $filters->getEnabledFilters());
43
44
		$applicationMock = $this->prophesize(Application::class);
45
		$applicationStartupEvent = new ApplicationStartupEvent($applicationMock->reveal());
46
		$this->eventDispatcher->dispatch(ApplicationStartupEvent::NAME, $applicationStartupEvent);
47
48
		$this->assertCount(2, $filters->getEnabledFilters());
49
	}
50
51
}
52