Completed
Push — master ( add83c...499be4 )
by André
28:25
created

providerForCachedLoadMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

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