Passed
Push — master ( e140d0...d9458c )
by Gabriel
12:38
created

DispatchableTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 17
c 1
b 0
f 0
dl 0
loc 35
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_dispatchUnless() 0 10 1
A test_dispatchIf() 0 9 1
A test_dispatch() 0 10 1
1
<?php
2
3
namespace ByTIC\EventDispatcher\Tests\Events;
4
5
use ByTIC\EventDispatcher\Tests\AbstractTest;
6
use ByTIC\EventDispatcher\Tests\Fixtures\Events\Event;
7
use ByTIC\EventDispatcher\Tests\Fixtures\Events\ExtendedEvent;
8
9
/**
10
 * Class DispatchableTest
11
 * @package ByTIC\EventDispatcher\Tests\Events
12
 */
13
class DispatchableTest extends AbstractTest
14
{
15
    public function test_dispatch()
16
    {
17
        $dispatcher = $this->mockDispatcherInContainer();
18
        $dispatcher->shouldReceive('dispatch')->twice()->andReturnArg(0);
19
20
        $event = Event::dispatch();
21
        self::assertInstanceOf(Event::class, $event);
22
23
        $event = ExtendedEvent::dispatch();
24
        self::assertInstanceOf(ExtendedEvent::class, $event);
25
    }
26
27
    public function test_dispatchIf()
28
    {
29
        $dispatcher = $this->mockDispatcherInContainer();
30
        $dispatcher->shouldReceive('dispatch')->once()->andReturnArg(0);
31
32
        self::assertSame(null ,Event::dispatchIf(false));
33
34
        $event = Event::dispatchIf(true);
35
        self::assertInstanceOf(Event::class, $event);
36
    }
37
38
    public function test_dispatchUnless()
39
    {
40
        $dispatcher = $this->mockDispatcherInContainer();
41
        $dispatcher->shouldReceive('dispatch')->once()->andReturnArg(0);
42
43
44
        self::assertSame(null ,Event::dispatchUnless(true));
45
46
        $event = Event::dispatchUnless(false);
47
        self::assertInstanceOf(Event::class, $event);
48
    }
49
}