|
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\Tests\Core\Persistence\Cache; |
|
10
|
|
|
|
|
11
|
|
|
use eZ\Publish\Core\Persistence\Cache\Tests\AbstractCacheHandlerTest; |
|
12
|
|
|
use eZ\Publish\SPI\Persistence\Notification\CreateStruct; |
|
13
|
|
|
use eZ\Publish\SPI\Persistence\Notification\Handler as SPINotificationHandler; |
|
14
|
|
|
use eZ\Publish\API\Repository\Values\Notification\Notification; |
|
15
|
|
|
use eZ\Publish\SPI\Persistence\Notification\Notification as SPINotification; |
|
16
|
|
|
use eZ\Publish\SPI\Persistence\Notification\UpdateStruct; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Test case for Persistence\Cache\NotificationHandler. |
|
20
|
|
|
*/ |
|
21
|
|
|
class NotificationHandlerTest extends AbstractCacheHandlerTest |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* {@inheritdoc} |
|
25
|
|
|
*/ |
|
26
|
|
|
public function getHandlerMethodName(): string |
|
27
|
|
|
{ |
|
28
|
|
|
return 'notificationHandler'; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* {@inheritdoc} |
|
33
|
|
|
*/ |
|
34
|
|
|
public function getHandlerClassName(): string |
|
35
|
|
|
{ |
|
36
|
|
|
return SPINotificationHandler::class; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* {@inheritdoc} |
|
41
|
|
|
*/ |
|
42
|
|
|
public function providerForUnCachedMethods(): array |
|
43
|
|
|
{ |
|
44
|
|
|
$ownerId = 7; |
|
45
|
|
|
$notificationId = 5; |
|
46
|
|
|
$notification = new Notification([ |
|
47
|
|
|
'id' => $notificationId, |
|
48
|
|
|
'ownerId' => $ownerId, |
|
49
|
|
|
]); |
|
50
|
|
|
|
|
51
|
|
|
// string $method, array $arguments, array? $tags, string? $key, mixed? $returnValue |
|
52
|
|
|
return [ |
|
53
|
|
|
[ |
|
54
|
|
|
'createNotification', |
|
55
|
|
|
[ |
|
56
|
|
|
new CreateStruct(['ownerId' => $ownerId]), |
|
57
|
|
|
], |
|
58
|
|
|
[ |
|
59
|
|
|
'notification-count-' . $ownerId, |
|
60
|
|
|
'notification-pending-count-' . $ownerId, |
|
61
|
|
|
], |
|
62
|
|
|
null, |
|
63
|
|
|
new SPINotification(), |
|
64
|
|
|
], |
|
65
|
|
|
[ |
|
66
|
|
|
'updateNotification', |
|
67
|
|
|
[ |
|
68
|
|
|
$notification, |
|
69
|
|
|
new UpdateStruct(['isPending' => false]), |
|
70
|
|
|
], |
|
71
|
|
|
[ |
|
72
|
|
|
'notification-' . $notificationId, |
|
73
|
|
|
'notification-pending-count-' . $ownerId, |
|
74
|
|
|
], |
|
75
|
|
|
null, |
|
76
|
|
|
new SPINotification(), |
|
77
|
|
|
], |
|
78
|
|
|
[ |
|
79
|
|
|
'delete', |
|
80
|
|
|
[ |
|
81
|
|
|
$notification, |
|
82
|
|
|
], |
|
83
|
|
|
[ |
|
84
|
|
|
'notification-' . $notificationId, |
|
85
|
|
|
'notification-count-' . $ownerId, |
|
86
|
|
|
'notification-pending-count-' . $ownerId, |
|
87
|
|
|
], |
|
88
|
|
|
], |
|
89
|
|
|
[ |
|
90
|
|
|
'loadUserNotifications', [$ownerId, 0, 25], null, null, [], |
|
91
|
|
|
], |
|
92
|
|
|
]; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* {@inheritdoc} |
|
97
|
|
|
*/ |
|
98
|
|
|
public function providerForCachedLoadMethods(): array |
|
99
|
|
|
{ |
|
100
|
|
|
$notificationId = 5; |
|
101
|
|
|
$ownerId = 7; |
|
102
|
|
|
$notificationCount = 10; |
|
103
|
|
|
$notificationCountPending = 5; |
|
104
|
|
|
|
|
105
|
|
|
// string $method, array $arguments, string $key, mixed? $data |
|
106
|
|
|
return [ |
|
107
|
|
|
[ |
|
108
|
|
|
'countPendingNotifications', |
|
109
|
|
|
[ |
|
110
|
|
|
$ownerId, |
|
111
|
|
|
], |
|
112
|
|
|
'ez-notification-pending-count-' . $ownerId, |
|
113
|
|
|
$notificationCount, |
|
114
|
|
|
], |
|
115
|
|
|
[ |
|
116
|
|
|
'countNotifications', |
|
117
|
|
|
[ |
|
118
|
|
|
$ownerId, |
|
119
|
|
|
], |
|
120
|
|
|
'ez-notification-count-' . $ownerId, |
|
121
|
|
|
$notificationCountPending, |
|
122
|
|
|
], |
|
123
|
|
|
[ |
|
124
|
|
|
'getNotificationById', |
|
125
|
|
|
[ |
|
126
|
|
|
$notificationId, |
|
127
|
|
|
], |
|
128
|
|
|
'ez-notification-' . $notificationId, |
|
129
|
|
|
new SPINotification(['id' => $notificationId]), |
|
130
|
|
|
], |
|
131
|
|
|
]; |
|
132
|
|
|
} |
|
133
|
|
|
} |
|
134
|
|
|
|