3 * Test class for SpecialPreferences class.
5 * Copyright © 2013, Antoine Musso
6 * Copyright © 2013, Wikimedia Foundation Inc.
12 * @covers SpecialPreferences
14 class SpecialPreferencesTest
extends MediaWikiTestCase
{
17 * Make sure a nickname which is longer than $wgMaxSigChars
18 * is not throwing a fatal error.
20 * Test specifications by Alexandre "ialex" Emsenhuber.
21 * @todo give this test a real name explaining what is being tested here
23 public function testBug41337() {
26 $this->setMwGlobals( 'wgMaxSigChars', 2 );
28 $user = $this->getMock( 'User' );
29 $user->expects( $this->any() )
31 ->will( $this->returnValue( false ) );
33 # Yeah foreach requires an array, not NULL =(
34 $user->expects( $this->any() )
35 ->method( 'getEffectiveGroups' )
36 ->will( $this->returnValue( [] ) );
38 # The mocked user has a long nickname
39 $user->expects( $this->any() )
40 ->method( 'getOption' )
41 ->will( $this->returnValueMap( [
42 [ 'nickname', null, false, 'superlongnickname' ],
46 # Forge a request to call the special page
47 $context = new RequestContext();
48 $context->setRequest( new FauxRequest() );
49 $context->setUser( $user );
50 $context->setTitle( Title
::newFromText( 'Test' ) );
52 # Do the call, should not spurt a fatal error.
53 $special = new SpecialPreferences();
54 $special->setContext( $context );
55 $this->assertNull( $special->execute( [] ) );