2017-01-18 04:58:48 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\i18n\Tests;
|
|
|
|
|
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
use SilverStripe\i18n\Messages\YamlReader;
|
|
|
|
|
|
|
|
class YamlReaderTest extends SapphireTest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function testRead()
|
|
|
|
{
|
|
|
|
$reader = new YamlReader();
|
|
|
|
$path = __DIR__ . '/i18nTest/_fakewebroot/i18ntestmodule/lang/en.yml';
|
|
|
|
$output = $reader->read('en', $path);
|
|
|
|
$expected = [
|
|
|
|
'NONAMESPACE' => 'Include Entity without Namespace',
|
2017-02-04 20:41:31 +01:00
|
|
|
'REPLACEMENTNONAMESPACE' => 'My replacement no namespace: {replacement}',
|
|
|
|
'REPLACEMENTINCLUDENONAMESPACE' => 'My include replacement no namespace: {replacement}',
|
2017-01-18 04:58:48 +01:00
|
|
|
'LAYOUTTEMPLATENONAMESPACE' => 'Layout Template no namespace',
|
|
|
|
'i18nTestModule.ENTITY' => 'Entity with "Double Quotes"',
|
|
|
|
'i18nTestModule.ADDITION' => 'Addition',
|
|
|
|
'i18nTestModule.MAINTEMPLATE' => 'Main Template',
|
|
|
|
'i18nTestModule.WITHNAMESPACE' => 'Include Entity with Namespace',
|
|
|
|
'i18nTestModule.LAYOUTTEMPLATE' => 'Layout Template',
|
2017-02-04 20:41:31 +01:00
|
|
|
'i18nTestModule.REPLACEMENTNAMESPACE' => 'My replacement: {replacement}',
|
|
|
|
'i18nTestModuleInclude_ss.REPLACEMENTINCLUDENAMESPACE' => 'My include replacement: {replacement}',
|
2017-01-25 04:35:13 +01:00
|
|
|
'i18nTestModule.PLURALS' => [
|
2017-01-18 04:58:48 +01:00
|
|
|
'one' => 'A test',
|
|
|
|
'other' => '{count} tests',
|
|
|
|
],
|
2017-01-25 04:35:13 +01:00
|
|
|
'Month.PLURALS' => [
|
|
|
|
'one' => 'A month',
|
|
|
|
'other' => '{count} months',
|
|
|
|
],
|
2017-01-18 04:58:48 +01:00
|
|
|
];
|
|
|
|
$this->assertEquals($expected, $output);
|
|
|
|
}
|
|
|
|
}
|