X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fapi%2FApiTestCase.php;h=f6333150adb586264b1eff84fd4502d371c05754;hb=0c615d9029cb6e0d65c21f1df5a8a54e197b860a;hp=87ad2cdf57e269e3c0e14756515ed43b629d1313;hpb=19a38526f390cfdc6a6061cc055fc7f13167bf03;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/api/ApiTestCase.php b/tests/phpunit/includes/api/ApiTestCase.php index 87ad2cdf57..f6333150ad 100644 --- a/tests/phpunit/includes/api/ApiTestCase.php +++ b/tests/phpunit/includes/api/ApiTestCase.php @@ -43,11 +43,11 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { /** * Edits or creates a page/revision - * @param string $pageName page title - * @param string $text content of the page - * @param string $summary optional summary string for the revision - * @param int $defaultNs optional namespace id - * @return array Array as returned by WikiPage::doEditContent() + * @param string $pageName Page title + * @param string $text Content of the page + * @param string $summary Optional summary string for the revision + * @param int $defaultNs Optional namespace id + * @return Array as returned by WikiPage::doEditContent() */ protected function editPage( $pageName, $text, $summary = '', $defaultNs = NS_MAIN ) { $title = Title::newFromText( $pageName, $defaultNs ); @@ -119,10 +119,10 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { * requesting a "real" edit token. * * @param array $params Key-value API params - * @param array|null $session session array + * @param array|null $session Session array * @param User|null $user A User object for the context - * @return mixed Result of the API call - * @throws Exception in case wsToken is not set in the session + * @return Result of the API call + * @throws Exception In case wsToken is not set in the session */ protected function doApiRequestWithToken( array $params, array $session = null, User $user = null @@ -133,7 +133,7 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { $session = $wgRequest->getSessionArray(); } - if ( $session['wsToken'] ) { + if ( isset( $session['wsToken'] ) && $session['wsToken'] ) { // add edit token to fake session $session['wsEditToken'] = $session['wsToken']; // add token to request parameters @@ -141,7 +141,7 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { return $this->doApiRequest( $params, $session, false, $user ); } else { - throw new Exception( "request data not in right format" ); + throw new Exception( "Session token not available" ); } } @@ -152,8 +152,8 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { $data = $this->doApiRequest( array( 'action' => 'login', - 'lgname' => self::$users[ $user ]->username, - 'lgpassword' => self::$users[ $user ]->password ) ); + 'lgname' => self::$users[$user]->username, + 'lgpassword' => self::$users[$user]->password ) ); $token = $data[0]['login']['token']; @@ -161,8 +161,8 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { array( 'action' => 'login', 'lgtoken' => $token, - 'lgname' => self::$users[ $user ]->username, - 'lgpassword' => self::$users[ $user ]->password, + 'lgname' => self::$users[$user]->username, + 'lgpassword' => self::$users[$user]->password, ), $data[2] );