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

MapperTest::testExtractUserPreferencesFromRows()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 34
rs 9.376
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\Legacy\Tests\UserPreference;
10
11
use eZ\Publish\Core\Persistence\Legacy\UserPreference\Mapper;
12
use eZ\Publish\SPI\Persistence\UserPreference\UserPreference;
13
use PHPUnit\Framework\TestCase;
14
15
class MapperTest extends TestCase
16
{
17
    /**
18
     * @var \eZ\Publish\Core\Persistence\Legacy\UserPreference\Mapper
19
     */
20
    private $mapper;
21
22
    protected function setUp()
23
    {
24
        $this->mapper = new Mapper();
25
    }
26
27
    /**
28
     * @covers \eZ\Publish\Core\Persistence\Legacy\UserPreference\Mapper::extractUserPreferencesFromRows
29
     */
30
    public function testExtractUserPreferencesFromRows()
31
    {
32
        $rows = [
33
            [
34
                'id' => 1,
35
                'user_id' => 5,
36
                'name' => 'setting_1',
37
                'value' => 'value_1',
38
            ],
39
            [
40
                'id' => 1,
41
                'user_id' => 5,
42
                'name' => 'setting_2',
43
                'value' => 'value_2',
44
            ],
45
        ];
46
47
        $objects = [
48
            new UserPreference([
49
                'id' => 1,
50
                'userId' => 5,
51
                'name' => 'setting_1',
52
                'value' => 'value_1',
53
            ]),
54
            new UserPreference([
55
                'id' => 1,
56
                'userId' => 5,
57
                'name' => 'setting_2',
58
                'value' => 'value_2',
59
            ]),
60
        ];
61
62
        $this->assertEquals($objects, $this->mapper->extractUserPreferencesFromRows($rows));
63
    }
64
}
65