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\Query\Project\Task; |
16
|
|
|
|
17
|
|
|
use Kreta\TaskManager\Application\Query\Project\Task\CountTasksQuery; |
18
|
|
|
use PhpSpec\ObjectBehavior; |
19
|
|
|
|
20
|
|
|
class CountTasksQuerySpec extends ObjectBehavior |
21
|
|
|
{ |
22
|
|
|
function it_can_be_created() |
23
|
|
|
{ |
24
|
|
|
$this->beConstructedWith('user-id'); |
25
|
|
|
$this->shouldHaveType(CountTasksQuery::class); |
26
|
|
|
$this->userId()->shouldReturn('user-id'); |
27
|
|
|
$this->title()->shouldReturn(null); |
28
|
|
|
$this->parentId()->shouldReturn(null); |
29
|
|
|
$this->priority()->shouldReturn(null); |
30
|
|
|
$this->progress()->shouldReturn(null); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
View Code Duplication |
function it_can_be_created_with_title() |
|
|
|
|
34
|
|
|
{ |
35
|
|
|
$this->beConstructedWith('user-id', null, null, 'Task title'); |
36
|
|
|
$this->shouldHaveType(CountTasksQuery::class); |
37
|
|
|
$this->userId()->shouldReturn('user-id'); |
38
|
|
|
$this->title()->shouldReturn('Task title'); |
39
|
|
|
$this->parentId()->shouldReturn(null); |
40
|
|
|
$this->priority()->shouldReturn(null); |
41
|
|
|
$this->progress()->shouldReturn(null); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
View Code Duplication |
function it_can_be_created_with_priority() |
|
|
|
|
45
|
|
|
{ |
46
|
|
|
$this->beConstructedWith('user-id', null, null, null, 'low'); |
47
|
|
|
$this->shouldHaveType(CountTasksQuery::class); |
48
|
|
|
$this->userId()->shouldReturn('user-id'); |
49
|
|
|
$this->title()->shouldReturn(null); |
50
|
|
|
$this->parentId()->shouldReturn(null); |
51
|
|
|
$this->priority()->shouldReturn('low'); |
52
|
|
|
$this->progress()->shouldReturn(null); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
View Code Duplication |
function it_can_be_created_with_progress() |
|
|
|
|
56
|
|
|
{ |
57
|
|
|
$this->beConstructedWith('user-id', null, null, null, null, 'todo'); |
58
|
|
|
$this->shouldHaveType(CountTasksQuery::class); |
59
|
|
|
$this->userId()->shouldReturn('user-id'); |
60
|
|
|
$this->title()->shouldReturn(null); |
61
|
|
|
$this->parentId()->shouldReturn(null); |
62
|
|
|
$this->priority()->shouldReturn(null); |
63
|
|
|
$this->progress()->shouldReturn('todo'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
function it_can_be_created_with_parent_id() |
67
|
|
|
{ |
68
|
|
|
$this->beConstructedWith('user-id', 'parent-id'); |
69
|
|
|
$this->shouldHaveType(CountTasksQuery::class); |
70
|
|
|
$this->userId()->shouldReturn('user-id'); |
71
|
|
|
$this->title()->shouldReturn(null); |
72
|
|
|
$this->parentId()->shouldReturn('parent-id'); |
73
|
|
|
$this->priority()->shouldReturn(null); |
74
|
|
|
$this->progress()->shouldReturn(null); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
View Code Duplication |
function it_can_be_created_with_project_id() |
|
|
|
|
78
|
|
|
{ |
79
|
|
|
$this->beConstructedWith('user-id', null, 'project-id'); |
80
|
|
|
$this->shouldHaveType(CountTasksQuery::class); |
81
|
|
|
$this->userId()->shouldReturn('user-id'); |
82
|
|
|
$this->title()->shouldReturn(null); |
83
|
|
|
$this->parentId()->shouldReturn(null); |
84
|
|
|
$this->projectId()->shouldReturn('project-id'); |
85
|
|
|
$this->priority()->shouldReturn(null); |
86
|
|
|
$this->progress()->shouldReturn(null); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
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.