DomainEventPublisherTests::testPublishSubscribe()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 18

Duplication

Lines 21
Ratio 100 %

Importance

Changes 0
Metric Value
dl 21
loc 21
rs 9.3142
c 0
b 0
f 0
cc 1
eloc 18
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Cubiche/Event component.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Domain\EventPublisher\Tests\Units;
13
14
use Cubiche\Core\EventBus\Event\EventBus;
15
use Cubiche\Domain\EventPublisher\DomainEventPublisher;
16
use Cubiche\Domain\EventPublisher\Tests\Fixtures\CounterEventSubscriber;
17
use Cubiche\Domain\EventPublisher\Tests\Fixtures\DecrementCounterEvent;
18
use Cubiche\Domain\EventPublisher\Tests\Fixtures\IncrementCounterEvent;
19
20
/**
21
 * DomainEventPublisher class.
22
 *
23
 * Generated by TestGenerator on 2016-05-03 at 14:58:41.
24
 */
25
class DomainEventPublisherTests extends TestCase
26
{
27
    /**
28
     * Test publish/subscribe method.
29
     */
30 View Code Duplication
    public function testPublishSubscribe()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
    {
32
        $this
33
            ->given($incrementEvent = new IncrementCounterEvent(5))
34
            ->and($decrementEvent = new DecrementCounterEvent(3))
35
            ->and($counterSubscriber = new CounterEventSubscriber())
36
            ->and(DomainEventPublisher::subscribe($counterSubscriber))
37
            ->when(DomainEventPublisher::publish($incrementEvent))
38
            ->then()
39
                ->integer($counterSubscriber->counter())
40
                    ->isEqualTo(5)
41
            ->when(DomainEventPublisher::publish($incrementEvent))
42
            ->then()
43
                ->integer($counterSubscriber->counter())
44
                    ->isEqualTo(10)
45
            ->when(DomainEventPublisher::publish($decrementEvent))
46
            ->then()
47
                ->integer($counterSubscriber->counter())
48
                    ->isEqualTo(7)
49
        ;
50
    }
51
52
    /**
53
     * Test set method.
54
     */
55 View Code Duplication
    public function testSet()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
56
    {
57
        $this
58
            ->given($incrementEvent = new IncrementCounterEvent(5))
59
            ->and($decrementEvent = new DecrementCounterEvent(3))
60
            ->and($counterSubscriber = new CounterEventSubscriber())
61
            ->and(DomainEventPublisher::set(EventBus::create()))
62
            ->and(DomainEventPublisher::subscribe($counterSubscriber))
63
            ->when(DomainEventPublisher::publish($incrementEvent))
64
            ->then()
65
                ->integer($counterSubscriber->counter())
66
                    ->isEqualTo(5)
67
            ->when(DomainEventPublisher::publish($incrementEvent))
68
            ->then()
69
                ->integer($counterSubscriber->counter())
70
                    ->isEqualTo(10)
71
            ->when(DomainEventPublisher::publish($decrementEvent))
72
            ->then()
73
                ->integer($counterSubscriber->counter())
74
                    ->isEqualTo(7)
75
        ;
76
    }
77
78
    /**
79
     * Test eventBus method.
80
     */
81
    public function testEventBus()
82
    {
83
        $this
84
            ->given($eventBus = EventBus::create())
85
            ->when(DomainEventPublisher::set($eventBus))
86
            ->then()
87
                ->object(DomainEventPublisher::eventBus())
88
                    ->isEqualTo($eventBus)
89
        ;
90
    }
91
}
92