3 * Test class for SpecialPreferences class.
5 * Copyright © 2013, Antoine Musso
6 * Copyright © 2013, Wikimedia Foundation Inc.
11 * @covers SpecialPreferences
13 class SpecialPreferencesTest
extends MediaWikiTestCase
{
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() {
25 $this->setMwGlobals( 'wgMaxSigChars', 2 );
27 $user = $this->getMock( 'User' );
28 $user->expects( $this->any() )
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' ),
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() ) );