public function testGivenEntityDiffOpArray_entityDiffOpisReturned()
 {
     $factory = new EntityTypeAwareDiffOpFactory();
     $diffOp = new ItemDiff(array());
     $newDiffOp = $factory->newFromArray($diffOp->toArray());
     $this->assertEquals($diffOp, $newDiffOp);
 }
Exemplo n.º 2
0
 /**
  * Checks that ItemDiff can handle atomic diffs for substructures.
  * This is needed for backwards compatibility with old versions of
  * MapDiffer: As of commit ff65735a125e, MapDiffer may generate atomic
  * diffs for substructures even in recursive mode (bug 51363).
  */
 public function testAtomicSubstructureWorkaround()
 {
     $oldErrorLevel = error_reporting(E_USER_ERROR);
     $atomicListDiff = new DiffOpChange(array('a' => 'A', 'b' => 'B'), array('b' => 'B', 'a' => 'A'));
     $diff = new ItemDiff(array('aliases' => $atomicListDiff, 'label' => $atomicListDiff, 'description' => $atomicListDiff, 'claim' => $atomicListDiff, 'links' => $atomicListDiff));
     $this->assertInstanceOf('Diff\\DiffOp\\Diff\\Diff', $diff->getAliasesDiff());
     $this->assertInstanceOf('Diff\\DiffOp\\Diff\\Diff', $diff->getLabelsDiff());
     $this->assertInstanceOf('Diff\\DiffOp\\Diff\\Diff', $diff->getDescriptionsDiff());
     $this->assertInstanceOf('Diff\\DiffOp\\Diff\\Diff', $diff->getClaimsDiff());
     $this->assertInstanceOf('Diff\\DiffOp\\Diff\\Diff', $diff->getSiteLinkDiff());
     error_reporting($oldErrorLevel);
 }
 public function changeBackwardsCompatProvider()
 {
     global $wgDevelopmentWarnings;
     //NOTE: Disable developer warnings that may get triggered by
     //      the B/C code path.
     $wgDevelopmentWarnings = false;
     \MediaWiki\suppressWarnings();
     try {
         $cases = array();
         // --------
         // We may hit a plain diff generated by old code.
         // Make sure we can deal with that.
         $diff = new Diff();
         $change = new ItemChange(array('type' => 'test'));
         $change->setDiff($diff);
         $cases['plain-diff'] = array($change);
         // --------
         // Bug T53363: As of commit ff65735a125e, MapDiffer may generate atomic diffs for
         // substructures even in recursive mode. Make sure we can handle them
         // if we happen to load them from the database or such.
         $diff = new ItemDiff(array('links' => new DiffOpChange(array('foowiki' => 'X', 'barwiki' => 'Y'), array('barwiki' => 'Y', 'foowiki' => 'X'))));
         // make sure we got the right key for sitelinks
         assert($diff->getSiteLinkDiff() !== null);
         //NOTE: ItemChange's constructor may or may not already fix the bad diff.
         $change = new ItemChange(array('type' => 'test'));
         $change->setDiff($diff);
         $cases['atomic-sitelink-diff'] = array($change);
         $wgDevelopmentWarnings = true;
         \MediaWiki\restoreWarnings();
         return $cases;
     } catch (Exception $ex) {
         $wgDevelopmentWarnings = true;
         \MediaWiki\restoreWarnings();
         throw $ex;
     }
 }