|
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 Spec\Kreta\Notifier\Domain\ReadEvent\Inbox\Notification; |
|
16
|
|
|
|
|
17
|
|
|
use Kreta\Notifier\Domain\Model\Inbox\Notification\NotificationId; |
|
18
|
|
|
use Kreta\Notifier\Domain\Model\Inbox\Notification\NotificationMarkedAsRead; |
|
19
|
|
|
use Kreta\Notifier\Domain\Model\Inbox\Notification\NotificationStatus; |
|
20
|
|
|
use Kreta\Notifier\Domain\ReadEvent\Inbox\Notification\NotificationMarkedAsReadEventHandler; |
|
21
|
|
|
use Kreta\Notifier\Domain\ReadModel\Inbox\Notification\Notification; |
|
22
|
|
|
use Kreta\Notifier\Domain\ReadModel\Inbox\Notification\NotificationView; |
|
23
|
|
|
use Kreta\SharedKernel\Domain\ReadEvent\EventHandler; |
|
24
|
|
|
use PhpSpec\ObjectBehavior; |
|
25
|
|
|
use Prophecy\Argument; |
|
26
|
|
|
|
|
27
|
|
|
class NotificationMarkedAsReadEventHandlerSpec extends ObjectBehavior |
|
28
|
|
|
{ |
|
29
|
|
|
function let(NotificationView $view) |
|
30
|
|
|
{ |
|
31
|
|
|
$this->beConstructedWith($view); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
function it_can_be_handle( |
|
35
|
|
|
NotificationMarkedAsRead $event, |
|
36
|
|
|
NotificationView $view, |
|
37
|
|
|
Notification $notification, |
|
38
|
|
|
NotificationId $notificationId, |
|
39
|
|
|
NotificationStatus $status, |
|
40
|
|
|
\DateTimeImmutable $occurredOn |
|
41
|
|
|
) { |
|
42
|
|
|
$this->shouldHaveType(NotificationMarkedAsReadEventHandler::class); |
|
43
|
|
|
$this->shouldImplement(EventHandler::class); |
|
44
|
|
|
|
|
45
|
|
|
$event->notificationId()->shouldBeCalled()->willReturn($notificationId); |
|
46
|
|
|
$view->notificationOfId($notificationId)->shouldBeCalled()->willReturn($notification); |
|
47
|
|
|
$event->status()->shouldBeCalled()->willReturn($status); |
|
48
|
|
|
$status->status()->shouldBeCalled()->willReturn('read'); |
|
49
|
|
|
$event->occurredOn()->shouldBeCalled()->willReturn($occurredOn); |
|
50
|
|
|
$occurredOn->getTimestamp()->shouldBeCalled()->willReturn(2313312); |
|
51
|
|
|
|
|
52
|
|
|
$view->save(Argument::type(Notification::class))->shouldBeCalled(); |
|
53
|
|
|
|
|
54
|
|
|
$this->handle($event); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
function it_subscribes_to() |
|
58
|
|
|
{ |
|
59
|
|
|
$this->isSubscribeTo()->shouldReturn(NotificationMarkedAsRead::class); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|