public function prepareUpdateChangeSet(ChangeSet $changeSet)
 {
     $changes = array();
     foreach ($changeSet->getChanges() as $change) {
         $changes[$change->getPropertyName()] = $change->getNewValue();
     }
     return $changes;
 }
 /**
  * Sets the new value of this field.
  *
  * @param string $field
  * @param mixed  $value
  */
 public function setNewValue($field, $value)
 {
     if ($change = $this->objectChangeSet->getFieldChange($field)) {
         $change->setNewValue($value);
     } else {
         $this->objectChangeSet->addChange(new Change($field, null, $value));
     }
 }
 public function testChangeSet()
 {
     $object = new \stdClass();
     $changeSet = new ChangeSet($object);
     $this->assertSame($object, $changeSet->getObject());
     $this->assertFalse($changeSet->hasChangedField('username'));
     $change = new Change('username', 'jwage', 'jonwage');
     $changeSet->addChange($change);
     $this->assertTrue($changeSet->hasChangedField('username'));
     $this->assertSame($change, $changeSet->getFieldChange('username'));
     $this->assertEquals('username', $change->getPropertyName());
     $this->assertEquals('jwage', $change->getOldValue());
     $this->assertEquals('jonwage', $change->getNewValue());
     $change->setNewValue('jon');
     $this->assertEquals('jon', $change->getNewValue());
 }