|
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\TaskManager\Application\DataTransformer\Project; |
|
16
|
|
|
|
|
17
|
|
|
use Kreta\SharedKernel\Domain\Model\Identity\Slug; |
|
18
|
|
|
use Kreta\TaskManager\Application\DataTransformer\Project\ProjectDataTransformer; |
|
19
|
|
|
use Kreta\TaskManager\Application\DataTransformer\Project\ProjectDTODataTransformer; |
|
20
|
|
|
use Kreta\TaskManager\Domain\Model\Organization\OrganizationId; |
|
21
|
|
|
use Kreta\TaskManager\Domain\Model\Project\Project; |
|
22
|
|
|
use Kreta\TaskManager\Domain\Model\Project\ProjectId; |
|
23
|
|
|
use Kreta\TaskManager\Domain\Model\Project\ProjectName; |
|
24
|
|
|
use PhpSpec\ObjectBehavior; |
|
25
|
|
|
|
|
26
|
|
|
class ProjectDTODataTransformerSpec extends ObjectBehavior |
|
27
|
|
|
{ |
|
28
|
|
|
function it_is_initializable() |
|
29
|
|
|
{ |
|
30
|
|
|
$this->shouldHaveType(ProjectDTODataTransformer::class); |
|
31
|
|
|
$this->shouldImplement(ProjectDataTransformer::class); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
function it_transform_project_to_plain_dto( |
|
35
|
|
|
Project $project, |
|
36
|
|
|
ProjectId $projectId, |
|
37
|
|
|
ProjectName $name, |
|
38
|
|
|
Slug $slug, |
|
39
|
|
|
OrganizationId $organizationId, |
|
40
|
|
|
\DateTimeImmutable $createdOn, |
|
41
|
|
|
\DateTimeImmutable $updatedOn |
|
42
|
|
|
) { |
|
43
|
|
|
$project->id()->shouldBeCalled()->willReturn($projectId); |
|
44
|
|
|
$projectId->id()->shouldBeCalled()->willReturn('project-id'); |
|
45
|
|
|
$project->name()->shouldBeCalled()->willReturn($name); |
|
46
|
|
|
$name->name()->shouldBeCalled()->willReturn('The project name'); |
|
47
|
|
|
$project->slug()->shouldBeCalled()->willReturn($slug); |
|
48
|
|
|
$slug->slug()->shouldBeCalled()->willReturn('the-project-name'); |
|
49
|
|
|
$project->createdOn()->shouldBeCalled()->willReturn($createdOn); |
|
50
|
|
|
$project->updatedOn()->shouldBeCalled()->willReturn($updatedOn); |
|
51
|
|
|
$project->organizationId()->shouldBeCalled()->willReturn($organizationId); |
|
52
|
|
|
$organizationId->id()->shouldBeCalled()->willReturn('organization-id'); |
|
53
|
|
|
|
|
54
|
|
|
$createdOn->format('Y-m-d')->shouldBeCalled()->willReturn('2016-10-20'); |
|
55
|
|
|
$updatedOn->format('Y-m-d')->shouldBeCalled()->willReturn('2016-10-22'); |
|
56
|
|
|
|
|
57
|
|
|
$this->write($project); |
|
58
|
|
|
|
|
59
|
|
|
$this->read()->shouldReturn([ |
|
60
|
|
|
'id' => 'project-id', |
|
61
|
|
|
'name' => 'The project name', |
|
62
|
|
|
'slug' => 'the-project-name', |
|
63
|
|
|
'created_on' => '2016-10-20', |
|
64
|
|
|
'updated_on' => '2016-10-22', |
|
65
|
|
|
'organization_id' => 'organization-id', |
|
66
|
|
|
]); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
function it_does_not_transformer_when_project_is_null() |
|
70
|
|
|
{ |
|
71
|
|
|
$this->read()->shouldReturn([]); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|