Completed
Push — master ( 096858...7ec34d )
by Gabriel
03:50
created

EventManagerTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 13
c 1
b 0
f 1
dl 0
loc 22
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A test_dispatch() 0 20 1
1
<?php
2
3
namespace Nip\Records\Tests\EventManager;
4
5
use Nip\Records\EventManager\EventManager;
6
use Nip\Records\EventManager\Events\Event;
7
use Nip\Records\EventManager\Events\Observe;
8
use Nip\Records\Tests\AbstractTest;
9
use Nip\Records\Tests\Fixtures\Records\Books\Book;
10
use Nip\Records\Tests\Fixtures\Records\Books\Books;
11
12
/**
13
 * Class EventManagerTest
14
 * @package Nip\Records\Tests\EventManager
15
 */
16
class EventManagerTest extends AbstractTest
17
{
18
    public function test_dispatch()
19
    {
20
        $manager = Books::instance();
21
22
        $emanager = EventManager::instance();
23
24
        $called = 0;
25
        $emanager->registerModelEvent(
26
            Observe::RETRIEVED,
27
            $manager,
28
            function () use (&$called) {
29
                $called++;
30
            }
31
        );
32
33
        $event = Event::create(Observe::RETRIEVED, $manager);
34
        $emanager->dispatch($event);
35
        $emanager->dispatch($event);
36
37
        self::assertSame(2, $called);
38
    }
39
}