|
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
|
|
|
namespace Spec\Kreta\TaskManager\Domain\Model\Organization; |
|
14
|
|
|
|
|
15
|
|
|
use Kreta\TaskManager\Domain\Model\Organization\MemberId; |
|
16
|
|
|
use Kreta\TaskManager\Domain\Model\Organization\OrganizationId; |
|
17
|
|
|
use Kreta\TaskManager\Domain\Model\User\UserId; |
|
18
|
|
|
use PhpSpec\ObjectBehavior; |
|
19
|
|
|
|
|
20
|
|
|
class MemberIdSpec extends ObjectBehavior |
|
21
|
|
|
{ |
|
22
|
|
|
function let(UserId $userId, OrganizationId $organizationId) |
|
23
|
|
|
{ |
|
24
|
|
|
$userId->id()->willReturn('user-id'); |
|
25
|
|
|
$organizationId->id()->willReturn('organization-id'); |
|
26
|
|
|
$this->beConstructedGenerate($userId, $organizationId); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
function it_is_initializable() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->shouldHaveType(MemberId::class); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
function it_renders_to_string() |
|
35
|
|
|
{ |
|
36
|
|
|
$this->__toString()->shouldReturn('UserId: user-id, OrganizationId: organization-id'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
function it_compares_two_ids_that_are_not_equal(MemberId $memberId, UserId $userId2, OrganizationId $organizationId) |
|
40
|
|
|
{ |
|
41
|
|
|
$memberId->organizationId()->shouldBeCalled()->willReturn($organizationId); |
|
42
|
|
|
$memberId->userId()->shouldBeCalled()->willReturn($userId2); |
|
43
|
|
|
$this->equals($memberId)->shouldReturn(false); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
function it_compares_two_ids_that_do_not_have_same_organization_id(MemberId $memberId, OrganizationId $organizationId2) |
|
|
|
|
|
|
47
|
|
|
{ |
|
48
|
|
|
$memberId->organizationId()->shouldBeCalled()->willReturn($organizationId2); |
|
49
|
|
|
$this->equals($memberId)->shouldReturn(false); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
function it_compares_two_ids_that_are_equals(MemberId $memberId, UserId $userId, OrganizationId $organizationId) |
|
53
|
|
|
{ |
|
54
|
|
|
$memberId->organizationId()->shouldBeCalled()->willReturn($organizationId); |
|
55
|
|
|
$memberId->userId()->shouldBeCalled()->willReturn($userId); |
|
56
|
|
|
$this->equals($memberId)->shouldReturn(true); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.