Completed
Push — master ( a0580c...57df1c )
by Tomasz
01:44
created

UseCaseSpec::it_should_reject_wrong_keys()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 18
nc 1
nop 5
dl 0
loc 34
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace spec\Aggrego\Domain\Api\Command\CreateBoard;
4
5
use PhpSpec\ObjectBehavior;
6
use Prophecy\Argument;
7
use Aggrego\Domain\Api\Command\CreateBoard\Command;
0 ignored issues
show
Bug introduced by
The type Aggrego\Domain\Api\Command\CreateBoard\Command was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Aggrego\Domain\Api\Command\CreateBoard\UseCase;
0 ignored issues
show
Bug introduced by
The type Aggrego\Domain\Api\Command\CreateBoard\UseCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Aggrego\Domain\Exception\ProfileKeySpecificationNotSatisfiedException;
0 ignored issues
show
Bug introduced by
The type Aggrego\Domain\Exception...onNotSatisfiedException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Aggrego\Domain\Factory\ProfileBoardFactory;
0 ignored issues
show
Bug introduced by
The type Aggrego\Domain\Factory\ProfileBoardFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Aggrego\Domain\Factory\ProfileKeySpecificationFactory;
0 ignored issues
show
Bug introduced by
The type Aggrego\Domain\Factory\P...KeySpecificationFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Aggrego\Domain\Model\InitialBoard\Entity\Board as InitialBoard;
0 ignored issues
show
Bug introduced by
The type Aggrego\Domain\Model\InitialBoard\Entity\Board was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Aggrego\Domain\Model\ProgressBoard\Repository;
0 ignored issues
show
Bug introduced by
The type Aggrego\Domain\Model\ProgressBoard\Repository was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Aggrego\Domain\Profile\BoardFactory\Factory;
0 ignored issues
show
Bug introduced by
The type Aggrego\Domain\Profile\BoardFactory\Factory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Aggrego\Domain\Profile\KeySpecification\Specification;
0 ignored issues
show
Bug introduced by
The type Aggrego\Domain\Profile\K...ification\Specification was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Aggrego\Domain\ValueObject\Key;
0 ignored issues
show
Bug introduced by
The type Aggrego\Domain\ValueObject\Key was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Aggrego\Domain\ValueObject\Profile;
0 ignored issues
show
Bug introduced by
The type Aggrego\Domain\ValueObject\Profile was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Aggrego\Domain\ValueObject\Source;
0 ignored issues
show
Bug introduced by
The type Aggrego\Domain\ValueObject\Source was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
20
class UseCaseSpec extends ObjectBehavior
21
{
22
    function let(
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
23
        Repository $boardRepository,
24
        Specification $specification,
25
        ProfileBoardFactory $profileBoardFactory,
26
        Factory $boardFactory
27
    )
28
    {
29
        /** @var Key $key */
30
        $key = Argument::type(Key::class);
31
        /** @var Profile $profile */
32
        $profile = Argument::type(Profile::class);
33
34
        $specification->isSatisfiedBy($key)->willReturn(true);
35
        $specification->isSupported($profile)->willReturn(true);
36
37
        $keySpecificationFactory = new ProfileKeySpecificationFactory([$specification->getWrappedObject()]);
38
        /** @var Key $key */
39
        $key = Argument::type(Key::class);
40
        $boardFactory->factory($key, $profile)->will(
41
            function (array $data) {
42
                $key = $data[0];
43
                /** @var Profile $profile */
44
                $profile = $data[1];
45
                $board = new InitialBoard($key, $profile);
46
                $board->addShard($key, new Source($profile->getName(), $profile->getVersion()));
47
                return $board;
48
            }
49
        );
50
        $profileBoardFactory->factory($profile)->willReturn($boardFactory->getWrappedObject());
51
        $this->beConstructedWith($boardRepository, $keySpecificationFactory, $profileBoardFactory);
52
    }
53
54
    function it_is_initializable()
55
    {
56
        $this->shouldHaveType(UseCase::class);
57
    }
58
59
    function it_should_handle(Command $command)
60
    {
61
        $command->getKey()->willReturn(['key' => 'test']);
62
        $command->getProfileName()->willReturn('test');
63
        $command->getVersionNumber()->willReturn('1.0');
64
        $this->handle($command)->shouldBeNull();
0 ignored issues
show
Bug introduced by
The method handle() does not exist on spec\Aggrego\Domain\Api\...CreateBoard\UseCaseSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

64
        $this->/** @scrutinizer ignore-call */ 
65
               handle($command)->shouldBeNull();
Loading history...
65
    }
66
67
    function it_should_reject_wrong_keys(
68
        Command $command,
69
        Repository $boardRepository,
70
        Specification $specification,
71
        ProfileBoardFactory $profileBoardFactory,
72
        Factory $boardFactory)
73
    {
74
        /** @var Key $key */
75
        $key = Argument::type(Key::class);
76
        /** @var Profile $profile */
77
        $profile = Argument::type(Profile::class);
78
79
        $specification->isSatisfiedBy($key)->willReturn(false);
80
        $specification->isSupported($profile)->willReturn(true);
81
82
        $keySpecificationFactory = new ProfileKeySpecificationFactory([$specification->getWrappedObject()]);
83
84
        $boardFactory->factory($key, $profile)->will(
85
            function (array $data) {
86
                $key = $data[0];
87
                /** @var Profile $profile */
88
                $profile = $data[1];
89
                $board = new InitialBoard($key, $profile);
90
                $board->addShard($key, new Source($profile->getName(), $profile->getVersion()));
91
                return $board;
92
            }
93
        );
94
        $profileBoardFactory->factory($profile)->willReturn($boardFactory->getWrappedObject());
95
        $this->beConstructedWith($boardRepository, $keySpecificationFactory, $profileBoardFactory);
96
97
        $command->getKey()->willReturn(['wrong' => 'key']);
98
        $command->getProfileName()->willReturn('test');
99
        $command->getVersionNumber()->willReturn('1.0');
100
        $this->shouldThrow(ProfileKeySpecificationNotSatisfiedException::class)->during('handle', [$command]);
101
    }
102
}
103