Code Duplication    Length = 12-22 lines in 6 locations

eZ/Publish/Core/Persistence/Legacy/Tests/Content/FieldValue/Converter/RelationListTest.php 1 location

@@ 173-194 (lines=22) @@
170
     * @group fieldType
171
     * @group relationlist
172
     */
173
    public function testToFieldValueEmpty()
174
    {
175
        $storageFieldValue = new StorageFieldValue();
176
        $storageFieldValue->sortKeyString = '';
177
        $storageFieldValue->dataText = <<<EOT
178
<?xml version="1.0" encoding="utf-8"?>
179
<related-objects><relation-list/></related-objects>
180
181
EOT;
182
183
        $expectedFieldValue = new FieldValue();
184
        $expectedFieldValue->data = array('destinationContentIds' => array());
185
186
        $actualFieldValue = new FieldValue();
187
188
        $this->converter->toFieldValue($storageFieldValue, $actualFieldValue);
189
190
        $this->assertEquals(
191
            $expectedFieldValue,
192
            $actualFieldValue
193
        );
194
    }
195
196
    /**
197
     * @group fieldType

eZ/Publish/Core/Persistence/Legacy/Tests/Content/FieldValue/Converter/SelectionTest.php 4 locations

@@ 41-59 (lines=19) @@
38
     * @group selection
39
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\SelectionConverter::toStorageValue
40
     */
41
    public function testToStorageValue()
42
    {
43
        $fieldValue = new FieldValue();
44
        $fieldValue->data = array(1, 3);
45
        $fieldValue->sortKey = '1-3';
46
47
        $expectedStorageFieldValue = new StorageFieldValue();
48
        $expectedStorageFieldValue->dataText = '1-3';
49
        $expectedStorageFieldValue->sortKeyString = '1-3';
50
51
        $actualStorageFieldValue = new StorageFieldValue();
52
53
        $this->converter->toStorageValue($fieldValue, $actualStorageFieldValue);
54
55
        $this->assertEquals(
56
            $expectedStorageFieldValue,
57
            $actualStorageFieldValue
58
        );
59
    }
60
61
    /**
62
     * @group fieldType
@@ 66-84 (lines=19) @@
63
     * @group selection
64
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\SelectionConverter::toStorageValue
65
     */
66
    public function testToStorageValueEmpty()
67
    {
68
        $fieldValue = new FieldValue();
69
        $fieldValue->data = array();
70
        $fieldValue->sortKey = '';
71
72
        $expectedStorageFieldValue = new StorageFieldValue();
73
        $expectedStorageFieldValue->dataText = '';
74
        $expectedStorageFieldValue->sortKeyString = '';
75
76
        $actualStorageFieldValue = new StorageFieldValue();
77
78
        $this->converter->toStorageValue($fieldValue, $actualStorageFieldValue);
79
80
        $this->assertEquals(
81
            $expectedStorageFieldValue,
82
            $actualStorageFieldValue
83
        );
84
    }
85
86
    /**
87
     * @group fieldType
@@ 91-109 (lines=19) @@
88
     * @group selection
89
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\SelectionConverter::toFieldValue
90
     */
91
    public function testToFieldValue()
92
    {
93
        $storageFieldValue = new StorageFieldValue();
94
        $storageFieldValue->dataText = '1-3';
95
        $storageFieldValue->sortKeyString = '1-3';
96
97
        $expectedFieldValue = new FieldValue();
98
        $expectedFieldValue->data = array(1, 3);
99
        $expectedFieldValue->sortKey = '1-3';
100
101
        $actualFieldValue = new FieldValue();
102
103
        $this->converter->toFieldValue($storageFieldValue, $actualFieldValue);
104
105
        $this->assertEquals(
106
            $expectedFieldValue,
107
            $actualFieldValue
108
        );
109
    }
110
111
    /**
112
     * @group fieldType
@@ 116-134 (lines=19) @@
113
     * @group selection
114
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\SelectionConverter::toFieldValue
115
     */
116
    public function testToFieldValueEmpty()
117
    {
118
        $storageFieldValue = new StorageFieldValue();
119
        $storageFieldValue->dataText = '';
120
        $storageFieldValue->sortKeyString = '';
121
122
        $expectedFieldValue = new FieldValue();
123
        $expectedFieldValue->data = array();
124
        $expectedFieldValue->sortKey = '';
125
126
        $actualFieldValue = new FieldValue();
127
128
        $this->converter->toFieldValue($storageFieldValue, $actualFieldValue);
129
130
        $this->assertEquals(
131
            $expectedFieldValue,
132
            $actualFieldValue
133
        );
134
    }
135
136
    /**
137
     * @group fieldType

eZ/Publish/Core/Persistence/Legacy/Tests/Content/FieldValue/Converter/UrlTest.php 1 location

@@ 39-50 (lines=12) @@
36
     * @group url
37
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\UrlConverter::toStorageValue
38
     */
39
    public function testToStorageValue()
40
    {
41
        $value = new FieldValue();
42
        $text = 'eZ Systems';
43
        $value->data = array('text' => $text);
44
        $value->externalData = 'http://ez.no/';
45
        $value->sortKey = false;
46
        $storageFieldValue = new StorageFieldValue();
47
48
        $this->converter->toStorageValue($value, $storageFieldValue);
49
        self::assertSame($text, $storageFieldValue->dataText);
50
    }
51
52
    /**
53
     * @group fieldType