namespace Shaarli;
-
use Shaarli\Config\ConfigManager;
/**
*
* @package Shaarli
*/
-class LanguagesFrTest extends \PHPUnit_Framework_TestCase
+class LanguagesFrTest extends \PHPUnit\Framework\TestCase
{
/**
* @var string Config file path (without extension).
/**
* Init: force French
*/
- public function setUp()
+ protected function setUp(): void
{
$this->conf = new ConfigManager(self::$configFile);
$this->conf->set('translation.language', 'fr');
/**
* Reset the locale since gettext seems to mess with it, making it too long
*/
- public static function tearDownAfterClass()
+ public static function tearDownAfterClass(): void
{
if (! empty(getenv('UT_LOCALE'))) {
setlocale(LC_ALL, getenv('UT_LOCALE'));
$this->conf->set('translation.mode', 'gettext');
$this->conf->set('translation.extensions.test', 'tests/utils/languages/');
new Languages('en', $this->conf);
- $this->assertEquals('voiture', t('car', 'car', 1, 'test'));
+ $txt = 'car'; // ignore me poedit
+ $this->assertEquals('voiture', t($txt, $txt, 1, 'test'));
$this->assertEquals('Fouille', t('Search', 'Search', 1, 'test'));
}
$this->conf->set('translation.mode', 'php');
$this->conf->set('translation.extensions.test', 'tests/utils/languages/');
new Languages('en', $this->conf);
- $this->assertEquals('voiture', t('car', 'car', 1, 'test'));
+ $txt = 'car'; // ignore me poedit
+ $this->assertEquals('voiture', t($txt, $txt, 1, 'test'));
$this->assertEquals('Fouille', t('Search', 'Search', 1, 'test'));
}
+
+ /**
+ * Test t() with an extension language file coming from the theme in gettext mode
+ */
+ public function testTranslationThemeExtensionGettext()
+ {
+ $this->conf->set('translation.mode', 'gettext');
+ $this->conf->set('raintpl_tpl', 'tests/utils/customtpl/');
+ $this->conf->set('theme', 'dummy');
+ new Languages('en', $this->conf);
+ $txt = 'rooster'; // ignore me poedit
+ $this->assertEquals('coq', t($txt, $txt, 1, 'dummy'));
+ }
+
+ /**
+ * Test t() with an extension language file coming from the theme in PHP mode
+ */
+ public function testTranslationThemeExtensionPhp()
+ {
+ $this->conf->set('translation.mode', 'php');
+ $this->conf->set('raintpl_tpl', 'tests/utils/customtpl/');
+ $this->conf->set('theme', 'dummy');
+ new Languages('en', $this->conf);
+ $txt = 'rooster'; // ignore me poedit
+ $this->assertEquals('coq', t($txt, $txt, 1, 'dummy'));
+ }
}