SpecialPagesTest.php

Go to the documentation of this file.
00001 <?php
00016 class SpecialPagesTest extends MediaWikiTestCase {
00017     protected function setUp() {
00018         parent::setUp();
00019 
00020         $this->setMwGlobals( array(
00021             'wgTranslateCacheDirectory' => $this->getNewTempDirectory(),
00022             'wgTranslateMessageIndex' => array( 'DatabaseMessageIndex' ),
00023             'wgDeprecationReleaseLimit' => 1.19,
00024             'wgTranslateTranslationServices' => array(),
00025         ) );
00026     }
00027 
00028     public static function provideSpecialPages() {
00029         require __DIR__ . '/../../_autoload.php';
00030         global $wgSpecialPages;
00031 
00032         $pages = array();
00033         foreach ( $wgSpecialPages as $name => $class ) {
00034             if ( isset( $wgAutoloadClasses[$class] ) ) {
00035                 $pages[] = array( $name );
00036             }
00037         }
00038 
00039         return $pages;
00040     }
00041 
00045     public function testSpecialPage( $name ) {
00046         $page = SpecialPageFactory::getPage( $name );
00047         $title = $page->getTitle();
00048 
00049         $context = RequestContext::newExtraneousContext( $title );
00050         $page->setContext( $context );
00051 
00052         try {
00053             $page->run( null );
00054         } catch ( PermissionsError $e ) {
00055             // This is okay
00056             wfDebug( 'Permissions error caught; expected.' );
00057         } catch ( ErrorPageError $e ) {
00058             // This is okay as well
00059             wfDebug( 'Page error caught; expected.' );
00060         }
00061 
00062         $this->assertTrue( true, "Special page $name was executed succesfully with anon user" );
00063 
00064         $user = new MockSuperUser();
00065         $context->setUser( $user );
00066         $page->setContext( $context );
00067 
00068         // This should not throw permission errors
00069         try {
00070             $page->run( null );
00071         } catch ( ErrorPageError $e ) {
00072             // This is okay here
00073             wfDebug( 'Page error caught; expected.' );
00074         }
00075 
00076         $this->assertTrue( true, "Special page $name was executed succesfully with super user" );
00077     }
00078 }
Generated on Tue Oct 29 00:00:24 2013 for MediaWiki Translate Extension by  doxygen 1.6.3