Fix tests

This commit is contained in:
Damian Mooyman 2017-04-27 16:54:42 +12:00
parent 7b7b3810e6
commit 2ae8fde2d3
3 changed files with 12 additions and 12 deletions

View File

@ -81,29 +81,29 @@ class i18nTest extends SapphireTest
$provider = Injector::inst()->get(MessageProvider::class);
$provider->getTranslator()->addResource(
'array',
[ 'i18nTest_DataObject.MyProperty' => 'MyProperty' ],
[ i18nTest\TestDataObject::class.'.MyProperty' => 'MyProperty' ],
'en_US'
);
$provider->getTranslator()->addResource(
'array',
[ 'i18nTest_DataObject.MyProperty' => 'Mein Attribut' ],
[ i18nTest\TestDataObject::class.'.MyProperty' => 'Mein Attribut' ],
'de_DE'
);
$provider->getTranslator()->addResource(
'array',
[ 'i18nTest_DataObject.MyUntranslatedProperty' => 'Mein Attribut' ],
[ i18nTest\TestDataObject::class.'.MyUntranslatedProperty' => 'Mein Attribut' ],
'en_US'
);
// Test field labels
$obj = new i18nTest\TestDataObject();
$this->assertEquals(
$obj->fieldLabel('MyProperty'),
'Mein Attribut'
'Mein Attribut',
$obj->fieldLabel('MyProperty')
);
$this->assertEquals(
$obj->fieldLabel('MyUntranslatedProperty'),
'My Untranslated Property'
'My Untranslated Property',
$obj->fieldLabel('MyUntranslatedProperty')
);
}
@ -113,12 +113,12 @@ class i18nTest extends SapphireTest
$provider = Injector::inst()->get(MessageProvider::class);
$provider->getTranslator()->addResource(
'array',
[ 'i18nTest_Object.MyProperty' => 'Untranslated' ],
[ i18nTest\TestObject::class.'.MyProperty' => 'Untranslated' ],
'en_US'
);
$provider->getTranslator()->addResource(
'array',
[ 'i18nTest_Object.my_translatable_property' => 'Übersetzt' ],
[ i18nTest\TestObject::class.'.my_translatable_property' => 'Übersetzt' ],
'de_DE'
);

View File

@ -34,7 +34,7 @@ class TestDataObject extends DataObject implements TestOnly
public function fieldLabels($includerelations = true)
{
$labels = parent::fieldLabels($includerelations);
$labels['MyProperty'] = _t('SilverStripe\\i18n\\Tests\\i18Test\\TestDataObject.MyProperty', 'My Property');
$labels['MyProperty'] = _t(__CLASS__.'.MyProperty', 'My Property');
return $labels;
}

View File

@ -11,13 +11,13 @@ class TestObject implements TestOnly, i18nEntityProvider
public static function my_translatable_property()
{
return _t("SilverStripe\\i18n\\Tests\\i18Test\\TestObject.my_translatable_property", self::$my_translatable_property);
return _t(__CLASS__.".my_translatable_property", self::$my_translatable_property);
}
public function provideI18nEntities()
{
return [
"i18nTest_Object.my_translatable_property" => self::$my_translatable_property,
__CLASS__.".my_translatable_property" => self::$my_translatable_property,
];
}
}