TranslateHooksTest.php

Go to the documentation of this file.
00001 <?php
00015 class TranslateHooksTest extends MediaWikiLangTestCase {
00016     protected function setUp() {
00017         parent::setUp();
00018 
00019         global $wgHooks;
00020         $this->setMwGlobals( array(
00021             'wgHooks' => $wgHooks,
00022             'wgTranslateCC' => array(),
00023             'wgTranslateMessageIndex' => array( 'DatabaseMessageIndex' ),
00024             'wgTranslateWorkflowStates' => false,
00025             'wgEnablePageTranslation' => false,
00026             'wgTranslateGroupFiles' => array(),
00027             'wgTranslateDocumentationLanguageCode' => 'qqq',
00028             'wgTranslateTranslationServices' => array(),
00029         ) );
00030         $wgHooks['TranslatePostInitGroups'] = array( array( $this, 'getTestGroups' ) );
00031         MessageGroups::clearCache();
00032         MessageIndexRebuildJob::newJob()->run();
00033     }
00034 
00035     public function getTestGroups( &$list ) {
00036         $messages = array(
00037             'ugakey1' => 'value1',
00038             'ugakey2' => 'value2',
00039         );
00040 
00041         $list['testgroup'] = new MockWikiMessageGroup( 'testgroup', $messages );
00042 
00043         return false;
00044     }
00045 
00046     public function testPreventCategorization() {
00047         $user = new MockSuperUser();
00048         $title = Title::makeTitle( NS_MEDIAWIKI, 'ugakey1/fi' );
00049         $wikipage = WikiPage::factory( $title );
00050         $wikipage->doEdit( '[[Category:Shouldnotbe]]', __METHOD__, 0, false, $user );
00051         $this->assertEquals(
00052             array(),
00053             $title->getParentCategories(),
00054             'translation of known message'
00055         );
00056 
00057         $title = Title::makeTitle( NS_MEDIAWIKI, 'ugakey2/qqq' );
00058         $wikipage = WikiPage::factory( $title );
00059         $wikipage->doEdit( '[[Category:Shouldbe]]', __METHOD__, 0, false, $user );
00060         $this->assertEquals(
00061             array( 'Category:Shouldbe' => 'MediaWiki:ugakey2/qqq' ),
00062             $title->getParentCategories(),
00063             'message docs'
00064         );
00065 
00066         $title = Title::makeTitle( NS_MEDIAWIKI, 'ugakey3/no' );
00067         $wikipage = WikiPage::factory( $title );
00068         $wikipage->doEdit( '[[Category:Shouldbealso]]', __METHOD__, 0, false, $user );
00069         $this->assertEquals( array(), $title->getParentCategories(), 'unknown message' );
00070     }
00071 }
Generated on Tue Oct 29 00:00:24 2013 for MediaWiki Translate Extension by  doxygen 1.6.3