private static function applyDefaults(EntityChange $change, array $defaults)
 {
     foreach ($defaults as $name => $value) {
         if (!$change->hasField($name)) {
             $change->setField($name, $value);
         }
     }
 }
 public function testGivenEntityChangeWithoutObjectId_setRevisionInfoSetsObjectId()
 {
     $content = $this->getMockBuilder('Wikibase\\ItemContent')->disableOriginalConstructor()->getMock();
     $content->expects($this->once())->method('getEntityId')->will($this->returnValue(new ItemId('Q1')));
     $revision = $this->getMockBuilder('Revision')->disableOriginalConstructor()->getMock();
     $revision->expects($this->once())->method('getContent')->will($this->returnValue($content));
     $change = new EntityChange(array('info' => array(), 'type' => '~'));
     $this->assertFalse($change->hasField('object_id'), 'precondition');
     $change->setRevisionInfo($revision);
     $this->assertSame('q1', $change->getObjectId());
 }