From b43624d3e0a96fe804e07679155d4f7f54f46459 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Wed, 13 Aug 2014 19:47:57 +0200 Subject: [PATCH] ApiTestCase: Avoid notices about undefined indices We're going to throw an exception right away here, but this is still problematic because of PHPUnit: "By default, PHPUnit converts PHP errors, warnings, and notices that are triggered during the execution of a test to an exception." http://phpunit.de/manual/4.2/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.errors Also change the exception message to something saner. Change-Id: I766c36076d34428035be78bbb3cf36cc572b565b --- tests/phpunit/includes/api/ApiTestCase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/includes/api/ApiTestCase.php b/tests/phpunit/includes/api/ApiTestCase.php index b556ef80f2..f6333150ad 100644 --- a/tests/phpunit/includes/api/ApiTestCase.php +++ b/tests/phpunit/includes/api/ApiTestCase.php @@ -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" ); } } -- 2.20.1