BlackListTest.php

Go to the documentation of this file.
00001 <?php
00014 class BlackListTest extends MediaWikiTestCase {
00015 
00019     protected $group;
00020     protected $codes;
00021     protected $groupConfiguration = array(
00022         'BASIC' => array(
00023             'class' => 'FileBasedMessageGroup',
00024             'id' => 'test-id',
00025             'label' => 'Test Label',
00026             'namespace' => 'NS_MEDIAWIKI',
00027             'description' => 'Test description',
00028         ),
00029         'FILES' => array(
00030             'class' => 'TestFFS',
00031         ),
00032     );
00033 
00034     protected function setUp() {
00035         parent::setUp();
00036         $this->group = MessageGroupBase::factory( $this->groupConfiguration );
00037         $this->codes = array_flip( array_keys( TranslateUtils::getLanguageNames( 'en' ) ) );
00038     }
00039 
00040     protected function tearDown() {
00041         unset( $this->group );
00042         parent::tearDown();
00043     }
00044 
00045     public function testNoLanguageConf() {
00046         $translatableLanguages = $this->group->getTranslatableLanguages();
00047         $this->assertNull( $translatableLanguages );
00048     }
00049 
00050     public function testAllBlackList() {
00051         $conf = $this->groupConfiguration;
00052         $conf['LANGUAGES'] = array(
00053             'blacklist' => '*',
00054         );
00055         $group = MessageGroupBase::factory( $conf );
00056         $translatableLanguages = $group->getTranslatableLanguages();
00057         $this->assertEquals( count( $translatableLanguages ), 0 );
00058     }
00059 
00060     public function testAllWhiteList() {
00061         $conf = $this->groupConfiguration;
00062         $conf['LANGUAGES'] = array(
00063             'whitelist' => '*',
00064         );
00065         $group = MessageGroupBase::factory( $conf );
00066         $translatableLanguages = $group->getTranslatableLanguages();
00067         $this->assertNull( $translatableLanguages );
00068     }
00069 
00070     public function testWhiteListOverrideBlackList() {
00071         $conf = $this->groupConfiguration;
00072         $conf['LANGUAGES'] = array(
00073             'whitelist' => array( 'en', 'hi', 'ta' ),
00074             'blacklist' => array( 'ta' ),
00075         );
00076         $group = MessageGroupBase::factory( $conf );
00077         $translatableLanguages = $group->getTranslatableLanguages();
00078         $this->assertTrue( isset( $translatableLanguages['ta'] ) );
00079         $this->assertTrue( isset( $translatableLanguages['hi'] ) );
00080     }
00081 
00082     public function testSomeBlackList() {
00083         $conf = $this->groupConfiguration;
00084         $conf['LANGUAGES'] = array(
00085             'blacklist' => array( 'or', 'hi' ),
00086         );
00087         $group = MessageGroupBase::factory( $conf );
00088         $translatableLanguages = $group->getTranslatableLanguages();
00089         $this->assertTrue( !isset( $translatableLanguages['hi'] ) );
00090         $this->assertTrue( isset( $translatableLanguages['he'] ) );
00091     }
00092 }
Generated on Tue Oct 29 00:00:24 2013 for MediaWiki Translate Extension by  doxygen 1.6.3