Completed
Push — location_multi_load ( e5e305...41e541 )
by André
51:38 queued 33:21
created

providerForCachedLoadMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 27
rs 9.488
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\Tests\Core\Persistence\Cache;
10
11
use eZ\Publish\Core\Persistence\Cache\Tests\AbstractCacheHandlerTest;
12
use eZ\Publish\SPI\Persistence\UserPreference\UserPreferenceSetStruct;
13
use eZ\Publish\SPI\Persistence\UserPreference\Handler as SPIUserPreferenceHandler;
14
use eZ\Publish\SPI\Persistence\UserPreference\UserPreference as SPIUserPreference;
15
16
/**
17
 * Test case for Persistence\Cache\UserPreferenceHandler.
18
 */
19
class UserPreferenceHandlerTest extends AbstractCacheHandlerTest
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function getHandlerMethodName(): string
25
    {
26
        return 'userPreferenceHandler';
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function getHandlerClassName(): string
33
    {
34
        return SPIUserPreferenceHandler::class;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function providerForUnCachedMethods(): array
41
    {
42
        $userId = 7;
43
        $name = 'setting';
44
45
        // string $method, array $arguments, array? $tags, string? $key, mixed? $returnValue
46
        return [
47
            [
48
                'setUserPreference',
49
                [
50
                    new UserPreferenceSetStruct([
51
                        'userId' => $userId,
52
                        'name' => $name,
53
                    ]),
54
                ],
55
                [
56
                    'user-preference-count-' . $userId,
57
                    'user-preference-' . $userId . '-' . $name,
58
                ],
59
                null,
60
                new SPIUserPreference(),
61
            ],
62
            [
63
                'loadUserPreferences', [$userId, 0, 25], null, null, [],
64
            ],
65
        ];
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    public function providerForCachedLoadMethods(): array
72
    {
73
        $userId = 7;
74
        $name = 'setting';
75
        $userPreferenceCount = 10;
76
77
        // string $method, array $arguments, string $key, mixed? $data
78
        return [
79
            [
80
                'countUserPreferences',
81
                [
82
                    $userId,
83
                ],
84
                'ez-user-preference-count-' . $userId,
85
                $userPreferenceCount,
86
            ],
87
            [
88
                'getUserPreferenceByUserIdAndName',
89
                [
90
                    $userId,
91
                    $name,
92
                ],
93
                'ez-user-preference-' . $userId . '-' . $name,
94
                new SPIUserPreference(['userId' => $userId, 'name' => $name]),
95
            ],
96
        ];
97
    }
98
}
99