1 | <?php |
||
35 | class TaskDTODataTransformerSpec extends ObjectBehavior |
||
36 | { |
||
37 | function let(OrganizationRepository $organizationRepository, ProjectRepository $projectRepository) |
||
41 | |||
42 | function it_is_initializable() |
||
47 | |||
48 | function it_transform_task_to_plain_dto( |
||
49 | ProjectRepository $projectRepository, |
||
50 | OrganizationRepository $organizationRepository, |
||
51 | Project $project, |
||
52 | OrganizationId $organizationId |
||
53 | ) { |
||
54 | $projectId = ProjectId::generate('project-id'); |
||
55 | $assigneeId = UserId::generate('assignee-id'); |
||
56 | $reporterId = UserId::generate('reporter-id'); |
||
57 | |||
58 | $organization = new Organization( |
||
59 | OrganizationId::generate('organization-id'), |
||
60 | new OrganizationName('Organization name'), |
||
61 | new Slug('Organization name'), |
||
62 | UserId::generate() |
||
63 | ); |
||
64 | $organization->addOwner($assigneeId); |
||
65 | $organization->addOrganizationMember($reporterId); |
||
66 | |||
67 | $assignee = $organization->organizationMember($assigneeId); |
||
68 | $reporter = $organization->organizationMember($reporterId); |
||
69 | |||
70 | $task = new Task( |
||
71 | TaskId::generate('task-id'), |
||
72 | NumericId::fromPrevious(2), |
||
73 | new TaskTitle('The task title'), |
||
74 | 'The task description', |
||
75 | $reporter->id(), |
||
76 | $assignee->id(), |
||
77 | TaskPriority::low(), |
||
78 | $projectId, |
||
79 | TaskId::generate('parent-id') |
||
80 | ); |
||
81 | |||
82 | $projectRepository->projectOfId($projectId)->shouldBeCalled()->willReturn($project); |
||
83 | $project->organizationId()->shouldBeCalled()->willReturn($organizationId); |
||
84 | $organizationRepository->organizationOfId($organizationId)->shouldBeCalled()->willReturn($organization); |
||
85 | |||
86 | $this->write($task); |
||
87 | |||
88 | $this->read()->shouldReturn([ |
||
89 | 'id' => 'task-id', |
||
90 | 'numeric_id' => 3, |
||
91 | 'title' => 'The task title', |
||
92 | 'priority' => 'low', |
||
93 | 'progress' => 'todo', |
||
94 | 'description' => 'The task description', |
||
95 | 'assignee_id' => 'assignee-id', |
||
96 | 'reporter_id' => 'reporter-id', |
||
97 | 'created_on' => (new \DateTimeImmutable())->format('Y-m-d'), |
||
98 | 'updated_on' => (new \DateTimeImmutable())->format('Y-m-d'), |
||
99 | 'project_id' => 'project-id', |
||
100 | 'parent_id' => 'parent-id', |
||
101 | ]); |
||
102 | } |
||
103 | |||
104 | function it_does_not_transformer_when_task_is_null() |
||
108 | } |
||
109 |