MediaWiki  REL1_22
SpecialPreferencesTest.php
Go to the documentation of this file.
00001 <?php
00010 class SpecialPreferencesTest extends MediaWikiTestCase {
00011 
00018     public function testBug41337() {
00019 
00020         // Set a low limit
00021         $this->setMwGlobals( 'wgMaxSigChars', 2 );
00022 
00023         $user = $this->getMock( 'User' );
00024         $user->expects( $this->any() )
00025             ->method( 'isAnon' )
00026             ->will( $this->returnValue( false ) );
00027 
00028         # Yeah foreach requires an array, not NULL =(
00029         $user->expects( $this->any() )
00030             ->method( 'getEffectiveGroups' )
00031             ->will( $this->returnValue( array() ) );
00032 
00033         # The mocked user has a long nickname
00034         $user->expects( $this->any() )
00035             ->method( 'getOption' )
00036             ->will( $this->returnValueMap( array(
00037                 array( 'nickname', null, false, 'superlongnickname' ),
00038             )
00039             ) );
00040 
00041         # Validate the mock (FIXME should probably be removed)
00042         $this->assertFalse( $user->isAnon() );
00043         $this->assertEquals( array(),
00044             $user->getEffectiveGroups() );
00045         $this->assertEquals( 'superlongnickname',
00046             $user->getOption( 'nickname' ) );
00047 
00048         # Forge a request to call the special page
00049         $context = new RequestContext();
00050         $context->setRequest( new FauxRequest() );
00051         $context->setUser( $user );
00052         $context->setTitle( Title::newFromText( 'Test' ) );
00053 
00054         # Do the call, should not spurt a fatal error.
00055         $special = new SpecialPreferences();
00056         $special->setContext( $context );
00057         $special->execute( array() );
00058     }
00059 
00060 }