Ejemplo n.º 1
0
 /**
  * @dataProvider diffProvider
  */
 public function testGetClaimsDiff(EntityDiff $entityDiff)
 {
     $diff = $entityDiff->getClaimsDiff();
     $this->assertInstanceOf('Diff\\Diff', $diff);
     $this->assertTrue($diff->isAssociative());
     foreach ($diff as $diffOp) {
         $this->assertTrue($diffOp instanceof DiffOpAdd || $diffOp instanceof DiffOpRemove);
         $statement = $diffOp instanceof DiffOpAdd ? $diffOp->getNewValue() : $diffOp->getOldValue();
         $this->assertInstanceOf('Wikibase\\DataModel\\Statement\\Statement', $statement);
     }
 }
 /**
  * Generates and returns an HTML visualization of the provided EntityDiff.
  *
  * @since 0.4
  *
  * @param EntityDiff $diff
  *
  * @return string
  */
 protected function visualizeEntityDiff(EntityDiff $diff)
 {
     if ($diff->isEmpty()) {
         return '';
     }
     $html = '';
     $termDiffVisualizer = new DiffView(array(), new Diff(array($this->context->getLanguage()->getMessage('wikibase-diffview-label') => $diff->getLabelsDiff(), $this->context->getLanguage()->getMessage('wikibase-diffview-alias') => $diff->getAliasesDiff(), $this->context->getLanguage()->getMessage('wikibase-diffview-description') => $diff->getDescriptionsDiff()), true), $this->siteStore, $this->entityIdFormatter, $this->context);
     $html .= $termDiffVisualizer->getHtml();
     foreach ($diff->getClaimsDiff() as $claimDiffOp) {
         $html .= $this->getClaimDiffHtml($claimDiffOp);
     }
     // FIXME: this does not belong here as it is specific to items
     if ($diff instanceof ItemDiff) {
         $linkDiffVisualizer = new DiffView(array(), new Diff(array($this->context->getLanguage()->getMessage('wikibase-diffview-link') => $diff->getSiteLinkDiff()), true), $this->siteStore, $this->entityIdFormatter, $this->context);
         $html .= $linkDiffVisualizer->getHtml();
     }
     return $html;
 }