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

InMemoryEventStoreSpec::it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 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\Infrastructure\Persistence\InMemory\EventStore;
16
17
use Kreta\SharedKernel\Domain\Model\AggregateDoesNotExistException;
18
use Kreta\SharedKernel\Domain\Model\DomainEventCollection;
19
use Kreta\SharedKernel\Domain\Model\Identity\Id;
20
use Kreta\SharedKernel\Event\EventStore;
21
use Kreta\SharedKernel\Event\Stream;
22
use Kreta\SharedKernel\Event\StreamName;
23
use Kreta\SharedKernel\Infrastructure\Persistence\InMemory\EventStore\InMemoryEventStore;
24
use Kreta\SharedKernel\Tests\Double\Domain\Model\DomainEventStub;
25
use PhpSpec\ObjectBehavior;
26
27
class InMemoryEventStoreSpec extends ObjectBehavior
28
{
29 View Code Duplication
    function it_appends_to(Stream $stream, StreamName $streamName)
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...
30
    {
31
        $this->shouldHaveType(InMemoryEventStore::class);
32
        $this->shouldImplement(EventStore::class);
33
34
        $eventCollection = new DomainEventCollection([
35
            new DomainEventStub('foo', 'bar'),
36
        ]);
37
        $stream->events()->shouldBeCalled()->willReturn($eventCollection);
38
        $stream->name()->shouldBeCalled()->willReturn($streamName);
39
        $streamName->name()->shouldBeCalled()->willReturn('dummy');
40
        $this->appendTo($stream);
41
    }
42
43 View Code Duplication
    function it_get_stream_of_name_given(Stream $stream, StreamName $streamName)
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...
44
    {
45
        $eventCollection = new DomainEventCollection([
46
            new DomainEventStub('foo', 'bar'),
47
        ]);
48
        $stream->events()->shouldBeCalled()->willReturn($eventCollection);
49
        $stream->name()->shouldBeCalled()->willReturn($streamName);
50
        $streamName->name()->shouldBeCalled()->willReturn('dummy');
51
        $this->appendTo($stream);
52
53
        $this->streamOfName($streamName)->shouldReturnAnInstanceOf(Stream::class);
54
    }
55
56
    function it_does_not_get_any_aggregate(StreamName $streamName, Id $aggregateId)
57
    {
58
        $streamName->aggregateId()->shouldBeCalled()->willReturn($aggregateId);
59
        $aggregateId->id()->willReturn('id');
60
61
        $this->shouldThrow(AggregateDoesNotExistException::class)->duringStreamOfName($streamName);
62
    }
63
}
64