Completed
Push — inmemory-preferences ( 49b08e )
by André
132:19 queued 108:07
created

UserPreferenceHandlerTest::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\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-count-' . $userId,
58
                    'ez-user-preference-' . $userId . '-' . $name,
59
                ],
60
                new SPIUserPreference(),
61
            ],
62
            [
63
                'loadUserPreferences', [$userId, 0, 25], null, null, [],
64
            ],
65
            [
66
                'countUserPreferences',
67
                [
68
                    $userId,
69
                ],
70
                null,
71
                null,
72
                $userPreferenceCount,
73
            ],
74
        ];
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function providerForCachedLoadMethods(): array
81
    {
82
        $userId = 7;
83
        $name = 'setting';
84
85
        // string $method, array $arguments, string $key, mixed? $data
86
        return [
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