1 | <?php |
||
2 | |||
3 | class InjiTest extends \PHPUnit\Framework\TestCase { |
||
4 | |||
5 | /** |
||
6 | * @covers Inji::listen |
||
7 | * @covers Inji::event |
||
8 | * @covers Inji::unlisten |
||
9 | */ |
||
10 | public function testNotSavingEvent() { |
||
11 | \Inji::$inst->listen('testEvent', 'testCallback', function() { |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
12 | return true; |
||
13 | }); |
||
14 | $this->assertEquals(true, Inji::$inst->event('testEvent')); |
||
15 | \Inji::$inst->unlisten('testEvent', 'testCallback'); |
||
16 | } |
||
17 | |||
18 | /** |
||
19 | * @covers Inji::listen |
||
20 | * @covers Inji::event |
||
21 | * @covers Inji::unlisten |
||
22 | */ |
||
23 | public function testSavingEvent() { |
||
24 | \Inji::$inst->listen('testEvent2', 'testCallback', 'InjiTestcallback', true); |
||
25 | $this->assertEquals(true, Inji::$inst->event('testEvent2')); |
||
26 | \Inji::$inst->unlisten('testEvent2', 'testCallback', true); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @covers Inji::listen |
||
31 | * @covers Inji::event |
||
32 | */ |
||
33 | public function testArrayWithCallback() { |
||
34 | $callbackOptions = ['callback' => 'InjiTestcallbackArray', 'data' => 'data']; |
||
35 | \Inji::$inst->listen('testEvent3', 'testCallback', $callbackOptions); |
||
36 | $this->assertEquals($callbackOptions, Inji::$inst->event('testEvent3')['callbackOptions']); |
||
37 | } |
||
38 | } |
||
39 | |||
40 | function InjiTestcallback() { |
||
41 | return true; |
||
42 | } |
||
43 | |||
44 | function InjiTestcallbackArray($event, $callbackOptions) { |
||
45 | return ['event' => $event, 'callbackOptions' => $callbackOptions]; |
||
46 | } |
||
47 |