IniFFSTest.php
Go to the documentation of this file.00001 <?php
00011 class IniFFSTest extends MediaWikiTestCase {
00012
00013 protected $groupConfiguration = array(
00014 'BASIC' => array(
00015 'class' => 'FileBasedMessageGroup',
00016 'id' => 'test-id',
00017 'label' => 'Test Label',
00018 'namespace' => 'NS_MEDIAWIKI',
00019 'description' => 'Test description',
00020 ),
00021 'FILES' => array(
00022 'class' => 'IniFFS',
00023 'sourcePattern' => 'ignored',
00024 ),
00025 );
00026
00027 public function testParsing() {
00028 $file = file_get_contents( __DIR__ . '/../data/IniFFSTest1.ini' );
00029
00033 $group = MessageGroupBase::factory( $this->groupConfiguration );
00034 $ffs = new IniFFS( $group );
00035
00036 $this->assertTrue( IniFFS::isValid( $file ) );
00037
00038 $parsed = $ffs->readFromVariable( $file );
00039 $expected = array(
00040 'hello' => 'Hello',
00041 'world' => 'World!',
00042 'all' => 'all = all',
00043 'foo.bar' => 'bar',
00044 'quote' => "We're having fun?",
00045 );
00046 $expected = array(
00047 'MESSAGES' => $expected,
00048 'AUTHORS' => array( 'The king of very small kingdom' )
00049 );
00050 $this->assertEquals( $expected, $parsed );
00051 }
00052
00053 public function testExport() {
00054 global $wgSitename;
00055 $file = file_get_contents( __DIR__ . '/../data/IniFFSTest2.ini' );
00056 $file = str_replace( '$wgSitename', $wgSitename, $file );
00057
00058 $collection = new MockMessageCollectionForExport();
00062 $group = MessageGroupBase::factory( $this->groupConfiguration );
00063 $ffs = new IniFFS( $group );
00064 $this->assertEquals( $file, $ffs->writeIntoVariable( $collection ) );
00065 }
00066 }