Completed
Pull Request — master (#366)
by Beñat
05:23
created

NotificationMarkedAsUnreadEventHandlerSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 5
dl 0
loc 32
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_can_be_handle() 0 19 1
A it_subscribes_to() 0 4 1
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\NotificationMarkedAsUnread;
19
use Kreta\Notifier\Domain\Model\Inbox\Notification\NotificationStatus;
20
use Kreta\Notifier\Domain\ReadEvent\Inbox\Notification\NotificationMarkedAsUnreadEventHandler;
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 NotificationMarkedAsUnreadEventHandlerSpec extends ObjectBehavior
28
{
29
    function let(NotificationView $view)
30
    {
31
        $this->beConstructedWith($view);
32
    }
33
34
    function it_can_be_handle(
35
        NotificationMarkedAsUnread $event,
36
        NotificationView $view,
37
        Notification $notification,
38
        NotificationId $notificationId,
39
        NotificationStatus $status
40
    ) {
41
        $this->shouldHaveType(NotificationMarkedAsUnreadEventHandler::class);
42
        $this->shouldImplement(EventHandler::class);
43
44
        $event->notificationId()->shouldBeCalled()->willReturn($notificationId);
45
        $view->notificationOfId($notificationId)->shouldBeCalled()->willReturn($notification);
46
        $event->status()->shouldBeCalled()->willReturn($status);
47
        $status->status()->shouldBeCalled()->willReturn('unread');
48
49
        $view->save(Argument::type(Notification::class))->shouldBeCalled();
50
51
        $this->handle($event);
52
    }
53
54
    function it_subscribes_to()
55
    {
56
        $this->isSubscribeTo()->shouldReturn(NotificationMarkedAsUnread::class);
57
    }
58
}
59