Exemplo n.º 1
0
 private function assertItemsCorrect(array $result, array $expectedFrom, array $expectedTo)
 {
     $actualFrom = $this->entityModificationTestHelper->getEntity($result['from']['id'], true);
     //resolve redirects
     $this->entityModificationTestHelper->assertEntityEquals($expectedFrom, $actualFrom);
     $actualTo = $this->entityModificationTestHelper->getEntity($result['to']['id'], true);
     $this->entityModificationTestHelper->assertEntityEquals($expectedTo, $actualTo);
 }
 private function assertRedirectWorks($expectedFrom, $fromId, $toId)
 {
     if (empty($expectedFrom)) {
         try {
             $this->testHelper->getEntity($fromId);
             $this->fail('getEntity( ' . $fromId->getSerialization() . ' ) did not throw an UnresolvedRedirectException');
         } catch (RevisionedUnresolvedRedirectException $ex) {
             $this->assertEquals($toId->getSerialization(), $ex->getRedirectTargetId()->getSerialization());
         }
     } else {
         $actualFrom = $this->testHelper->getEntity($fromId);
         $this->testHelper->assertEntityEquals($expectedFrom, $actualFrom, 'modified source item');
     }
 }
 public function testRedirectRequest()
 {
     $params = array('fromid' => 'Q1', 'toid' => 'Q2');
     $targetItemContent = array('labels' => array('en' => array('language' => 'en', 'value' => 'Item 2')));
     // -- prefill the entities --------------------------------------------
     $this->entityModificationTestHelper->putEntity(array(), 'Q1');
     $this->entityModificationTestHelper->putEntity($targetItemContent, 'Q2');
     // -- do the request --------------------------------------------
     $html = $this->executeSpecialEntityRedirect($params);
     $this->assertNoError($html);
     $this->assertContains('(wikibase-redirectentity-success: Q1, Q2)', $html, 'Expected success message');
     // -- check the items --------------------------------------------
     $actualFrom = $this->entityModificationTestHelper->getEntity('Q1', true);
     $this->entityModificationTestHelper->assertEntityEquals($targetItemContent, $actualFrom);
     $actualTo = $this->entityModificationTestHelper->getEntity('Q2');
     $this->entityModificationTestHelper->assertEntityEquals($targetItemContent, $actualTo);
 }
 /**
  * @dataProvider mergeRequestProvider
  */
 public function testMergeRequest($fromBefore, $toBefore, $fromAfter, $toAfter, $ignoreConflicts = '')
 {
     // -- set up params ---------------------------------
     $params = array('fromid' => 'Q1', 'toid' => 'Q2', 'summary' => 'CustomSummary!', 'ignoreconflicts' => $ignoreConflicts);
     // -- prefill the entities --------------------------------------------
     $this->entityModificationTestHelper->putEntity($fromBefore, 'Q1');
     $this->entityModificationTestHelper->putEntity($toBefore, 'Q2');
     // -- do the request --------------------------------------------
     $html = $this->executeSpecialMergeItems($params);
     // -- check the result --------------------------------------------
     $this->assertNoError($html);
     $this->assertRegExp('!\\(wikibase-mergeitems-success: Q1, \\d+, Q2, \\d+\\)!', $html, 'Expected success message');
     // -- check the items --------------------------------------------
     $actualFrom = $this->entityModificationTestHelper->getEntity('Q1', true);
     $this->entityModificationTestHelper->assertEntityEquals($fromAfter, $actualFrom);
     $actualTo = $this->entityModificationTestHelper->getEntity('Q2', true);
     $this->entityModificationTestHelper->assertEntityEquals($toAfter, $actualTo);
 }