/** * @dataProvider tokenFailureProvider */ public function testCheckToken_failure($data, $wasPosted, $expected) { $request = new \FauxRequest($data, $wasPosted); $user = $this->getMockUser(); $checker = new TokenCheckInteractor($user); try { $checker->checkRequestToken($request, 'tokentest'); $this->fail('check did not throw a TokenCheckException as expected'); } catch (TokenCheckException $ex) { $this->assertEquals($expected, $ex->getErrorCode()); } }
/** * @param ItemId $fromId * @param ItemId $toId * @param string[] $ignoreConflicts * @param string $summary */ private function mergeItems(ItemId $fromId, ItemId $toId, array $ignoreConflicts, $summary) { $this->tokenCheck->checkRequestToken($this->getRequest(), 'wpEditToken'); /** @var EntityRevision $newRevisionFrom */ /** @var EntityRevision $newRevisionTo */ list($newRevisionFrom, $newRevisionTo, ) = $this->interactor->mergeItems($fromId, $toId, $ignoreConflicts, $summary); //XXX: might be nicer to pass pre-rendered links as parameters $this->getOutput()->addWikiMsg('wikibase-mergeitems-success', $fromId->getSerialization(), $newRevisionFrom->getRevisionId(), $toId->getSerialization(), $newRevisionTo->getRevisionId()); }
/** * @param EntityId $fromId * @param EntityId $toId */ private function redirectEntity(EntityId $fromId, EntityId $toId) { $this->tokenCheck->checkRequestToken($this->getRequest(), 'wpEditToken'); $this->interactor->createRedirect($fromId, $toId, false); $this->getOutput()->addWikiMsg('wikibase-redirectentity-success', $fromId->getSerialization(), $toId->getSerialization()); }