Code Duplication    Length = 35-35 lines in 2 locations

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

@@ 38-72 (lines=35) @@
35
     * @group fieldType
36
     * @group relationlist
37
     */
38
    public function testToStorageFieldDefinition()
39
    {
40
        $fieldDefinition = new PersistenceFieldDefinition(
41
            [
42
                'fieldTypeConstraints' => new FieldTypeConstraints(
43
                    [
44
                        'fieldSettings' => [
45
                            'selectionMethod' => Type::SELECTION_BROWSE,
46
                            'selectionRoot' => 12345,
47
                            'selectionContentTypes' => ['article', 'blog_post'],
48
                        ],
49
                    ]
50
                ),
51
            ]
52
        );
53
54
        $expectedStorageFieldDefinition = new StorageFieldDefinition();
55
        $expectedStorageFieldDefinition->dataText5 = <<<EOT
56
<?xml version="1.0" encoding="utf-8"?>
57
<related-objects><constraints><allowed-class contentclass-identifier="article"/><allowed-class contentclass-identifier="blog_post"/></constraints><selection_type value="0"/><contentobject-placement node-id="12345"/></related-objects>
58
59
EOT;
60
        // For BC these are still set
61
        $expectedStorageFieldDefinition->dataInt1 = 0;
62
        $expectedStorageFieldDefinition->dataInt2 = 12345;
63
64
        $actualStorageFieldDefinition = new StorageFieldDefinition();
65
66
        $this->converter->toStorageFieldDefinition($fieldDefinition, $actualStorageFieldDefinition);
67
68
        $this->assertEquals(
69
            $expectedStorageFieldDefinition,
70
            $actualStorageFieldDefinition
71
        );
72
    }
73
}
74

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

@@ 144-178 (lines=35) @@
141
     * @group selection
142
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\SelectionConverter::toStorageFieldDefinition
143
     */
144
    public function testToStorageFieldDefinitionMultiple()
145
    {
146
        $fieldDefinition = new PersistenceFieldDefinition(
147
            array(
148
                'fieldTypeConstraints' => new FieldTypeConstraints(
149
                    array(
150
                        'fieldSettings' => new FieldSettings(
151
                            array(
152
                                'isMultiple' => true,
153
                                'options' => array(
154
                                    0 => 'First',
155
                                    1 => 'Second',
156
                                    2 => 'Third',
157
                                ),
158
                            )
159
                        ),
160
                    )
161
                ),
162
            )
163
        );
164
165
        $expectedStorageFieldDefinition = new StorageFieldDefinition();
166
        $expectedStorageFieldDefinition->dataInt1 = 1;
167
        $expectedStorageFieldDefinition->dataText5 = <<<EOT
168
<?xml version="1.0" encoding="utf-8"?>
169
<ezselection><options><option id="0" name="First"/><option id="1" name="Second"/><option id="2" name="Third"/></options></ezselection>
170
171
EOT;
172
173
        $actualStorageFieldDefinition = new StorageFieldDefinition();
174
175
        $this->converter->toStorageFieldDefinition($fieldDefinition, $actualStorageFieldDefinition);
176
177
        $this->assertEquals($expectedStorageFieldDefinition, $actualStorageFieldDefinition);
178
    }
179
180
    /**
181
     * @group fieldType