Completed
Pull Request — master (#366)
by Beñat
05:22
created

ProjectorSpec::it_cannot_be_cloned()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
15
namespace Spec\Kreta\SharedKernel\Projection;
16
17
use Kreta\SharedKernel\Domain\Model\DomainEventCollection;
18
use Kreta\SharedKernel\Domain\Model\Exception;
19
use Kreta\SharedKernel\Domain\ReadEvent\EventHandler;
20
use Kreta\SharedKernel\Tests\Double\Domain\Model\DomainEventStub;
21
use Kreta\SharedKernel\Tests\Double\Domain\Model\EventSourcingEventStub;
22
use PhpSpec\ObjectBehavior;
23
24
class ProjectorSpec extends ObjectBehavior
25
{
26
    function let()
27
    {
28
        $this->beConstructedInstance();
29
    }
30
31
    function it_cannot_be_cloned()
32
    {
33
        $this->shouldThrow(new Exception('Clone is not supported'))->during__clone();
34
    }
35
36 View Code Duplication
    function it_cannot_project_events_that_not_match_with_registered_handlers(
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...
37
        DomainEventCollection $events,
38
        EventHandler $eventHandler
39
    ) {
40
        $event = new EventSourcingEventStub();
41
42
        $eventHandler->isSubscribeTo()->shouldBeCalled()->willReturn(DomainEventStub::class);
43
        $this->register([$eventHandler]);
44
        $events->toArray()->shouldBeCalled()->willReturn([$event]);
45
        $eventHandler->handle($event)->shouldNotBeCalled();
46
        $this->project($events);
47
    }
48
49 View Code Duplication
    function it_cannot_project_events(DomainEventCollection $events, EventHandler $eventHandler)
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...
50
    {
51
        $event = new DomainEventStub('foo', 'bar');
52
53
        $eventHandler->isSubscribeTo()->shouldBeCalled()->willReturn(DomainEventStub::class);
54
        $this->register([$eventHandler]);
55
        $events->toArray()->shouldBeCalled()->willReturn([$event]);
56
        $eventHandler->handle($event)->shouldBeCalled();
57
        $this->project($events);
58
    }
59
}
60