|
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\Query\Project; |
|
14
|
|
|
|
|
15
|
|
|
use Kreta\TaskManager\Application\Query\Project\FilterProjectsQuery; |
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
|
17
|
|
|
|
|
18
|
|
|
class FilterProjectsQuerySpec extends ObjectBehavior |
|
19
|
|
|
{ |
|
20
|
|
|
function it_can_be_created() |
|
21
|
|
|
{ |
|
22
|
|
|
$this->beConstructedWith('user-id', 0, -1); |
|
23
|
|
|
$this->shouldHaveType(FilterProjectsQuery::class); |
|
24
|
|
|
$this->userId()->shouldReturn('user-id'); |
|
25
|
|
|
$this->offset()->shouldReturn(0); |
|
26
|
|
|
$this->limit()->shouldReturn(-1); |
|
27
|
|
|
$this->name()->shouldReturn(null); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
View Code Duplication |
function it_can_be_created_with_name() |
|
|
|
|
|
|
31
|
|
|
{ |
|
32
|
|
|
$this->beConstructedWith('user-id', 0, -1, null, 'Organization name'); |
|
33
|
|
|
$this->shouldHaveType(FilterProjectsQuery::class); |
|
34
|
|
|
$this->userId()->shouldReturn('user-id'); |
|
35
|
|
|
$this->organizationId()->shouldReturn(null); |
|
36
|
|
|
$this->offset()->shouldReturn(0); |
|
37
|
|
|
$this->limit()->shouldReturn(-1); |
|
38
|
|
|
$this->name()->shouldReturn('Organization name'); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
View Code Duplication |
function it_can_be_created_with_organization_id() |
|
|
|
|
|
|
42
|
|
|
{ |
|
43
|
|
|
$this->beConstructedWith('user-id', 0, -1, 'organization-id'); |
|
44
|
|
|
$this->shouldHaveType(FilterProjectsQuery::class); |
|
45
|
|
|
$this->userId()->shouldReturn('user-id'); |
|
46
|
|
|
$this->organizationId()->shouldReturn('organization-id'); |
|
47
|
|
|
$this->offset()->shouldReturn(0); |
|
48
|
|
|
$this->limit()->shouldReturn(-1); |
|
49
|
|
|
$this->name()->shouldReturn(null); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
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.