Example #1
0
 /**
  * @depends testConstructWithFieldsArgument
  */
 public function testSetFieldValue()
 {
     $fieldsValues = new FieldsValues(['field1', 'field2' => 'value2', 'field3']);
     // Change value
     $fieldsValues->fieldValue('field2', '2value');
     $this->assertEquals(['field2' => '2value'], $fieldsValues->getFieldsValues());
     // Set value, when field was empty
     $fieldsValues->fieldValue('field3', 'value3');
     $this->assertEquals(['field2' => '2value', 'field3' => 'value3'], $fieldsValues->getFieldsValues());
     // Add new field
     $fieldsValues->fieldValue('field4', 'value4');
     $this->assertEquals(['field2' => '2value', 'field3' => 'value3', 'field4' => 'value4'], $fieldsValues->getFieldsValues());
 }
Example #2
0
 /**
  * Constructor
  *
  * @param FieldsValues $fieldsValues
  */
 public function __construct(FieldsValues $fieldsValues = null)
 {
     if (!$fieldsValues) {
         $fieldsValues = new FieldsValues();
     }
     $this->supports = $fieldsValues->getSupportedFields();
     $this->fields = $fieldsValues->getFieldsValues();
 }