Completed
Push — master ( e714f3...157665 )
by Andrey
02:39
created

testCanInvalidAttachEventToEventManager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Tests;
4
5
6
use Psr\EventManager\EventInterface;
7
use Psr\EventManager\EventManagerInterface;
8
use Event\Event;
9
use Event\EventManager;
10
use Tests\EventTestSuite;
11
12
13
final class EventManagerTest extends EventTestSuite
14
{
15
    public function testCanListenerReturnTrue()
16
    {
17
        $this->assertTrue(call_user_func($this->eventListener));
18
    }
19
20
    public function testCanEventManagerObjectCreated()
21
    {
22
        $this->assertNotEmpty($this->eventManager);
23
    }
24
25
    public function testCanAttachEventToEventManager()
26
    {
27
        $this->assertTrue($this->eventManager->attach($this->event->getName(), $this->eventListener));
28
    }
29
30
    public function testCanInvalidAttachEventToEventManager()
31
    {
32
        $this->assertFalse($this->eventManager->attach($this->event->getName(), null));
0 ignored issues
show
Documentation introduced by
null is of type null, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
33
    }
34
35
    public function testCanDetachEventFromEventManager()
36
    {
37
        $this->assertTrue($this->eventManager->attach($this->event->getName(), $this->eventListener));
38
39
        $this->assertTrue($this->eventManager->detach($this->event->getName(), $this->eventListener));
40
    }
41
42
    public function testCanClearAllListenersFromEvent()
43
    {
44
        $this->eventManager->attach($this->event->getName(), $this->eventListener);
45
46
        $this->assertTrue($this->eventManager->clearListeners($this->event->getName()));
47
48
        $this->assertFalse($this->eventManager->isExistListeners($this->event->getName()));
49
    }
50
}