DispatcherTest::testConstruct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Tests\GBProd\DomainEventBundle\Dispatcher;
4
5
use GBProd\DomainEventBundle\Event\Dispatcher;
6
use GBProd\DomainEvent\DomainEvent;
7
use GBProd\DomainEvent\EventProvider;
8
use GBProd\DomainEvent\EventProviderTrait;
9
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
10
use Symfony\Component\EventDispatcher\Event as SymfonyEvent;
11
12
/**
13
 * Tests for Dispatcher
14
 * 
15
 * @author gbprod <[email protected]>
16
 */
17
class DispatcherTest extends \PHPUnit_Framework_TestCase implements EventProvider
18
{
19
    use EventProviderTrait;
20
    
21
    public function testConstruct()
22
    {
23
        new Dispatcher(
24
            $this->getMock(EventDispatcherInterface::class)
25
        );
26
    }
27
    
28
    public function testDispatchEvent()
29
    {
30
        $event = $this->getMock('GBProd\DomainEvent\DomainEvent');
31
        $this->raise($event);
32
        
33
        $symfonyDispatcher = $this->getMock(EventDispatcherInterface::class);
34
        
35
        $symfonyDispatcher
36
            ->expects($this->once())
37
            ->method('dispatch')
38
            ->with(
39
                'DispatcherTest.'.get_class($event),
40
                $this->isInstanceOf(SymfonyEvent::class)
41
            )
42
        ;
43
        
44
        $dispatcher = new Dispatcher($symfonyDispatcher);
45
        
46
        $dispatcher->dispatch($this);
47
    }
48
}