Skip to content
Permalink
Browse files

Add additional tests for array args.

Add tests for translation helpers with array arguments. These tests were
missing before and should help prevent regressions while #10087 is
solved.
  • Loading branch information...
markstory committed Jan 28, 2017
1 parent 9fff233 commit 35aa70e6bb287392526b34764f1587e0ca27f648
Showing with 15 additions and 0 deletions.
  1. +15 −0 tests/TestCase/I18n/I18nTest.php
@@ -242,6 +242,9 @@ public function testBasicTranslateFunction()
I18n::defaultFormatter('sprintf');
$this->assertEquals('%d is 1 (po translated)', __('%d = 1'));
$this->assertEquals('1 is 1 (po translated)', __('%d = 1', 1));
$this->assertEquals('1 is 1 (po translated)', __('%d = 1', [1]));
$this->assertEquals('The red dog, and blue cat', __('The %s dog, and %s cat', ['red', 'blue']));
$this->assertEquals('The red dog, and blue cat', __('The %s dog, and %s cat', 'red', 'blue'));
}
/**
@@ -268,6 +271,12 @@ public function testBasicTranslatePluralFunction()
$result = __n('singular msg', '%d = 0 or > 1', 2);
$this->assertEquals('2 is 2-4 (po translated)', $result);
$result = __n('%s %s and %s are good', '%s and %s are best', 1, ['red', 'blue']);
$this->assertEquals('1 red and blue are good', $result);
$result = __n('%s %s and %s are good', '%s and %s are best', 1, 'red', 'blue');
$this->assertEquals('1 red and blue are good', $result);
}
/**
@@ -292,6 +301,9 @@ public function testBasicDomainFunction()
$result = __d('custom', 'The {0} is tasty', ['fruit']);
$this->assertEquals('The fruit is delicious', $result);
$result = __d('custom', 'The {0} is tasty', 'fruit');
$this->assertEquals('The fruit is delicious', $result);
$result = __d('custom', 'Average price {0}', ['9.99']);
$this->assertEquals('Price Average 9.99', $result);
}
@@ -355,6 +367,9 @@ public function testBasicContextFunction()
$this->assertEquals('The letters A and B', __x('character', 'letters', ['A', 'B']));
$this->assertEquals('The letter A', __x('character', 'letter', ['A']));
$this->assertEquals('The letters A and B', __x('character', 'letters', 'A', 'B'));
$this->assertEquals('The letter A', __x('character', 'letter', 'A'));
$this->assertEquals(
'She wrote a letter to Thomas and Sara',
__x('communication', 'letters', ['Thomas', 'Sara'])

0 comments on commit 35aa70e

Please sign in to comment.
You can’t perform that action at this time.