1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the TrashServiceTest class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Publish\Core\SignalSlot\Tests; |
10
|
|
|
|
11
|
|
|
use eZ\Publish\API\Repository\TrashService as APITrashService; |
12
|
|
|
use eZ\Publish\API\Repository\Values\Content\Trash\TrashItemDeleteResult; |
13
|
|
|
use eZ\Publish\API\Repository\Values\Content\Trash\TrashItemDeleteResultList; |
14
|
|
|
use eZ\Publish\Core\Repository\Values\Content\TrashItem; |
15
|
|
|
use eZ\Publish\Core\Repository\Values\Content\Location; |
16
|
|
|
use eZ\Publish\API\Repository\Values\Content\Query; |
17
|
|
|
use eZ\Publish\API\Repository\Values\Content\Search\SearchResult; |
18
|
|
|
use eZ\Publish\Core\SignalSlot\SignalDispatcher; |
19
|
|
|
use eZ\Publish\Core\SignalSlot\TrashService; |
20
|
|
|
use eZ\Publish\Core\SignalSlot\Signal\TrashService as TrashServiceSignals; |
21
|
|
|
|
22
|
|
|
class TrashServiceTest extends ServiceTest |
23
|
|
|
{ |
24
|
|
|
protected function getServiceMock() |
25
|
|
|
{ |
26
|
|
|
return $this->createMock(APITrashService::class); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
protected function getSignalSlotService($coreService, SignalDispatcher $dispatcher) |
30
|
|
|
{ |
31
|
|
|
return new TrashService($coreService, $dispatcher); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function serviceProvider() |
35
|
|
|
{ |
36
|
|
|
$newParentLocationId = 2; |
37
|
|
|
$trashItemId = $locationId = 60; |
38
|
|
|
$contentId = 59; |
39
|
|
|
$trashItemContentInfo = $this->getContentInfo($contentId, md5('trash')); |
40
|
|
|
$trashItemParentLocationId = 17; |
41
|
|
|
|
42
|
|
|
$trashItem = new TrashItem( |
43
|
|
|
array( |
44
|
|
|
'id' => $trashItemId, |
45
|
|
|
'contentInfo' => $trashItemContentInfo, |
46
|
|
|
'parentLocationId' => $trashItemParentLocationId, |
47
|
|
|
) |
48
|
|
|
); |
49
|
|
|
|
50
|
|
|
$newParentLocation = new Location( |
51
|
|
|
array( |
52
|
|
|
'id' => $newParentLocationId, |
53
|
|
|
'contentInfo' => $this->getContentInfo(53, md5('root')), |
54
|
|
|
) |
55
|
|
|
); |
56
|
|
|
|
57
|
|
|
$location = new Location( |
58
|
|
|
array( |
59
|
|
|
'id' => $locationId, |
60
|
|
|
'contentInfo' => $trashItemContentInfo, |
61
|
|
|
'parentLocationId' => $trashItemParentLocationId, |
62
|
|
|
) |
63
|
|
|
); |
64
|
|
|
|
65
|
|
|
$locationWithNewParent = new Location( |
66
|
|
|
array( |
67
|
|
|
'id' => $locationId, |
68
|
|
|
'contentInfo' => $trashItemContentInfo, |
69
|
|
|
'parentLocationId' => $newParentLocationId, |
70
|
|
|
) |
71
|
|
|
); |
72
|
|
|
|
73
|
|
|
$trashItemDeleteResult = new TrashItemDeleteResult( |
74
|
|
|
array( |
75
|
|
|
'trashItemId' => $trashItemId, |
76
|
|
|
'contentId' => $contentId, |
77
|
|
|
'contentRemoved' => true, |
78
|
|
|
) |
79
|
|
|
); |
80
|
|
|
|
81
|
|
|
$trashItemDeleteResultList = new TrashItemDeleteResultList( |
82
|
|
|
array( |
83
|
|
|
'items' => array($trashItemDeleteResult), |
84
|
|
|
) |
85
|
|
|
); |
86
|
|
|
|
87
|
|
|
return array( |
88
|
|
|
array( |
89
|
|
|
'loadTrashItem', |
90
|
|
|
array($trashItemId), |
91
|
|
|
$trashItem, |
92
|
|
|
0, |
93
|
|
|
), |
94
|
|
|
array( |
95
|
|
|
'trash', |
96
|
|
|
array($location), |
97
|
|
|
$trashItem, |
98
|
|
|
1, |
99
|
|
|
TrashServiceSignals\TrashSignal::class, |
100
|
|
|
array('locationId' => $locationId), |
101
|
|
|
), |
102
|
|
|
array( |
103
|
|
|
'recover', |
104
|
|
|
array($trashItem, $newParentLocation), |
105
|
|
|
$locationWithNewParent, |
106
|
|
|
1, |
107
|
|
|
'eZ\Publish\Core\SignalSlot\Signal\TrashService\RecoverSignal', |
108
|
|
|
array( |
109
|
|
|
'trashItemId' => $trashItemId, |
110
|
|
|
'newParentLocationId' => $newParentLocationId, |
111
|
|
|
'newLocationId' => $locationId, |
112
|
|
|
), |
113
|
|
|
), |
114
|
|
|
array( |
115
|
|
|
'recover', |
116
|
|
|
array($trashItem, null), |
117
|
|
|
$location, |
118
|
|
|
1, |
119
|
|
|
TrashServiceSignals\RecoverSignal::class, |
120
|
|
|
array( |
121
|
|
|
'trashItemId' => $trashItemId, |
122
|
|
|
'newParentLocationId' => $trashItemParentLocationId, |
123
|
|
|
'newLocationId' => $locationId, |
124
|
|
|
), |
125
|
|
|
), |
126
|
|
|
array( |
127
|
|
|
'emptyTrash', |
128
|
|
|
array(), |
129
|
|
|
$trashItemDeleteResultList, |
130
|
|
|
1, |
131
|
|
|
TrashServiceSignals\EmptyTrashSignal::class, |
132
|
|
|
array('trashItemDeleteResultList' => $trashItemDeleteResultList), |
133
|
|
|
), |
134
|
|
|
array( |
135
|
|
|
'deleteTrashItem', |
136
|
|
|
array($trashItem), |
137
|
|
|
$trashItemDeleteResult, |
138
|
|
|
1, |
139
|
|
|
TrashServiceSignals\DeleteTrashItemSignal::class, |
140
|
|
|
array( |
141
|
|
|
'trashItemId' => $trashItemId, |
142
|
|
|
'trashItemDeleteResult' => $trashItemDeleteResult, |
143
|
|
|
), |
144
|
|
|
), |
145
|
|
|
array( |
146
|
|
|
'findTrashItems', |
147
|
|
|
array(new Query()), |
148
|
|
|
new SearchResult(array('totalCount' => 0)), |
149
|
|
|
0, |
150
|
|
|
), |
151
|
|
|
); |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
|