/**
  * @param string $action
  * @param EntityId $entityId
  * @param Diff $diff
  * @param array $fields
  *
  * @return EntityChange
  */
 private function newEntityChange($action, EntityId $entityId, Diff $diff, array $fields)
 {
     /** @var EntityChange $instance  */
     $instance = new ItemChange($fields);
     if (!$instance->hasField('object_id')) {
         $instance->setField('object_id', $entityId->getSerialization());
     }
     if (!$instance->hasField('info')) {
         $instance->setField('info', array());
     }
     // Note: the change type determines how the client will
     // instantiate and handle the change
     $type = 'wikibase-' . $entityId->getEntityType() . '~' . $action;
     $instance->setField('type', $type);
     $instance->setDiff($diff);
     return $instance;
 }
 /**
  * @dataProvider changeBackwardsCompatProvider
  *
  * @param ItemChange $change
  * @throws Exception
  */
 public function testGetSiteLinkDiffBackwardsCompat(ItemChange $change)
 {
     //NOTE: Disable developer warnings that may get triggered by
     //      the B/C code path.
     $this->setMwGlobals('wgDevelopmentWarnings', false);
     // Also suppress notices that may be triggered by wfLogWarning
     \MediaWiki\suppressWarnings();
     $exception = null;
     try {
         $siteLinkDiff = $change->getSiteLinkDiff();
         $this->assertInstanceOf('Diff\\Diff', $siteLinkDiff, "getSiteLinkDiff must return a Diff");
     } catch (Exception $ex) {
         // PHP 5.3 doesn't have `finally`, so we use a hacky emulation
         $exception = $ex;
     }
     // this is our make-shift `finally` section.
     \MediaWiki\restoreWarnings();
     if ($exception) {
         throw $exception;
     }
 }