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
|
|
|
namespace eZ\Publish\API\Repository\Tests; |
8
|
|
|
|
9
|
|
|
use Doctrine\DBAL\ParameterType; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Base class for trash specific tests. |
13
|
|
|
*/ |
14
|
|
|
abstract class BaseTrashServiceTest extends BaseTest |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* Creates a trashed item from the <b>Community</b> page location and stores |
18
|
|
|
* this item in a location variable named <b>$trashItem</b>. |
19
|
|
|
* |
20
|
|
|
* @return \eZ\Publish\API\Repository\Values\Content\TrashItem |
21
|
|
|
*/ |
22
|
|
|
protected function createTrashItem() |
23
|
|
|
{ |
24
|
|
|
$repository = $this->getRepository(); |
25
|
|
|
|
26
|
|
|
/* BEGIN: Inline */ |
27
|
|
|
// remoteId of the "Media" page main location |
28
|
|
|
$mediaRemoteId = '75c715a51699d2d309a924eca6a95145'; |
29
|
|
|
|
30
|
|
|
$trashService = $repository->getTrashService(); |
31
|
|
|
$locationService = $repository->getLocationService(); |
32
|
|
|
|
33
|
|
|
// Load "Media" page location |
34
|
|
|
$mediaLocation = $locationService->loadLocationByRemoteId( |
35
|
|
|
$mediaRemoteId |
36
|
|
|
); |
37
|
|
|
|
38
|
|
|
// Trash the "Community" page location |
39
|
|
|
$trashItem = $trashService->trash($mediaLocation); |
40
|
|
|
/* END: Inline */ |
41
|
|
|
|
42
|
|
|
return $trashItem; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @throws \ErrorException |
47
|
|
|
*/ |
48
|
|
|
protected function updateTrashedDate(int $locationId, int $newTimestamp): void |
49
|
|
|
{ |
50
|
|
|
$connection = $this->getRawDatabaseConnection(); |
51
|
|
|
$query = $connection->createQueryBuilder(); |
52
|
|
|
$query |
53
|
|
|
->update('ezcontentobject_trash') |
54
|
|
|
->set('trashed', ':trashed_timestamp') |
55
|
|
|
->where('node_id = :location_id') |
56
|
|
|
->setParameter('trashed_timestamp', $newTimestamp, ParameterType::INTEGER) |
57
|
|
|
->setParameter('location_id', $locationId, ParameterType::INTEGER); |
58
|
|
|
$query->execute(); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|