|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* This file is part of the Aggrego. |
|
5
|
|
|
* (c) Tomasz Kunicki <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
* |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types = 1); |
|
13
|
|
|
|
|
14
|
|
|
namespace spec\Aggrego\CommandLogicUnit\EventConsumer; |
|
15
|
|
|
|
|
16
|
|
|
use Aggrego\CommandConsumer\Client as CommandConsumerClient; |
|
17
|
|
|
use Aggrego\CommandConsumer\Command; |
|
18
|
|
|
use Aggrego\CommandLogicUnit\EventConsumer\Client; |
|
19
|
|
|
use Aggrego\CommandLogicUnit\EventProcessor\EventProcessor; |
|
20
|
|
|
use Aggrego\CommandLogicUnit\Shared\EventProcessor\CommandCollection; |
|
21
|
|
|
use Aggrego\EventConsumer\Shared\Event; |
|
22
|
|
|
use PhpSpec\ObjectBehavior; |
|
23
|
|
|
|
|
24
|
|
|
class ClientSpec extends ObjectBehavior |
|
25
|
|
|
{ |
|
26
|
|
|
function let( |
|
|
|
|
|
|
27
|
|
|
EventProcessor $eventProcessor, |
|
28
|
|
|
CommandConsumerClient $commandConsumerClient |
|
29
|
|
|
) |
|
30
|
|
|
{ |
|
31
|
|
|
$this->beConstructedWith($eventProcessor, $commandConsumerClient); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
function it_is_initializable() |
|
|
|
|
|
|
35
|
|
|
{ |
|
36
|
|
|
$this->shouldHaveType(Client::class); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
function it_should_consume( |
|
40
|
|
|
EventProcessor $eventProcessor, |
|
41
|
|
|
CommandConsumerClient $commandConsumerClient, |
|
42
|
|
|
Command $command, |
|
43
|
|
|
Event $event |
|
44
|
|
|
) |
|
45
|
|
|
{ |
|
46
|
|
|
$eventProcessor->transform($event)->willReturn(new CommandCollection($command->getWrappedObject())); |
|
|
|
|
|
|
47
|
|
|
$this->beConstructedWith($eventProcessor, $commandConsumerClient); |
|
48
|
|
|
|
|
49
|
|
|
$this->consume($event)->shouldReturn(null); |
|
|
|
|
|
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.