forked from Marko-M/codeigniter-gettext
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a test about translated expressions
- Loading branch information
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
namespace CodeIgniterGetText\Tests; | ||
|
||
require_once('include/gettext_test_functions.php'); | ||
require_once('include/gettext_test_constants.php'); | ||
|
||
class TranslationTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
const EXPRESSION = "Let me test this expression"; | ||
|
||
/** | ||
* @before | ||
*/ | ||
public function testFrenchLocale() | ||
{ | ||
$config = array( | ||
'gettext_locale_dir' => 'testTranslations', | ||
'gettext_text_domain' => 'my-domain', | ||
'gettext_catalog_codeset' => 'UTF-8', | ||
'gettext_locale' => 'fr_FR' | ||
); | ||
|
||
// only for avoid output when launch test | ||
$this->expectOutputRegex('//'); | ||
|
||
\Gettext::init($config); | ||
} | ||
|
||
public function testDoubleUnderscore() | ||
{ | ||
$this->assertEquals("Une expression en Français", __("A expression in English")); | ||
} | ||
|
||
public function testUnderscroreE() | ||
{ | ||
$this->expectOutputRegex("/(Une expression en Français)$/"); | ||
_e("A expression in English"); | ||
} | ||
|
||
public function testUnderscroreN_Singular() | ||
{ | ||
$this->assertEquals( | ||
"Une expression en Français", __("A expression in English"), 1 | ||
); | ||
} | ||
|
||
public function testUnderscroreN_Plural() | ||
{ | ||
$this->assertEquals( | ||
"Une expression en Français", __("A expression in English"), 2 | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php | ||
|
||
// Simulate constants defined in CodeIgniter | ||
define('APPPATH', dirname(__FILE__)); | ||
define('APPPATH', realpath(dirname(__FILE__) . '/../') . '/'); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: CodeIgniter Gettext Test\n" | ||
"POT-Creation-Date: 2017-01-09 01:07+0100\n" | ||
"PO-Revision-Date: 2017-01-09 01:07+0100\n" | ||
"Last-Translator: Joël Gaujard <j.gaujard@gmail.com>\n" | ||
"Language-Team: Joël Gaujard <j.gaujard@gmail.com>\n" | ||
"Language: fr_FR\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"X-Generator: Poedit 1.8.11\n" | ||
"X-Poedit-Basepath: ../../..\n" | ||
"Plural-Forms: nplurals=2; plural=(n > 1);\n" | ||
"X-Poedit-SourceCharset: UTF-8\n" | ||
"X-Poedit-KeywordsList: __;_e;_n:1,2\n" | ||
"X-Poedit-SearchPath-0: .\n" | ||
|
||
#: TranslationTest.php:31 | ||
msgid "A expression in English" | ||
msgstr "Une expression en Français" |