]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/languages/fr/LanguagesFrTest.php
Compatibility with PHPUnit 9
[github/shaarli/Shaarli.git] / tests / languages / fr / LanguagesFrTest.php
index c05a0f98643c24f7f452a7ddac40c120b5ff7290..d84feed135366f3e122785839d24f2eb9dd93e2d 100644 (file)
@@ -3,7 +3,6 @@
 
 namespace Shaarli;
 
-
 use Shaarli\Config\ConfigManager;
 
 /**
@@ -13,7 +12,7 @@ use Shaarli\Config\ConfigManager;
  *
  * @package Shaarli
  */
-class LanguagesFrTest extends \PHPUnit_Framework_TestCase
+class LanguagesFrTest extends \Shaarli\TestCase
 {
     /**
      * @var string Config file path (without extension).
@@ -28,7 +27,7 @@ class LanguagesFrTest extends \PHPUnit_Framework_TestCase
     /**
      * Init: force French
      */
-    public function setUp()
+    protected function setUp(): void
     {
         $this->conf = new ConfigManager(self::$configFile);
         $this->conf->set('translation.language', 'fr');
@@ -37,7 +36,7 @@ class LanguagesFrTest extends \PHPUnit_Framework_TestCase
     /**
      * 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'));
@@ -155,7 +154,8 @@ class LanguagesFrTest extends \PHPUnit_Framework_TestCase
         $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'));
     }
 
@@ -167,7 +167,34 @@ class LanguagesFrTest extends \PHPUnit_Framework_TestCase
         $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'));
+    }
 }