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; |
|
|
|
|
8
|
|
|
use Aggrego\Domain\Api\Command\CreateBoard\UseCase; |
|
|
|
|
9
|
|
|
use Aggrego\Domain\Exception\ProfileKeySpecificationNotSatisfiedException; |
|
|
|
|
10
|
|
|
use Aggrego\Domain\Factory\ProfileBoardFactory; |
|
|
|
|
11
|
|
|
use Aggrego\Domain\Factory\ProfileKeySpecificationFactory; |
|
|
|
|
12
|
|
|
use Aggrego\Domain\Model\InitialBoard\Entity\Board as InitialBoard; |
|
|
|
|
13
|
|
|
use Aggrego\Domain\Model\ProgressBoard\Repository; |
|
|
|
|
14
|
|
|
use Aggrego\Domain\Profile\BoardFactory\Factory; |
|
|
|
|
15
|
|
|
use Aggrego\Domain\Profile\KeySpecification\Specification; |
|
|
|
|
16
|
|
|
use Aggrego\Domain\ValueObject\Key; |
|
|
|
|
17
|
|
|
use Aggrego\Domain\ValueObject\Profile; |
|
|
|
|
18
|
|
|
use Aggrego\Domain\ValueObject\Source; |
|
|
|
|
19
|
|
|
|
20
|
|
|
class UseCaseSpec extends ObjectBehavior |
21
|
|
|
{ |
22
|
|
|
function let( |
|
|
|
|
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(); |
|
|
|
|
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
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths