mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Fix tests
This commit is contained in:
parent
7b7b3810e6
commit
2ae8fde2d3
@ -81,29 +81,29 @@ class i18nTest extends SapphireTest
|
|||||||
$provider = Injector::inst()->get(MessageProvider::class);
|
$provider = Injector::inst()->get(MessageProvider::class);
|
||||||
$provider->getTranslator()->addResource(
|
$provider->getTranslator()->addResource(
|
||||||
'array',
|
'array',
|
||||||
[ 'i18nTest_DataObject.MyProperty' => 'MyProperty' ],
|
[ i18nTest\TestDataObject::class.'.MyProperty' => 'MyProperty' ],
|
||||||
'en_US'
|
'en_US'
|
||||||
);
|
);
|
||||||
$provider->getTranslator()->addResource(
|
$provider->getTranslator()->addResource(
|
||||||
'array',
|
'array',
|
||||||
[ 'i18nTest_DataObject.MyProperty' => 'Mein Attribut' ],
|
[ i18nTest\TestDataObject::class.'.MyProperty' => 'Mein Attribut' ],
|
||||||
'de_DE'
|
'de_DE'
|
||||||
);
|
);
|
||||||
$provider->getTranslator()->addResource(
|
$provider->getTranslator()->addResource(
|
||||||
'array',
|
'array',
|
||||||
[ 'i18nTest_DataObject.MyUntranslatedProperty' => 'Mein Attribut' ],
|
[ i18nTest\TestDataObject::class.'.MyUntranslatedProperty' => 'Mein Attribut' ],
|
||||||
'en_US'
|
'en_US'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test field labels
|
// Test field labels
|
||||||
$obj = new i18nTest\TestDataObject();
|
$obj = new i18nTest\TestDataObject();
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$obj->fieldLabel('MyProperty'),
|
'Mein Attribut',
|
||||||
'Mein Attribut'
|
$obj->fieldLabel('MyProperty')
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$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 = Injector::inst()->get(MessageProvider::class);
|
||||||
$provider->getTranslator()->addResource(
|
$provider->getTranslator()->addResource(
|
||||||
'array',
|
'array',
|
||||||
[ 'i18nTest_Object.MyProperty' => 'Untranslated' ],
|
[ i18nTest\TestObject::class.'.MyProperty' => 'Untranslated' ],
|
||||||
'en_US'
|
'en_US'
|
||||||
);
|
);
|
||||||
$provider->getTranslator()->addResource(
|
$provider->getTranslator()->addResource(
|
||||||
'array',
|
'array',
|
||||||
[ 'i18nTest_Object.my_translatable_property' => 'Übersetzt' ],
|
[ i18nTest\TestObject::class.'.my_translatable_property' => 'Übersetzt' ],
|
||||||
'de_DE'
|
'de_DE'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class TestDataObject extends DataObject implements TestOnly
|
|||||||
public function fieldLabels($includerelations = true)
|
public function fieldLabels($includerelations = true)
|
||||||
{
|
{
|
||||||
$labels = parent::fieldLabels($includerelations);
|
$labels = parent::fieldLabels($includerelations);
|
||||||
$labels['MyProperty'] = _t('SilverStripe\\i18n\\Tests\\i18Test\\TestDataObject.MyProperty', 'My Property');
|
$labels['MyProperty'] = _t(__CLASS__.'.MyProperty', 'My Property');
|
||||||
|
|
||||||
return $labels;
|
return $labels;
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,13 @@ class TestObject implements TestOnly, i18nEntityProvider
|
|||||||
|
|
||||||
public static function my_translatable_property()
|
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()
|
public function provideI18nEntities()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
"i18nTest_Object.my_translatable_property" => self::$my_translatable_property,
|
__CLASS__.".my_translatable_property" => self::$my_translatable_property,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user