CallbackHandlerTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace AsyncPHP\Doorman\Tests\Handler;
4
5
use AsyncPHP\Doorman\Handler\CallbackHandler;
6
use AsyncPHP\Doorman\Task\CallbackTask;
7
use AsyncPHP\Doorman\Tests\Test;
8
9
/**
10
 * @covers AsyncPHP\Doorman\Handler\CallbackHandler
11
 */
12
class CallbackHandlerTest extends Test
13
{
14
    /**
15
     * @var CallbackHandler
16
     */
17
    protected $handler;
18
19
    /**
20
     * @inheritdoc
21
     */
22
    public function setUp()
23
    {
24
        parent::setUp();
25
26
        $this->handler = new CallbackHandler();
27
    }
28
29
    /**
30
     * @test
31
     */
32
    public function handlesCallbackTasks()
33
    {
34
        $store = 0;
35
36
        $task1 = new CallbackTask(function () use (&$store) {
37
            $store += 1;
38
        });
39
40
        $task2 = new CallbackTask(function () use (&$store) {
41
            $store += 2;
42
        });
43
44
        $this->handler->handle($task1);
45
        $this->handler->handle($task2);
46
47
        $this->assertEquals(3, $store);
48
    }
49
}
50