test: coverage recording now needs to be explicit
[mediawiki.git] / tests / phpunit / includes / specials / SpecialPreferencesTest.php
blobc7a48282ecdfa974a7b971e63341227a4f8de443
1 <?php
2 /**
3 * Test class for SpecialPreferences class.
5 * Copyright © 2013, Antoine Musso
6 * Copyright © 2013, Wikimedia Foundation Inc.
8 */
10 class SpecialPreferencesTest extends MediaWikiTestCase {
12 /**
13 * Make sure a nickname which is longer than $wgMaxSigChars
14 * is not throwing a fatal error.
16 * Test specifications by Alexandre "ialex" Emsenhuber.
18 function testBug41337() {
20 // Set a low limit
21 $this->setMwGlobals( 'wgMaxSigChars', 2 );
23 $user = $this->getMock( 'User' );
24 $user->expects( $this->any() )
25 ->method( 'isAnon' )
26 ->will( $this->returnValue( false ) );
28 # Yeah foreach requires an array, not NULL =(
29 $user->expects( $this->any() )
30 ->method( 'getEffectiveGroups' )
31 ->will( $this->returnValue( array() ) );
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' ),
39 ) );
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' ) );
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' ) );
54 # Do the call, should not spurt a fatal error.
55 $special = new SpecialPreferences();
56 $special->setContext( $context );
57 $special->execute( array() );