EventProviderTraitTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 30
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testPopEventsReturnsEmptyArrayIfNoEventRaised() 0 9 1
A testPopEventsReturnsArrayWithRaisedEvents() 0 17 1
1
<?php
2
3
namespace Tests\GBProd\DomainEvent;
4
5
use GBProd\DomainEvent\DomainEvent;
6
use GBProd\DomainEvent\EventProviderTrait;
7
8
/**
9
 * Tests for EventProviderTrait
10
 * 
11
 * @author gbprod <[email protected]>
12
 */
13
class EventProviderTraitTest extends \PHPUnit_Framework_TestCase
14
{
15
    public function testPopEventsReturnsEmptyArrayIfNoEventRaised()
16
    {
17
        $provider = $this->getMockForTrait(EventProviderTrait::class);
18
        
19
        $this->assertEquals(
20
            [],
21
            $provider->popEvents()
22
        );
23
    }
24
    
25
    public function testPopEventsReturnsArrayWithRaisedEvents()
26
    {
27
        $provider = $this->getMockForTrait(EventProviderTrait::class);
28
        
29
        $event1 = $this->getMock(DomainEvent::class);
30
        $event2 = $this->getMock(DomainEvent::class);
31
        $event3 = $this->getMock(DomainEvent::class);
32
        
33
        $provider->raise($event1);
34
        $provider->raise($event2);
35
        $provider->raise($event3);
36
        
37
        $this->assertEquals(
38
            [$event1, $event2, $event3],
39
            $provider->popEvents()
40
        );
41
    }
42
}