Completed
Push — master ( 7d9afb...4e0ac6 )
by Łukasz
49:46 queued 21:48
created

NotificationServiceTest::serviceProvider()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 67

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 67
rs 8.72
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace eZ\Publish\Core\SignalSlot\Tests;
10
11
use eZ\Publish\API\Repository\NotificationService as APINotificationService;
12
use eZ\Publish\API\Repository\Values\Notification\CreateStruct;
13
use eZ\Publish\API\Repository\Values\Notification\Notification;
14
use eZ\Publish\API\Repository\Values\Notification\NotificationList;
15
use eZ\Publish\Core\SignalSlot\NotificationService;
16
use eZ\Publish\Core\SignalSlot\Signal\NotificationService\NotificationCreateSignal;
17
use eZ\Publish\Core\SignalSlot\Signal\NotificationService\NotificationDeleteSignal;
18
use eZ\Publish\Core\SignalSlot\Signal\NotificationService\NotificationReadSignal;
19
use eZ\Publish\Core\SignalSlot\SignalDispatcher;
20
21
class NotificationServiceTest extends ServiceTest
22
{
23
    public function serviceProvider()
24
    {
25
        $notificationId = 5;
26
27
        $notification = new Notification([
28
            'id' => $notificationId,
29
        ]);
30
31
        $createStruct = new CreateStruct([
32
            'ownerId' => 10,
33
            'type' => 'Foo',
34
            'data' => [],
35
        ]);
36
37
        return [
38
            [
39
                'loadNotifications',
40
                [0, 25],
41
                new NotificationList(),
42
                0,
43
            ],
44
            [
45
                'getNotification',
46
                [$notificationId],
47
                new Notification(),
48
                0,
49
            ],
50
            [
51
                'markNotificationAsRead',
52
                [$notification],
53
                null,
54
                1,
55
                NotificationReadSignal::class,
56
                [
57
                    'notificationId' => $notificationId,
58
                ],
59
            ],
60
            [
61
                'getPendingNotificationCount',
62
                [],
63
                10,
64
                0,
65
            ],
66
            [
67
                'deleteNotification',
68
                [$notification],
69
                null,
70
                1,
71
                NotificationDeleteSignal::class,
72
                [
73
                    'notificationId' => $notificationId,
74
                ],
75
            ],
76
            [
77
                'createNotification',
78
                [$createStruct],
79
                $notification,
80
                1,
81
                NotificationCreateSignal::class,
82
                [
83
                    'ownerId' => $createStruct->ownerId,
84
                    'type' => $createStruct->type,
85
                    'data' => $createStruct->data,
86
                ],
87
            ],
88
        ];
89
    }
90
91
    /**
92
     * {@inheritdoc}
93
     */
94
    protected function getServiceMock()
95
    {
96
        return $this->createMock(APINotificationService::class);
97
    }
98
99
    /**
100
     * {@inheritdoc}
101
     */
102
    protected function getSignalSlotService($innerService, SignalDispatcher $dispatcher)
103
    {
104
        return new NotificationService($innerService, $dispatcher);
105
    }
106
}
107