Fixed spacing and removed unneeded parenthesis
[lhc/web/wiklou.git] / tests / phpunit / includes / specials / SpecialPreferencesTest.php
1 <?php
2 /**
3 * Test class for SpecialPreferences class.
4 *
5 * Copyright © 2013, Antoine Musso
6 * Copyright © 2013, Wikimedia Foundation Inc.
7 *
8 */
9
10 class SpecialPreferencesTest extends MediaWikiTestCase {
11
12 /**
13 * Make sure a nickname which is longer than $wgMaxSigChars
14 * is not throwing a fatal error.
15 *
16 * Test specifications by Alexandre "ialex" Emsenhuber.
17 */
18 function testBug41337() {
19
20 // Set a low limit
21 $this->setMwGlobals( 'wgMaxSigChars', 2 );
22
23 $user = $this->getMock( 'User' );
24 $user->expects( $this->any() )
25 ->method( 'isAnon' )
26 ->will( $this->returnValue( false ) );
27
28 # Yeah foreach requires an array, not NULL =(
29 $user->expects( $this->any() )
30 ->method( 'getEffectiveGroups' )
31 ->will( $this->returnValue( array() ) );
32
33 # The mocked user has a long nickname
34 $user->expects( $this->any() )
35 ->method( 'getOption' )
36 ->will( $this->returnValueMap( array(
37 array( 'nickname', null, false, 'superlongnickname' ),
38 )
39 ) );
40
41 # Validate the mock (FIXME should probably be removed)
42 $this->assertFalse( $user->isAnon() );
43 $this->assertEquals( array(),
44 $user->getEffectiveGroups() );
45 $this->assertEquals( 'superlongnickname',
46 $user->getOption( 'nickname' ) );
47
48 # Forge a request to call the special page
49 $context = new RequestContext();
50 $context->setRequest( new FauxRequest() );
51 $context->setUser( $user );
52 $context->setTitle( Title::newFromText( 'Test' ) );
53
54 # Do the call, should not spurt a fatal error.
55 $special = new SpecialPreferences();
56 $special->setContext( $context );
57 $special->execute( array() );
58 }
59
60 }