Completed
Pull Request — master (#142)
by Beñat
02:52
created

EditOrganizationHandlerSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
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\Organization;
14
15
use Kreta\TaskManager\Application\Organization\EditOrganizationCommand;
16
use Kreta\TaskManager\Application\Organization\EditOrganizationHandler;
17
use Kreta\TaskManager\Domain\Model\Organization\Organization;
18
use Kreta\TaskManager\Domain\Model\Organization\OrganizationDoesNotExistException;
19
use Kreta\TaskManager\Domain\Model\Organization\OrganizationId;
20
use Kreta\TaskManager\Domain\Model\Organization\OrganizationRepository;
21
use Kreta\TaskManager\Domain\Model\User\UserRepository;
22
use PhpSpec\ObjectBehavior;
23
use Prophecy\Argument;
24
25
class EditOrganizationHandlerSpec extends ObjectBehavior
26
{
27
    function let(OrganizationRepository $repository, UserRepository $userRepository)
28
    {
29
        $this->beConstructedWith($repository, $userRepository);
30
    }
31
32
    function it_is_initializable()
33
    {
34
        $this->shouldHaveType(EditOrganizationHandler::class);
35
    }
36
37 View Code Duplication
    function it_edits_an_organization(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
38
        EditOrganizationCommand $command,
39
        OrganizationRepository $repository,
40
        Organization $organization
41
    ) {
42
        $command->id()->shouldBeCalled()->willReturn('organization-id');
43
        $repository->organizationOfId(Argument::type(OrganizationId::class))->shouldBeCalled()->willReturn($organization);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 122 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
44
        $command->name()->shouldBeCalled()->willReturn('Organization name');
45
        $command->slug()->shouldBeCalled()->willReturn('organization-slug');
46
        $repository->persist(Argument::type(Organization::class))->shouldBeCalled();
47
        $this->__invoke($command);
48
    }
49
50 View Code Duplication
    function it_edits_an_organization_without_slug(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
51
        EditOrganizationCommand $command,
52
        OrganizationRepository $repository,
53
        Organization $organization
54
    ) {
55
        $command->id()->shouldBeCalled()->willReturn('organization-id');
56
        $repository->organizationOfId(Argument::type(OrganizationId::class))->shouldBeCalled()->willReturn($organization);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 122 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
57
        $command->name()->shouldBeCalled()->willReturn('Organization name');
58
        $command->slug()->shouldBeCalled()->willReturn(null);
59
        $repository->persist(Argument::type(Organization::class))->shouldBeCalled();
60
        $this->__invoke($command);
61
    }
62
63 View Code Duplication
    function it_does_not_edits_an_organization_because_the_organization_does_not_exist(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
64
        EditOrganizationCommand $command,
65
        OrganizationRepository $repository
66
    ) {
67
        $command->id()->shouldBeCalled()->willReturn('organization-id');
68
        $repository->organizationOfId(Argument::type(OrganizationId::class))
69
            ->shouldBeCalled()->willReturn(null);
70
        $this->shouldThrow(OrganizationDoesNotExistException::class)->during__invoke($command);
71
    }
72
}
73