Merge "DatabaseMssql: Don't duplicate body of makeList()"
[mediawiki.git] / tests / phpunit / includes / specials / SpecialPreferencesTest.php
blob4f6c4116aa3fbbaa716cd0b8ea694a975edf6cbe
1 <?php
2 /**
3 * Test class for SpecialPreferences class.
5 * Copyright © 2013, Antoine Musso
6 * Copyright © 2013, Wikimedia Foundation Inc.
8 */
10 /**
11 * @covers SpecialPreferences
13 class SpecialPreferencesTest extends MediaWikiTestCase {
15 /**
16 * Make sure a nickname which is longer than $wgMaxSigChars
17 * is not throwing a fatal error.
19 * Test specifications by Alexandre "ialex" Emsenhuber.
20 * @todo give this test a real name explaining what is being tested here
22 public function testBug41337() {
24 // Set a low limit
25 $this->setMwGlobals( 'wgMaxSigChars', 2 );
27 $user = $this->getMock( 'User' );
28 $user->expects( $this->any() )
29 ->method( 'isAnon' )
30 ->will( $this->returnValue( false ) );
32 # Yeah foreach requires an array, not NULL =(
33 $user->expects( $this->any() )
34 ->method( 'getEffectiveGroups' )
35 ->will( $this->returnValue( array() ) );
37 # The mocked user has a long nickname
38 $user->expects( $this->any() )
39 ->method( 'getOption' )
40 ->will( $this->returnValueMap( array(
41 array( 'nickname', null, false, 'superlongnickname' ),
43 ) );
45 # Forge a request to call the special page
46 $context = new RequestContext();
47 $context->setRequest( new FauxRequest() );
48 $context->setUser( $user );
49 $context->setTitle( Title::newFromText( 'Test' ) );
51 # Do the call, should not spurt a fatal error.
52 $special = new SpecialPreferences();
53 $special->setContext( $context );
54 $this->assertNull( $special->execute( array() ) );