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 testIsStub_nonStubItem()
 {
     $item = new Item();
     $item->getStatements()->addNewStatement(new PropertyNoValueSnak(42));
     $content = ItemContent::newFromItem($item);
     $this->assertFalse($content->isStub());
 }
 /**
  * @param ItemId $id
  *
  * @return EntityContent
  */
 private function makeItemContent(ItemId $id)
 {
     $item = new Item($id);
     $content = ItemContent::newFromItem($item);
     return $content;
 }
 public function testSetRevisionInfo()
 {
     if (!defined('WB_VERSION')) {
         $this->markTestSkipped('Need to be able to create entity content in order to test with Revision objects.');
     }
     $id = new ItemId('Q7');
     $item = new Item($id);
     $entityChange = $this->newEntityChange($id);
     $timestamp = '20140523' . '174422';
     $revision = new Revision(array('id' => 5, 'page' => 6, 'user' => 7, 'parent_id' => 3, 'user_text' => 'Mr. Kittens', 'timestamp' => $timestamp, 'content' => ItemContent::newFromItem($item), 'comment' => 'Test!'));
     $entityChange->setRevisionInfo($revision);
     $this->assertEquals(5, $entityChange->getField('revision_id'), 'revision_id');
     $this->assertEquals(7, $entityChange->getField('user_id'), 'user_id');
     $this->assertEquals('q7', $entityChange->getObjectId(), 'object_id');
     $this->assertEquals($timestamp, $entityChange->getTime(), 'timestamp');
     $this->assertEquals('Test!', $entityChange->getComment(), 'comment');
     $metadata = $entityChange->getMetadata();
     $this->assertEquals(3, $metadata['parent_id'], 'parent_id');
     $this->assertEquals(6, $metadata['page_id'], 'page_id');
     $this->assertEquals(5, $metadata['rev_id'], 'rev_id');
     $this->assertEquals('Mr. Kittens', $metadata['user_text'], 'user_text');
 }