DispatchPresenterTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 9.4285
1
<?php
2
3
namespace Symnedi\EventDispatcher\Tests\NetteEvent;
4
5
use Nette\Application\Application;
6
use Nette\Application\IResponse;
7
use Nette\Application\UI\Presenter;
8
use PHPUnit_Framework_TestCase;
9
use Symnedi\EventDispatcher\Event\PresenterResponseEvent;
10
use Symnedi\EventDispatcher\NettePresenterEvents;
11
use Symnedi\EventDispatcher\Tests\ContainerFactory;
12
13
14
final class DispatchPresenterTest extends PHPUnit_Framework_TestCase
15
{
16
17
	/**
18
	 * @var Application
19
	 */
20
	private $application;
21
22
	/**
23
	 * @var EventStateStorage
24
	 */
25
	private $eventStateStorage;
26
27
28
	protected function setUp()
29
	{
30
		$containerFactory = (new ContainerFactory)->create();
31
		$this->application = $containerFactory->getByType(Application::class);
32
		$this->eventStateStorage = $containerFactory->getByType(EventStateStorage::class);
33
	}
34
35
36
	public function testDispatch()
37
	{
38
		$this->application->run();
39
40
		/** @var PresenterResponseEvent $presenterResponseEvent */
41
		$presenterResponseEvent = $this->eventStateStorage->getEventState(NettePresenterEvents::ON_SHUTDOWN);
42
		$this->assertInstanceOf(Presenter::class, $presenterResponseEvent->getPresenter());
43
		$this->assertNull($presenterResponseEvent->getResponse());
44
	}
45
46
}
47