Skip to content

Commit

Permalink
Adding / updating I18n class test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Jan 9, 2012
1 parent 30522d0 commit 0be71a0
Showing 1 changed file with 42 additions and 12 deletions.
54 changes: 42 additions & 12 deletions lib/Cake/Test/Case/I18n/I18nTest.php
Expand Up @@ -50,10 +50,14 @@ public function tearDown() {
CakePlugin::unload();
}


/**
* testTranslationCaching method
*
* @return void
*/
public function testTranslationCaching() {
Configure::write('Config.language', 'cache_test_po');
$i18n = i18n::getInstance();
$i18n = I18n::getInstance();

// reset internally stored entries
I18n::clear();
Expand Down Expand Up @@ -93,7 +97,6 @@ public function testTranslationCaching() {
$this->assertEquals('FOO', I18n::translate('dom1.foo', false, 'dom1'));
}


/**
* testDefaultStrings method
*
Expand Down Expand Up @@ -2588,6 +2591,11 @@ public function testCategoryThenSingular() {
$this->assertEquals('Po (translated)', $singular);
}

/**
* testTimeDefinition method
*
* @return void
*/
public function testTimeDefinition() {
Configure::write('Config.language', 'po');
$result = __c('d_fmt', 5);
Expand All @@ -2603,6 +2611,11 @@ public function testTimeDefinition() {
$this->assertEquals($expected, $result);
}

/**
* testTimeDefinitionJapanese method
*
* @return void
*/
public function testTimeDefinitionJapanese() {
Configure::write('Config.language', 'ja_jp');
$result = __c('d_fmt', 5);
Expand All @@ -2620,12 +2633,29 @@ public function testTimeDefinitionJapanese() {
$this->assertEquals($expected, $result);
}

/**
* testTranslateLanguageParam method
*
* @return void
*/
public function testTranslateLanguageParam() {
Configure::write('Config.language', 'rule_0_po');

$result = I18n::translate('Plural Rule 1', null, null, 6);
$expected = 'Plural Rule 0 (translated)';
$this->assertEquals($expected, $result);

$result = I18n::translate('Plural Rule 1', null, null, 6, null, 'rule_1_po');
$expected = 'Plural Rule 1 (translated)';
$this->assertEquals($expected, $result);
}

/**
* Singular method
*
* @return void
*/
function __domainCategorySingular($domain = 'test_plugin', $category = 3) {
private function __domainCategorySingular($domain = 'test_plugin', $category = 3) {
$singular = __dc($domain, 'Plural Rule 1', $category);
return $singular;
}
Expand All @@ -2635,7 +2665,7 @@ function __domainCategorySingular($domain = 'test_plugin', $category = 3) {
*
* @return void
*/
function __domainCategoryPlural($domain = 'test_plugin', $category = 3) {
private function __domainCategoryPlural($domain = 'test_plugin', $category = 3) {
$plurals = array();
for ($number = 0; $number <= 25; $number++) {
$plurals[] = sprintf(__dcn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, $category), (float)$number);
Expand All @@ -2648,7 +2678,7 @@ function __domainCategoryPlural($domain = 'test_plugin', $category = 3) {
*
* @return void
*/
function __domainSingular($domain = 'test_plugin') {
private function __domainSingular($domain = 'test_plugin') {
$singular = __d($domain, 'Plural Rule 1');
return $singular;
}
Expand All @@ -2658,7 +2688,7 @@ function __domainSingular($domain = 'test_plugin') {
*
* @return void
*/
function __domainPlural($domain = 'test_plugin') {
private function __domainPlural($domain = 'test_plugin') {
$plurals = array();
for ($number = 0; $number <= 25; $number++) {
$plurals[] = sprintf(__dn($domain, '%d = 1', '%d = 0 or > 1', (float)$number), (float)$number );
Expand All @@ -2671,7 +2701,7 @@ function __domainPlural($domain = 'test_plugin') {
*
* @return void
*/
function __category($category = 3) {
private function __category($category = 3) {
$singular = __c('Plural Rule 1', $category);
return $singular;
}
Expand All @@ -2681,7 +2711,7 @@ function __category($category = 3) {
*
* @return void
*/
function __singular() {
private function __singular() {
$singular = __('Plural Rule 1');
return $singular;
}
Expand All @@ -2691,7 +2721,7 @@ function __singular() {
*
* @return void
*/
function __plural() {
private function __plural() {
$plurals = array();
for ($number = 0; $number <= 25; $number++) {
$plurals[] = sprintf(__n('%d = 1', '%d = 0 or > 1', (float)$number), (float)$number);
Expand All @@ -2704,7 +2734,7 @@ function __plural() {
*
* @return void
*/
function __singularFromCore() {
private function __singularFromCore() {
$singular = __('Plural Rule 1 (from core)');
return $singular;
}
Expand All @@ -2714,7 +2744,7 @@ function __singularFromCore() {
*
* @return void
*/
function __pluralFromCore() {
private function __pluralFromCore() {
$plurals = array();
for ($number = 0; $number <= 25; $number++) {
$plurals[] = sprintf(__n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', (float)$number), (float)$number );
Expand Down

0 comments on commit 0be71a0

Please sign in to comment.