DispatchPresenterTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
c 2
b 0
f 1
lcom 1
cbo 6
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testDispatch() 0 9 1
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