toStorageFieldDefinition() public method

Converts field definition data in $fieldDef into $storageFieldDef.
public toStorageFieldDefinition ( eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDef, StorageFieldDefinition $storageDef )
$fieldDef eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition
$storageDef eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition
Esempio n. 1
0
    /**
     * @group fieldType
     * @group selection
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\SelectionConverter::toStorageFieldDefinition
     */
    public function testToStorageFieldDefinitionSingle()
    {
        $fieldDefinition = new PersistenceFieldDefinition(array('fieldTypeConstraints' => new FieldTypeConstraints(array('fieldSettings' => new FieldSettings(array('isMultiple' => false, 'options' => array(0 => 'First')))))));
        $expectedStorageFieldDefinition = new StorageFieldDefinition();
        $expectedStorageFieldDefinition->dataInt1 = 0;
        $expectedStorageFieldDefinition->dataText5 = <<<EOT
<?xml version="1.0" encoding="utf-8"?>
<ezselection><options><option id="0" name="First"/></options></ezselection>

EOT;
        $actualStorageFieldDefinition = new StorageFieldDefinition();
        $this->converter->toStorageFieldDefinition($fieldDefinition, $actualStorageFieldDefinition);
        $this->assertEquals($expectedStorageFieldDefinition, $actualStorageFieldDefinition);
    }