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

MapperTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testExtractUserPreferencesFromRows() 0 34 1
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