|
@@ 153-197 (lines=45) @@
|
| 150 |
|
$handler->trashSubtree($locationId); |
| 151 |
|
} |
| 152 |
|
|
| 153 |
|
public function testDeleteTrashItem() |
| 154 |
|
{ |
| 155 |
|
$trashedId = 6; |
| 156 |
|
$contentId = 42; |
| 157 |
|
$relationSourceContentId = 42; |
| 158 |
|
|
| 159 |
|
$handlerMethodName = $this->getHandlerMethodName(); |
| 160 |
|
|
| 161 |
|
$innerHandler = $this->createMock($this->getHandlerClassName()); |
| 162 |
|
|
| 163 |
|
$innerHandler |
| 164 |
|
->expects($this->once()) |
| 165 |
|
->method('loadTrashItem') |
| 166 |
|
->with($trashedId) |
| 167 |
|
->will($this->returnValue(new Trashed(['id' => $trashedId, 'contentId' => $contentId]))); |
| 168 |
|
|
| 169 |
|
$this->persistenceHandlerMock |
| 170 |
|
->method($handlerMethodName) |
| 171 |
|
->will($this->returnValue($innerHandler)); |
| 172 |
|
|
| 173 |
|
$contentHandlerMock = $this->createMock(ContentHandler::class); |
| 174 |
|
|
| 175 |
|
$contentHandlerMock |
| 176 |
|
->expects($this->once()) |
| 177 |
|
->method('loadReverseRelations') |
| 178 |
|
->with($contentId) |
| 179 |
|
->will($this->returnValue([new Relation(['sourceContentId' => $relationSourceContentId])])); |
| 180 |
|
|
| 181 |
|
$this->persistenceHandlerMock |
| 182 |
|
->method('contentHandler') |
| 183 |
|
->will($this->returnValue($contentHandlerMock)); |
| 184 |
|
|
| 185 |
|
$tags = [ |
| 186 |
|
'content-fields-' . $relationSourceContentId, |
| 187 |
|
]; |
| 188 |
|
|
| 189 |
|
$this->cacheMock |
| 190 |
|
->expects($this->once()) |
| 191 |
|
->method('invalidateTags') |
| 192 |
|
->with($tags); |
| 193 |
|
|
| 194 |
|
/** @var \eZ\Publish\SPI\Persistence\Content\Location\Trash\Handler $handler */ |
| 195 |
|
$handler = $this->persistenceCacheHandler->$handlerMethodName(); |
| 196 |
|
$handler->deleteTrashItem($trashedId); |
| 197 |
|
} |
| 198 |
|
|
| 199 |
|
public function testEmptyTrash() |
| 200 |
|
{ |
|
@@ 199-242 (lines=44) @@
|
| 196 |
|
$handler->deleteTrashItem($trashedId); |
| 197 |
|
} |
| 198 |
|
|
| 199 |
|
public function testEmptyTrash() |
| 200 |
|
{ |
| 201 |
|
$trashedId = 6; |
| 202 |
|
$contentId = 42; |
| 203 |
|
$relationSourceContentId = 42; |
| 204 |
|
|
| 205 |
|
$handlerMethodName = $this->getHandlerMethodName(); |
| 206 |
|
|
| 207 |
|
$innerHandler = $this->createMock($this->getHandlerClassName()); |
| 208 |
|
|
| 209 |
|
$innerHandler |
| 210 |
|
->expects($this->once()) |
| 211 |
|
->method('findTrashItems') |
| 212 |
|
->will($this->returnValue([new Trashed(['id' => $trashedId, 'contentId' => $contentId])])); |
| 213 |
|
|
| 214 |
|
$this->persistenceHandlerMock |
| 215 |
|
->method($handlerMethodName) |
| 216 |
|
->will($this->returnValue($innerHandler)); |
| 217 |
|
|
| 218 |
|
$contentHandlerMock = $this->createMock(ContentHandler::class); |
| 219 |
|
|
| 220 |
|
$contentHandlerMock |
| 221 |
|
->expects($this->once()) |
| 222 |
|
->method('loadReverseRelations') |
| 223 |
|
->with($contentId) |
| 224 |
|
->will($this->returnValue([new Relation(['sourceContentId' => $relationSourceContentId])])); |
| 225 |
|
|
| 226 |
|
$this->persistenceHandlerMock |
| 227 |
|
->method('contentHandler') |
| 228 |
|
->will($this->returnValue($contentHandlerMock)); |
| 229 |
|
|
| 230 |
|
$tags = [ |
| 231 |
|
'content-fields-' . $relationSourceContentId, |
| 232 |
|
]; |
| 233 |
|
|
| 234 |
|
$this->cacheMock |
| 235 |
|
->expects($this->once()) |
| 236 |
|
->method('invalidateTags') |
| 237 |
|
->with($tags); |
| 238 |
|
|
| 239 |
|
/** @var \eZ\Publish\SPI\Persistence\Content\Location\Trash\Handler $handler */ |
| 240 |
|
$handler = $this->persistenceCacheHandler->$handlerMethodName(); |
| 241 |
|
$handler->emptyTrash(); |
| 242 |
|
} |
| 243 |
|
} |
| 244 |
|
|