silverstripe-framework/tests/php/i18n/YamlReaderTest.php
Damian Mooyman de02a3f733
Restored context parameter to i18n, and added to a “comment” key
Rolled pluralisation functionality into the i18n::_t() method
Warnings on missing default can now be turned off
2017-01-25 18:12:40 +13:00

42 lines
1.5 KiB
PHP

<?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',
'SPRINTFNONAMESPACE' => 'My replacement no namespace: %s',
'SPRINTFINCLUDENONAMESPACE' => 'My include replacement no namespace: %s',
'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',
'i18nTestModule.SPRINTFNAMESPACE' => 'My replacement: %s',
'i18nTestModuleInclude.ss.SPRINTFINCLUDENAMESPACE' => 'My include replacement: %s',
'i18nTestModule.PLURALS' => [
'one' => 'A test',
'other' => '{count} tests',
],
'Month.PLURALS' => [
'one' => 'A month',
'other' => '{count} months',
],
];
$this->assertEquals($expected, $output);
}
}