jenkins-bot has submitted this change and it was merged.

Change subject: Destroy session after running api tests
......................................................................


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
---
M tests/phpunit/includes/api/ApiTestCase.php
1 file changed, 11 insertions(+), 0 deletions(-)

Approvals:
  Bartosz Dziewoński: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/includes/api/ApiTestCase.php 
b/tests/phpunit/includes/api/ApiTestCase.php
index 9a552fa..8c27b10 100644
--- a/tests/phpunit/includes/api/ApiTestCase.php
+++ b/tests/phpunit/includes/api/ApiTestCase.php
@@ -46,6 +46,17 @@
                $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

-- 
To view, visit https://gerrit.wikimedia.org/r/178601
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Icf5cb4d4a2c24c96698cac5bf32147c0c9149ef3
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to