doLogin( 'uploader' ); $result = $this->editPage( __CLASS__ . rand( 0, 100 ), __CLASS__ . rand( 0, 100 ) ); /** @var Status $result */ $result = $result->getValue(); /** @var Revision $revision */ $revision = $result['revision']; $this->revId = $revision->getId(); $this->doLogin( 'sysop' ); DeferredUpdates::clearPendingUpdates(); } public function testRequestWithoutToken() { if ( class_exists( 'ApiUsageException' ) ) { $this->setExpectedException( 'ApiUsageException', 'The "token" parameter must be set.' ); } else { $this->setExpectedException( 'UsageException', 'The token parameter must be set' ); } $this->doApiRequest( [ 'action' => 'thank', 'source' => 'someSource', 'rev' => 1, ] ); } public function testValidRequest() { list( $result,, ) = $this->doApiRequestWithToken( [ 'action' => 'thank', 'rev' => $this->revId, ] ); $this->assertSuccess( $result ); } public function testValidRequestWithSource() { list( $result,, ) = $this->doApiRequestWithToken( [ 'action' => 'thank', 'source' => 'someSource', 'rev' => $this->revId, ] ); $this->assertSuccess( $result ); } protected function assertSuccess( $result ) { $this->assertEquals( [ 'result' => [ 'success' => 1, 'recipient' => self::$users['uploader']->getUser()->getName(), ], ], $result ); } public function testInvalidRequest() { $this->setExpectedException( 'UsageException' ); $this->doApiRequestWithToken( [ 'action' => 'thank' ] ); } }