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

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