MessageGroupBaseTest.php

Go to the documentation of this file.
00001 <?php
00002 
00003 class MessageGroupBaseTest extends MediaWikiTestCase {
00004 
00008     protected $group;
00009 
00010     protected $groupConfiguration = array(
00011         'BASIC' => array(
00012             'class' => 'FileBasedMessageGroup',
00013             'id' => 'test-id',
00014             'label' => 'Test Label',
00015             'namespace' => 'NS_MEDIAWIKI',
00016             'description' => 'Test description',
00017         ),
00018     );
00019 
00020     protected function setUp() {
00021         parent::setUp();
00022         $this->group = MessageGroupBase::factory( $this->groupConfiguration );
00023     }
00024 
00025     protected function tearDown() {
00026         unset( $this->group );
00027         parent::tearDown();
00028     }
00029 
00030     public function testGetConfiguration() {
00031         $this->assertEquals(
00032             $this->groupConfiguration,
00033             $this->group->getConfiguration(),
00034             "configuration should not change."
00035         );
00036     }
00037 
00038     public function testGetId() {
00039         $this->assertEquals(
00040             $this->groupConfiguration['BASIC']['id'],
00041             $this->group->getId(),
00042             "id comes from config."
00043         );
00044     }
00045 
00046     public function testGetSourceLanguage() {
00047         $this->assertEquals(
00048             'en',
00049             $this->group->getSourceLanguage(),
00050             "source language defaults to en."
00051         );
00052     }
00053 
00054     public function testGetNamespaceConstant() {
00055         $this->assertEquals(
00056             NS_MEDIAWIKI,
00057             $this->group->getNamespace(),
00058             "should parse string namespace contant."
00059         );
00060     }
00061 
00062     public function testGetNamespaceNumber() {
00063         $conf = $this->groupConfiguration;
00064         $conf['BASIC']['namespace'] = NS_IMAGE;
00065         $this->group = MessageGroupBase::factory( $conf );
00066 
00067         $this->assertEquals(
00068             NS_IMAGE,
00069             $this->group->getNamespace(),
00070             "should parse integer namespace number."
00071         );
00072     }
00073 
00074     public function testGetNamespaceString() {
00075         $conf = $this->groupConfiguration;
00076         $conf['BASIC']['namespace'] = 'image';
00077         $this->group = MessageGroupBase::factory( $conf );
00078 
00079         $this->assertEquals(
00080             NS_IMAGE,
00081             $this->group->getNamespace(),
00082             "should parse string namespace name."
00083         );
00084     }
00085 
00090     public function testGetNamespaceInvalid() {
00091         $conf = $this->groupConfiguration;
00092         $conf['BASIC']['namespace'] = 'ergweofijwef';
00093         MessageGroupBase::factory( $conf );
00094     }
00095 }
Generated on Tue Oct 29 00:00:24 2013 for MediaWiki Translate Extension by  doxygen 1.6.3