XliffFFSTest.php
Go to the documentation of this file.00001 <?php
00010 class XliffFFSTest extends MediaWikiTestCase {
00011 protected $groupConfiguration = array(
00012 'BASIC' => array(
00013 'class' => 'FileBasedMessageGroup',
00014 'id' => 'test-id',
00015 'label' => 'Test Label',
00016 'namespace' => 'NS_MEDIAWIKI',
00017 'description' => 'Test description',
00018 ),
00019 'FILES' => array(
00020 'class' => 'XliffFFS',
00021 'sourcePattern' => '',
00022 ),
00023 );
00024
00025 public function testParsing() {
00026 $group = MessageGroupBase::factory( $this->groupConfiguration );
00027 $ffs = new XliffFFS( $group );
00028
00029 $file = file_get_contents( __DIR__ . '/../data/minimal.xlf' );
00030 $parsed = $ffs->readFromVariable( $file, 'target' );
00031 $expected = array(
00032 '1' => 'Hei maailma',
00033 '2' => TRANSLATE_FUZZY . 'Fuzzy translation',
00034 '3' => 'Tämä on <g id="1" ctype="bold">paksu</g>.',
00035 );
00036 $expected = array( 'MESSAGES' => $expected );
00037 $this->assertEquals( $expected, $parsed );
00038
00039 $parsed = $ffs->readFromVariable( $file, 'source' );
00040 $expected = array(
00041 '1' => 'Hello world',
00042 '2' => 'Fuzzy message',
00043 '3' => 'This is <g id="1" ctype="bold">bold</g>.',
00044 );
00045 $expected = array( 'MESSAGES' => $expected );
00046 $this->assertEquals( $expected, $parsed );
00047 }
00048 }