|
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\Persistence\Cache\Tests; |
|
10
|
|
|
|
|
11
|
|
|
use eZ\Publish\SPI\Persistence\Bookmark\Bookmark; |
|
12
|
|
|
use eZ\Publish\SPI\Persistence\Bookmark\CreateStruct; |
|
13
|
|
|
use eZ\Publish\SPI\Persistence\Bookmark\Handler as SPIBookmarkHandler; |
|
14
|
|
|
use eZ\Publish\SPI\Persistence\Content\Location; |
|
15
|
|
|
use eZ\Publish\SPI\Persistence\Content\Location\Handler as SPILocationHandler; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Test case for Persistence\Cache\BookmarkHandler. |
|
19
|
|
|
*/ |
|
20
|
|
|
class BookmarkHandlerTest extends AbstractCacheHandlerTest |
|
21
|
|
|
{ |
|
22
|
|
|
public function getHandlerMethodName(): string |
|
23
|
|
|
{ |
|
24
|
|
|
return 'bookmarkHandler'; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function getHandlerClassName(): string |
|
28
|
|
|
{ |
|
29
|
|
|
return SPIBookmarkHandler::class; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function providerForUnCachedMethods(): array |
|
33
|
|
|
{ |
|
34
|
|
|
// string $method, array $arguments, array? $tags, string? $key, mixed? $returnValue |
|
35
|
|
|
return [ |
|
36
|
|
|
['create', [new CreateStruct()], null, null, new Bookmark()], |
|
37
|
|
|
['delete', [1], ['bookmark-1']], |
|
38
|
|
|
['loadUserBookmarks', [3, 2, 1], null, null, []], |
|
39
|
|
|
['countUserBookmarks', [3], null, null, 1], |
|
40
|
|
|
['locationSwapped', [1, 2], null, null], |
|
41
|
|
|
]; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function providerForCachedLoadMethods(): array |
|
45
|
|
|
{ |
|
46
|
|
|
$bookmark = new Bookmark([ |
|
47
|
|
|
'id' => 1, |
|
48
|
|
|
'locationId' => 43, |
|
49
|
|
|
'userId' => 3, |
|
50
|
|
|
]); |
|
51
|
|
|
|
|
52
|
|
|
$calls = [['locationHandler', SPILocationHandler::class, 'load', new Location(['pathString' => '/1/2/43/'])]]; |
|
53
|
|
|
|
|
54
|
|
|
// string $method, array $arguments, string $key, mixed? $data |
|
55
|
|
|
return [ |
|
56
|
|
|
['loadByUserIdAndLocationId', [3, [43]], 'ez-bookmark-3-43', [43 => $bookmark], true, $calls], |
|
57
|
|
|
]; |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|