Completed
Pull Request — master (#366)
by Beñat
04:48
created

UserSpec::it_can_be_signed_up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 7
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\Notifier\Domain\Model\Inbox;
16
17
use Kreta\Notifier\Domain\Model\Inbox\User;
18
use Kreta\Notifier\Domain\Model\Inbox\UserId;
19
use Kreta\Notifier\Domain\Model\Inbox\UserSignedUp;
20
use Kreta\SharedKernel\Domain\Model\AggregateRoot;
21
use Kreta\SharedKernel\Domain\Model\DomainEventCollection;
22
use Kreta\SharedKernel\Domain\Model\EventSourcedAggregateRoot;
23
use Kreta\SharedKernel\Event\EventStream;
24
use PhpSpec\ObjectBehavior;
25
26
class UserSpec extends ObjectBehavior
27
{
28
    function let(UserId $id)
29
    {
30
        $id->id()->willReturn('user-id');
31
        $this->beConstructedSignUp($id);
32
    }
33
34
    function it_can_be_signed_up()
35
    {
36
        $this->shouldHaveType(User::class);
37
        $this->shouldHaveType(AggregateRoot::class);
38
        $this->shouldImplement(EventSourcedAggregateRoot::class);
39
        $this->shouldHavePublished(UserSignedUp::class);
40
        $this->id()->shouldReturnAnInstanceOf(UserId::class);
41
        $this->__toString()->shouldReturn('user-id');
42
    }
43
44 View Code Duplication
    function it_can_be_reconstituted_user(
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...
45
        EventStream $stream,
46
        UserId $id,
47
        UserSignedUp $userSignedUp,
48
        DomainEventCollection $collection
49
    ) {
50
        $collection->toArray()->willReturn([
51
            $userSignedUp,
52
        ]);
53
        $stream->events()->willReturn($collection);
54
        $stream->aggregateRootId()->shouldBeCalled()->willReturn($id);
55
        $this->beConstructedReconstitute($stream);
56
        $this->id()->shouldReturn($id);
57
        $id->id()->shouldBeCalled()->willReturn('user-id');
58
        $this->__toString()->shouldReturn('user-id');
59
    }
60
}
61