Completed
Push — EZP-31287 ( fe8c5c...af9523 )
by
unknown
34:01
created

BookmarkHandlerTest::getHandlerMethodName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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