/** * @param ItemId $id * @param ItemId $target * * @throws RuntimeException * @return EntityContent */ protected function makeItemRedirectContent(ItemId $id, ItemId $target) { $title = Title::newFromText($target->getSerialization()); $redirect = new EntityRedirect($id, $target); $content = ItemContent::newFromRedirect($redirect, $title); return $content; }
public function itemProvider() { $emptyItem = new Item(new ItemId('Q1')); $item = new Item(new ItemId('Q11')); $item->setDescription('en', 'ohi there'); $item->setLabel('de', 'o_O'); $item->setAliases('nl', array('foo', 'bar')); $item2 = new Item(new ItemId('Q12')); $item2->setLabel('de', 'o_O'); $item2->setLabel('en', 'O_o'); $item2->setAliases('nl', array('daaaah')); $redirect = new EntityRedirect(new ItemId('Q11'), new ItemId('Q21')); $redirect2 = new EntityRedirect(new ItemId('Q11'), new ItemId('Q22')); $insTags = array('has <td>label / de</td>' => array('tag' => 'td', 'content' => 'label / de'), 'has <ins>foo</ins>' => array('tag' => 'ins', 'content' => 'foo'), 'has <td>aliases / nl / 0</td>' => array('tag' => 'td', 'content' => 'aliases / nl / 0'), 'has <ins>bar</ins>' => array('tag' => 'ins', 'content' => 'bar'), 'has <td>description / en</td>' => array('tag' => 'td', 'content' => 'description / en'), 'has <ins>ohi there</ins>' => array('tag' => 'ins', 'content' => 'ohi there')); $delTags = array('has <td>label / de</td>' => array('tag' => 'td', 'content' => 'label / de'), 'has <del>foo</del>' => array('tag' => 'del', 'content' => 'foo'), 'has <td>aliases / nl / 0</td>' => array('tag' => 'td', 'content' => 'aliases / nl / 0'), 'has <del>bar</del>' => array('tag' => 'del', 'content' => 'bar'), 'has <td>description / en</td>' => array('tag' => 'td', 'content' => 'description / en'), 'has <del>ohi there</del>' => array('tag' => 'del', 'content' => 'ohi there')); $changeTags = array('has <td>label / en</td>' => array('tag' => 'td', 'content' => 'label / en'), 'has <ins>O_o</ins>' => array('tag' => 'ins', 'content' => 'O_o'), 'has <td>aliases / nl / 0</td>' => array('tag' => 'td', 'content' => 'aliases / nl / 0'), 'has <ins>daaaah</ins>' => array('tag' => 'ins', 'content' => 'daaaah'), 'has <td>aliases / nl / 1</td>' => array('tag' => 'td', 'content' => 'aliases / nl / 1'), 'has <del>foo</del>' => array('tag' => 'del', 'content' => 'foo'), 'has <td>aliases / nl / 2</td>' => array('tag' => 'td', 'content' => 'aliases / nl / 2'), 'has <del>bar</del>' => array('tag' => 'del', 'content' => 'bar'), 'has <td>description / en</td>' => array('tag' => 'td', 'content' => 'description / en'), 'has <del>ohi there</del>' => array('tag' => 'del', 'content' => 'ohi there')); $fromRedirTags = array('has <td>label / de</td>' => array('tag' => 'td', 'content' => 'label / de'), 'has <ins>foo</ins>' => array('tag' => 'ins', 'content' => 'foo'), 'has <td>redirect</td>' => array('tag' => 'td', 'content' => 'redirect'), 'has <del>Q21</del>' => array('tag' => 'del', 'content' => 'Q21')); $toRedirTags = array('has <td>label / de</td>' => array('tag' => 'td', 'content' => 'label / de'), 'has <del>foo</del>' => array('tag' => 'del', 'content' => 'foo'), 'has <td>redirect</td>' => array('tag' => 'td', 'content' => 'redirect'), 'has <ins>Q21</ins>' => array('tag' => 'ins', 'content' => 'Q21')); $changeRedirTags = array('has <td>redirect</td>' => array('tag' => 'td', 'content' => 'redirect'), 'has <del>Q21</del>' => array('tag' => 'del', 'content' => 'Q21'), 'has <ins>Q22</del>' => array('tag' => 'ins', 'content' => 'Q22')); $empty = ItemContent::newFromItem($emptyItem); $itemContent = ItemContent::newFromItem($item); $itemContent2 = ItemContent::newFromItem($item2); $redirectContent = ItemContent::newFromRedirect($redirect, Title::newFromText($redirect->getEntityId()->getSerialization())); $redirectContent2 = ItemContent::newFromRedirect($redirect2, Title::newFromText($redirect2->getEntityId()->getSerialization())); return array('empty' => array($empty, $empty, array('empty' => '/^$/')), 'same' => array($itemContent, $itemContent, array('empty' => '/^$/')), 'from emtpy' => array($empty, $itemContent, $insTags), 'to empty' => array($itemContent, $empty, $delTags), 'changed' => array($itemContent, $itemContent2, $changeTags), 'to redirect' => array($itemContent, $redirectContent, $toRedirTags), 'from redirect' => array($redirectContent, $itemContent, $fromRedirTags), 'redirect changed' => array($redirectContent, $redirectContent2, $changeRedirTags)); }
public function provideGetEntityPageProperties() { $cases = parent::provideGetEntityPageProperties(); // expect wb-sitelinks => 0 for all inherited cases foreach ($cases as &$case) { $case[1]['wb-sitelinks'] = 0; } $cases['redirect'] = array(ItemContent::newFromRedirect(new EntityRedirect(new ItemId('Q1'), new ItemId('Q2')), $this->getMock('Title')), array()); $cases['claims'] = array($this->getItemContentWithClaim(), array('wb-claims' => 1, 'wb-sitelinks' => 0)); $cases['sitelinks'] = array($this->getItemContentWithSiteLink(), array('wb-claims' => 0, 'wb-sitelinks' => 1, 'wb-status' => ItemContent::STATUS_LINKSTUB)); return $cases; }