|
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\Command\Organization; |
|
16
|
|
|
|
|
17
|
|
|
use Kreta\TaskManager\Application\Command\Organization\CreateOrganizationCommand; |
|
18
|
|
|
use PhpSpec\ObjectBehavior; |
|
19
|
|
|
|
|
20
|
|
|
class CreateOrganizationCommandSpec extends ObjectBehavior |
|
21
|
|
|
{ |
|
22
|
|
|
function it_can_be_created_with_basic_info() |
|
23
|
|
|
{ |
|
24
|
|
|
$this->beConstructedWith('reporter-id', 'Organization name'); |
|
25
|
|
|
$this->shouldHaveType(CreateOrganizationCommand::class); |
|
26
|
|
|
$this->id()->shouldNotBe(null); |
|
27
|
|
|
$this->name()->shouldReturn('Organization name'); |
|
28
|
|
|
$this->slug()->shouldReturn(null); |
|
29
|
|
|
$this->reporterId()->shouldReturn('reporter-id'); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
View Code Duplication |
function it_can_be_created_with_basic_info_and_organization_id() |
|
|
|
|
|
|
33
|
|
|
{ |
|
34
|
|
|
$this->beConstructedWith('reporter-id', 'Organization name', 'organization-id'); |
|
35
|
|
|
$this->shouldHaveType(CreateOrganizationCommand::class); |
|
36
|
|
|
$this->id()->shouldReturn('organization-id'); |
|
37
|
|
|
$this->name()->shouldReturn('Organization name'); |
|
38
|
|
|
$this->slug()->shouldReturn(null); |
|
39
|
|
|
$this->reporterId()->shouldReturn('reporter-id'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
function it_can_be_created_with_basic_info_organization_id_reporter_id() |
|
43
|
|
|
{ |
|
44
|
|
|
$this->beConstructedWith( |
|
45
|
|
|
'reporter-id', |
|
46
|
|
|
'Organization name', |
|
47
|
|
|
'organization-id' |
|
48
|
|
|
); |
|
49
|
|
|
$this->id()->shouldReturn('organization-id'); |
|
50
|
|
|
$this->name()->shouldReturn('Organization name'); |
|
51
|
|
|
$this->slug()->shouldReturn(null); |
|
52
|
|
|
$this->reporterId()->shouldReturn('reporter-id'); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
function it_can_be_created_with_basic_info_organization_id_reporter_id_and_slug() |
|
56
|
|
|
{ |
|
57
|
|
|
$this->beConstructedWith( |
|
58
|
|
|
'reporter-id', |
|
59
|
|
|
'Organization name', |
|
60
|
|
|
'organization-id', |
|
61
|
|
|
'organization-slug' |
|
62
|
|
|
); |
|
63
|
|
|
$this->id()->shouldReturn('organization-id'); |
|
64
|
|
|
$this->name()->shouldReturn('Organization name'); |
|
65
|
|
|
$this->slug()->shouldReturn('organization-slug'); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
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.