r101341 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101340‎ | r101341 | r101342 >
Date:09:02, 31 October 2011
Author:hashar
Status:deferred
Tags:
Comment:
Run test with an anonymous user

(reapplying r100343)
One can visit [[Special:JavaScriptTest/qunit]] as a logged in user thus
tests for anonymous user failed.
Modified paths:
  • /branches/JSTesting/tests/qunit/suites/resources/mediawiki/mediawiki.user.test.js (modified) (history)

Diff [purge]

Index: branches/JSTesting/tests/qunit/suites/resources/mediawiki/mediawiki.user.test.js
@@ -16,6 +16,19 @@
1717 test( 'User login status', function() {
1818 expect(5);
1919
 20+ /**
 21+ * Tests can be run under three different conditions:
 22+ * 1) From tests/qunit/index.html, user will be anonymous.
 23+ * 2) Logged in on [[Special:JavaScriptTest/qunit]]
 24+ * 3) Anonymously at the same special page.
 25+ */
 26+
 27+ // remember current user to restore it later on.
 28+ var savedUsername = mw.config.get( 'wgUserName' );
 29+
 30+ // Forge an anonymous user:
 31+ mw.config.set( 'wgUserName', null);
 32+
2033 strictEqual( mw.user.name(), null, 'user.name should return null when anonymous' );
2134 ok( mw.user.anonymous(), 'user.anonymous should reutrn true when anonymous' );
2235
@@ -26,4 +39,7 @@
2740 ok( !mw.user.anonymous(), 'user.anonymous returns false when logged-in' );
2841
2942 equal( mw.user.id(), 'John', 'user.id Returns username when logged-in' );
 43+
 44+ // restore previous user
 45+ mw.config.set( 'wgUserName', savedUsername );
3046 });

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100343test against an anonymous user!...hashar13:44, 20 October 2011

Status & tagging log