Initialize a translation function

It matches the API of ngettext().
This commit is contained in:
ArthurHoaro 2016-08-07 11:52:49 +02:00
parent 65b2c795d0
commit edf3ff5a53
3 changed files with 63 additions and 0 deletions

41
tests/LanguagesTest.php Normal file
View file

@ -0,0 +1,41 @@
<?php
require_once 'application/Languages.php';
/**
* Class LanguagesTest.
*/
class LanguagesTest extends PHPUnit_Framework_TestCase
{
/**
* Test t() with a simple non identified value.
*/
public function testTranslateSingleNotID()
{
$text = 'abcdé 564 fgK';
$this->assertEquals($text, t($text));
}
/**
* Test t() with a non identified plural form.
*/
public function testTranslatePluralNotID()
{
$text = '%s sandwich';
$nText = '%s sandwiches';
$this->assertEquals('0 sandwich', t($text, $nText));
$this->assertEquals('1 sandwich', t($text, $nText, 1));
$this->assertEquals('2 sandwiches', t($text, $nText, 2));
}
/**
* Test t() with a non identified invalid plural form.
*/
public function testTranslatePluralNotIDInvalid()
{
$text = 'sandwich';
$nText = 'sandwiches';
$this->assertEquals('sandwich', t($text, $nText, 1));
$this->assertEquals('sandwiches', t($text, $nText, 2));
}
}