private function addTestChanges()
 {
     $changeStore = new SqlChangeStore(wfGetLB());
     $change = new EntityChange($this->getChangeRowData('20150101000005'));
     $changeStore->saveChange($change);
     $change = new EntityChange($this->getChangeRowData('20150101000300'));
     $changeStore->saveChange($change);
 }
 public function testLoadByRevisionId()
 {
     if (!defined('WB_VERSION')) {
         $this->markTestSkipped("Skipping because WikibaseClient doesn't have a local wb_changes table.");
     }
     list($expected) = $this->getEntityChanges();
     $expected->setField('revision_id', 342342);
     $expected->setField('id', null);
     // Null the id as we save the same changes multiple times
     $changeStore = new SqlChangeStore(wfGetLB());
     $changeStore->saveChange($expected);
     $lookup = new ChangeLookup(array('wikibase-item~remove' => 'Wikibase\\EntityChange'), wfWikiID());
     $change = $lookup->loadByRevisionId(342342);
     $this->assertChangesEqual(array($expected), array($change));
 }
 public function testSaveChange_update()
 {
     $db = wfGetDB(DB_MASTER);
     $db->delete('wb_changes', '*', __METHOD__);
     $this->tablesUsed[] = 'wb_changes';
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $factory = $wikibaseRepo->getEntityChangeFactory();
     $change = $factory->newForEntity(EntityChange::ADD, new ItemId('Q21389475'));
     $change->setField('time', wfTimestampNow());
     $store = new SqlChangeStore(wfGetLB());
     $store->saveChange($change);
     $expected = array('change_id' => (string) $change->getId(), 'change_type' => 'wikibase-item~add', 'change_time' => '20121026200049', 'change_object_id' => 'q21389475', 'change_revision_id' => '0', 'change_user_id' => '0', 'change_info' => '[]');
     $change->setField('time', '20121026200049');
     $store->saveChange($change);
     $res = $db->select('wb_changes', '*', array(), __METHOD__);
     $this->assertEquals(1, $res->numRows(), 'row count');
     $row = (array) $res->current();
     $this->assertEquals($expected, $row);
 }