|
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\Application\DataTransformer\Organization; |
|
14
|
|
|
|
|
15
|
|
|
use Kreta\SharedKernel\Domain\Model\Identity\Slug; |
|
16
|
|
|
use Kreta\TaskManager\Application\DataTransformer\Organization\MemberDataTransformer; |
|
17
|
|
|
use Kreta\TaskManager\Application\DataTransformer\Organization\MemberDTODataTransformer; |
|
18
|
|
|
use Kreta\TaskManager\Domain\Model\Organization\Organization; |
|
19
|
|
|
use Kreta\TaskManager\Domain\Model\Organization\OrganizationId; |
|
20
|
|
|
use Kreta\TaskManager\Domain\Model\Organization\OrganizationMember; |
|
21
|
|
|
use Kreta\TaskManager\Domain\Model\Organization\OrganizationMemberId; |
|
22
|
|
|
use Kreta\TaskManager\Domain\Model\Organization\OrganizationName; |
|
23
|
|
|
use Kreta\TaskManager\Domain\Model\User\UserId; |
|
24
|
|
|
use PhpSpec\ObjectBehavior; |
|
25
|
|
|
|
|
26
|
|
|
class MemberDTODataTransformerSpec extends ObjectBehavior |
|
27
|
|
|
{ |
|
28
|
|
|
function it_is_initializable() |
|
29
|
|
|
{ |
|
30
|
|
|
$this->shouldHaveType(MemberDTODataTransformer::class); |
|
31
|
|
|
$this->shouldImplement(MemberDataTransformer::class); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
function it_transform_member_to_plain_dto() |
|
35
|
|
|
{ |
|
36
|
|
|
$userId = UserId::generate('user-id'); |
|
37
|
|
|
$organization = new Organization( |
|
38
|
|
|
OrganizationId::generate('organization-id'), |
|
39
|
|
|
new OrganizationName('Organization name'), |
|
40
|
|
|
new Slug('Organization name'), |
|
41
|
|
|
$userId |
|
42
|
|
|
); |
|
43
|
|
|
$member = new OrganizationMember( |
|
44
|
|
|
OrganizationMemberId::generate('member-id'), |
|
45
|
|
|
$userId, |
|
46
|
|
|
$organization |
|
47
|
|
|
); |
|
48
|
|
|
|
|
49
|
|
|
$this->write($member); |
|
50
|
|
|
$this->read()->shouldReturn([ |
|
51
|
|
|
'id' => 'member-id', |
|
52
|
|
|
'created_on' => (new \DateTimeImmutable())->format('Y-m-d'), |
|
53
|
|
|
'updated_on' => (new \DateTimeImmutable())->format('Y-m-d'), |
|
54
|
|
|
'user_id' => 'user-id', |
|
55
|
|
|
'organization' => [ |
|
56
|
|
|
[ |
|
57
|
|
|
'id' => 'organization-id', |
|
58
|
|
|
'name' => 'Organization name', |
|
59
|
|
|
'slug' => 'organization-name', |
|
60
|
|
|
'created_on' => (new \DateTimeImmutable())->format('Y-m-d'), |
|
61
|
|
|
'updated_on' => (new \DateTimeImmutable())->format('Y-m-d'), |
|
62
|
|
|
], |
|
63
|
|
|
], |
|
64
|
|
|
]); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
function it_does_not_transformer_when_member_is_null() |
|
68
|
|
|
{ |
|
69
|
|
|
$this->read()->shouldReturn([]); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|