コード例 #1
0
 /**
  * @dataProvider provideExceptionConflictsData
  */
 public function testMergeItemsConflictsExceptions($pre1, $pre2)
 {
     // -- prefill the entities --------------------------------------------
     $this->entityModificationTestHelper->putEntity($pre1, 'Q1');
     $this->entityModificationTestHelper->putEntity($pre2, 'Q2');
     $params = array('fromid' => 'Q1', 'toid' => 'Q2');
     // -- do the request --------------------------------------------
     $html = $this->executeSpecialMergeItems($params);
     $this->assertError('Wikibase\\Repo\\Interactors\\ItemMergeException:wikibase-itemmerge-failed-modify', $html);
 }
 /**
  * @dataProvider mergeConflictsProvider
  */
 public function testMergeItems_conflict($fromData, $toData, $ignoreConflicts)
 {
     $fromId = new ItemId('Q1');
     $toId = new ItemId('Q2');
     $this->testHelper->putEntity($fromData, $fromId);
     $this->testHelper->putEntity($toData, $toId);
     try {
         $interactor = $this->newInteractor();
         $interactor->mergeItems($fromId, $toId, $ignoreConflicts);
         $this->fail('ItemMergeException expected');
     } catch (ItemMergeException $ex) {
         $this->assertEquals('failed-modify', $ex->getErrorCode());
     }
 }
コード例 #3
0
 /**
  * @dataProvider provideExceptionConflictsData
  */
 public function testMergeItemsConflictsExceptions($pre1, $pre2)
 {
     $expected = array('exception' => array('type' => 'UsageException', 'code' => 'failed-save'));
     // -- prefill the entities --------------------------------------------
     $this->entityModificationTestHelper->putEntity($pre1, 'Q1');
     $this->entityModificationTestHelper->putEntity($pre2, 'Q2');
     $params = array('action' => 'wbmergeitems', 'fromid' => 'Q1', 'toid' => 'Q2');
     // -- do the request --------------------------------------------
     try {
         $this->callApiModule($params);
         $this->fail('Expected UsageException!');
     } catch (UsageException $ex) {
         $this->apiModuleTestHelper->assertUsageException($expected, $ex);
     }
 }
 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);
 }