Passed
Push — master ( 43534e...6dc374 )
by Alex
01:15 queued 12s
created

NamedEventTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 11
c 0
b 0
f 0
dl 0
loc 47
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testSetAndGetParameters() 0 14 1
A testGetEventNameWillReturnEventName() 0 5 1
A testImplementsEventNameAwareInterface() 0 5 1
1
<?php
0 ignored issues
show
Coding Style introduced by
End of line character is invalid; expected "\n" but found "\r\n"
Loading history...
2
3
declare(strict_types=1);
4
5
namespace ArpTest\EventDispatcher\Event;
6
7
use Arp\EventDispatcher\Event\NamedEvent;
8
use Arp\EventDispatcher\Event\ParametersInterface;
9
use Arp\EventDispatcher\Resolver\EventNameAwareInterface;
10
use PHPUnit\Framework\MockObject\MockObject;
11
use PHPUnit\Framework\TestCase;
12
13
/**
14
 * @author  Alex Patterson <[email protected]>
15
 * @package ArpTest\EventDispatcher\Event
16
 */
17
final class NamedEventTest extends TestCase
18
{
19
    /**
20
     * Assert that the class implements EventNameAwareInterface.
21
     *
22
     * @covers \Arp\EventDispatcher\Event\NamedEvent
23
     */
24
    public function testImplementsEventNameAwareInterface(): void
25
    {
26
        $namedEvent = new NamedEvent('test');
27
28
        $this->assertInstanceOf(EventNameAwareInterface::class, $namedEvent);
29
    }
30
31
    /**
32
     * Assert that getEventName() will return the name of the event.
33
     *
34
     * @covers \Arp\EventDispatcher\Event\NamedEvent::getEventName
35
     */
36
    public function testGetEventNameWillReturnEventName(): void
37
    {
38
        $namedEvent = new NamedEvent('foo');
39
40
        $this->assertSame('foo', $namedEvent->getEventName());
41
    }
42
43
    /**
44
     * Assert that a empty parameters collection is set by default.
45
     *
46
     * @covers \Arp\EventDispatcher\Event\AbstractEvent::__construct
47
     * @covers \Arp\EventDispatcher\Event\NamedEvent::setParameters
48
     * @covers \Arp\EventDispatcher\Event\NamedEvent::getParameters
49
     */
50
    public function testSetAndGetParameters(): void
51
    {
52
        $params = ['foo' => 'bar'];
53
54
        $namedEvent = new NamedEvent('foo', $params);
55
56
        $this->assertSame($params, $namedEvent->getParameters()->getParams());
57
58
        /** @var ParametersInterface|MockObject $parameters */
59
        $parameters = $this->getMockForAbstractClass(ParametersInterface::class);
60
61
        $namedEvent->setParameters($parameters);
62
63
        $this->assertSame($parameters, $namedEvent->getParameters());
64
    }
65
}
66