From: umherirrender Date: Tue, 9 Dec 2014 20:35:40 +0000 (+0100) Subject: Destroy session after running api tests X-Git-Tag: 1.31.0-rc.0~12943^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=b52e1fe2f7e578a118a74f85cf20e5906432f662;p=lhc%2Fweb%2Fwiklou.git Destroy session after running api tests ApiLogin and ApiCreateAccount calling wfSetupSession, which leaks a session over the test. The test RequestContextText needs a clear session to work, so the api tests should avoid leaking the session. Doing this in the ApiTestCase because some tests calling ApiLogin over FauxRequest and that also starts a session. Change-Id: Icf5cb4d4a2c24c96698cac5bf32147c0c9149ef3 --- diff --git a/tests/phpunit/includes/api/ApiTestCase.php b/tests/phpunit/includes/api/ApiTestCase.php index 9a552fa99c..8c27b1018a 100644 --- a/tests/phpunit/includes/api/ApiTestCase.php +++ b/tests/phpunit/includes/api/ApiTestCase.php @@ -46,6 +46,17 @@ abstract class ApiTestCase extends MediaWikiLangTestCase { $this->apiContext = new ApiTestContext(); } + protected function tearDown() { + // Avoid leaking session over tests + if ( session_id() != '' ) { + global $wgUser; + $wgUser->logout(); + session_destroy(); + } + + parent::tearDown(); + } + /** * Edits or creates a page/revision * @param string $pageName Page title