ListenerTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A test_listener() 0 7 1
1
<?php
2
3
namespace Wonderland\Thread\Tests\Mediator\Listener;
4
5
use PHPUnit\Framework\TestCase;
6
use Wonderland\Thread\Event\Event;
7
use Wonderland\Thread\Mediator\Listener\Listener;
8
9
/**
10
 * Class ListenerTest
11
 * @package Wonderland\Thread\Tests\Mediator\Listener
12
 * @author Alice Praud <[email protected]>
13
 */
14
class ListenerTest extends TestCase
15
{
16
	/** @var Listener */
17
	private $listener;
18
19
	/** @var callable */
20
	private $callback;
21
22
	public function setUp()
23
	{
24
		$this->callback = function(){
25
  };
26
		$this->listener = new Listener(Event::POOL_NEW_THREAD, $this->callback);
27
	}
28
29
	public function test_listener()
30
	{
31
		$this->assertSame(Event::POOL_NEW_THREAD, $this->listener->getEventName());
32
		$this->assertSame($this->listener, $this->listener->setEventName(Event::POOL_POST_WAIT_TICK));
33
		$this->assertSame(Event::POOL_POST_WAIT_TICK, $this->listener->getEventName());
34
		$this->assertSame($this->listener, $this->listener->setCallback($this->callback));
35
		$this->listener->notify(new Event('test'));
36
	}
37
38
}
39