|
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 Kreta\Notifier\Infrastructure\Symfony\Command; |
|
16
|
|
|
|
|
17
|
|
|
use Kreta\Notifier\Application\Command\Inbox\ReadNotificationCommand; |
|
18
|
|
|
use Kreta\Notifier\Application\Command\Inbox\ReceiveNotificationCommand; |
|
19
|
|
|
use Kreta\Notifier\Application\Command\Inbox\SignUpUserCommand; |
|
20
|
|
|
use Kreta\Notifier\Application\Command\Inbox\UnreadNotificationCommand; |
|
21
|
|
|
use Kreta\SharedKernel\Application\CommandBus; |
|
22
|
|
|
use Kreta\SharedKernel\Domain\Model\Identity\Uuid; |
|
23
|
|
|
use Symfony\Component\Console\Command\Command; |
|
24
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
25
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
26
|
|
|
|
|
27
|
|
|
class TestInboxCommand extends Command |
|
28
|
|
|
{ |
|
29
|
|
|
private $commandBus; |
|
30
|
|
|
|
|
31
|
|
|
public function __construct(CommandBus $commandBus) |
|
32
|
|
|
{ |
|
33
|
|
|
$this->commandBus = $commandBus; |
|
34
|
|
|
parent::__construct('kreta:notifier:inbox:test'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
38
|
|
|
{ |
|
39
|
|
|
$body = 'The notification body'; |
|
40
|
|
|
|
|
41
|
|
|
for ($i = 0; $i < 2; ++$i) { |
|
42
|
|
|
$userId = Uuid::generate(); |
|
43
|
|
|
|
|
44
|
|
|
$signUpUserCommand = new SignUpUserCommand($userId); |
|
45
|
|
|
$this->commandBus->handle($signUpUserCommand); |
|
46
|
|
|
|
|
47
|
|
|
$output->writeln('Signed up the user ' . $i); |
|
48
|
|
|
|
|
49
|
|
|
for ($j = 0; $j < 15; ++$j) { |
|
50
|
|
|
$notificationId = Uuid::generate(); |
|
51
|
|
|
|
|
52
|
|
|
$receiveNotificationCommand = new ReceiveNotificationCommand($body, $userId, $notificationId); |
|
53
|
|
|
$this->commandBus->handle($receiveNotificationCommand); |
|
54
|
|
|
|
|
55
|
|
|
$output->writeln('Received the notification ' . $j); |
|
56
|
|
|
|
|
57
|
|
|
$readNotificationCommand = new ReadNotificationCommand($notificationId, $userId); |
|
58
|
|
|
$this->commandBus->handle($readNotificationCommand); |
|
59
|
|
|
|
|
60
|
|
|
$output->writeln('Read the notification ' . $j); |
|
61
|
|
|
|
|
62
|
|
|
if ($j % 2 === 0) { |
|
63
|
|
|
$unreadNotificationCommand = new UnreadNotificationCommand($notificationId, $userId); |
|
64
|
|
|
$this->commandBus->handle($unreadNotificationCommand); |
|
65
|
|
|
|
|
66
|
|
|
$output->writeln('Unread the notification ' . $j); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|