summaryrefslogtreecommitdiff
path: root/tests/simple_unit/I18N
diff options
context:
space:
mode:
authorctrlaltca <>2012-07-12 11:21:01 +0000
committerctrlaltca <>2012-07-12 11:21:01 +0000
commit903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 (patch)
treee08bf04f0823650a231227ac3499121270172a23 /tests/simple_unit/I18N
parent3e4e6e66aeb3f8fea4e1eb4237498ef9d2358f63 (diff)
standardize the use of unix eol; use svn properties to enforce native eol
Diffstat (limited to 'tests/simple_unit/I18N')
-rw-r--r--tests/simple_unit/I18N/ChoiceFormatTest.php194
-rw-r--r--tests/simple_unit/I18N/CultureInfoTest.php24
-rw-r--r--tests/simple_unit/I18N/MysqlMessageSourceTestCase.php88
3 files changed, 153 insertions, 153 deletions
diff --git a/tests/simple_unit/I18N/ChoiceFormatTest.php b/tests/simple_unit/I18N/ChoiceFormatTest.php
index 3a95b5a8..809d46b4 100644
--- a/tests/simple_unit/I18N/ChoiceFormatTest.php
+++ b/tests/simple_unit/I18N/ChoiceFormatTest.php
@@ -1,98 +1,98 @@
-<?php
-
-Prado::using('System.I18N.core.ChoiceFormat');
-
-class ChoiceFormatTest extends UnitTestCase
-{
- function testChoices()
- {
- $choice = new ChoiceFormat();
- $string = '[0] are no files |[1] is one file |(1,Inf] are {number} files';
-
- $want = 'are no files';
- $this->assertEqual($want, $choice->format($string, 0));
-
- $want = 'is one file';
- $this->assertEqual($want, $choice->format($string, 1));
-
- $want = 'are {number} files';
- $this->assertEqual($want, $choice->format($string, 5));
-
- $this->assertFalse($choice->format($string, -1));
-
- $string = '{1,2} one two |{3,4} three four |[2,5] two to five inclusive';
- $this->assertEqual($choice->format($string,1),'one two');
- $this->assertEqual($choice->format($string,2.1),'two to five inclusive');
- $this->assertEqual($choice->format($string,3),'three four');
- }
-
- function test_set_notation()
- {
- $choice = new ChoiceFormat();
- $string = '{n: n%2 == 0} are even numbers |{n: n >= 5} are not even and greater than or equal to 5';
-
- $want = 'are even numbers';
- $this->assertEqual($want, $choice->format($string, 0));
- $this->assertEqual($want, $choice->format($string, 2));
- $this->assertEqual($want, $choice->format($string, 4));
- $this->assertNotEqual($want, $choice->format($string, 1));
-
- $want = 'are not even and greater than or equal to 5';
- $this->assertEqual($want, $choice->format($string, 5));
- }
-
- function test_polish()
- {
- $choice = new ChoiceFormat();
- $string = '[1] plik |{2,3,4} pliki
- |[5,21] pliko\'w |{n: n % 10 > 1 && n %10 < 5} pliki |{n: n%10 >= 5 || n%10 <=1} pliko\'w';
-
- $wants = array( 'plik' => array(1),
- 'pliki' => array(2,3,4,22,23,24),
- 'pliko\'w' => array(5,6,7,11,12,15,17,20,21,25,26,30));
- foreach($wants as $want => $numbers)
- {
- foreach($numbers as $n)
- $this->assertEqual($want, $choice->format($string, $n));
- }
- }
-
- function test_russian()
- {
- $choice = new ChoiceFormat();
- $string = '
- {n: n % 10 == 1 && n % 100 != 11} test1
- |{n: n % 10 >= 2 && n % 10 <= 4 && ( n % 100 < 10 || n % 100 >= 20 )} test2
- |{n: 2} test3';
-
- $wants = array('test1' => array(1,21,31,41),
- 'test2' => array(2,4, 22, 24, 32, 34),
- 'test3' => array(0, 5,6,7,8,9,10,11,12,13,14, 20,25,26,30)
- );
- foreach($wants as $want => $numbers)
- {
- foreach($numbers as $n)
- $this->assertEqual($want, $choice->format($string, $n));
- }
- }
-
- function test_english()
- {
- $choice = new ChoiceFormat();
- $string = '[0] none |{n: n % 10 == 1} 1st |{n: n % 10 == 2} 2nd |{n: n % 10 == 3} 3rd |{n:n} th';
-
- $wants = array('none' => array(0),
- '1st' => array(1,11,21),
- '2nd' => array(2,12,22),
- '3rd' => array(3,13,23),
- 'th' => array(4,5,6,7,14,15)
- );
- foreach($wants as $want => $numbers)
- {
- foreach($numbers as $n)
- $this->assertEqual($want, $choice->format($string, $n));
- }
- }
-}
-
+<?php
+
+Prado::using('System.I18N.core.ChoiceFormat');
+
+class ChoiceFormatTest extends UnitTestCase
+{
+ function testChoices()
+ {
+ $choice = new ChoiceFormat();
+ $string = '[0] are no files |[1] is one file |(1,Inf] are {number} files';
+
+ $want = 'are no files';
+ $this->assertEqual($want, $choice->format($string, 0));
+
+ $want = 'is one file';
+ $this->assertEqual($want, $choice->format($string, 1));
+
+ $want = 'are {number} files';
+ $this->assertEqual($want, $choice->format($string, 5));
+
+ $this->assertFalse($choice->format($string, -1));
+
+ $string = '{1,2} one two |{3,4} three four |[2,5] two to five inclusive';
+ $this->assertEqual($choice->format($string,1),'one two');
+ $this->assertEqual($choice->format($string,2.1),'two to five inclusive');
+ $this->assertEqual($choice->format($string,3),'three four');
+ }
+
+ function test_set_notation()
+ {
+ $choice = new ChoiceFormat();
+ $string = '{n: n%2 == 0} are even numbers |{n: n >= 5} are not even and greater than or equal to 5';
+
+ $want = 'are even numbers';
+ $this->assertEqual($want, $choice->format($string, 0));
+ $this->assertEqual($want, $choice->format($string, 2));
+ $this->assertEqual($want, $choice->format($string, 4));
+ $this->assertNotEqual($want, $choice->format($string, 1));
+
+ $want = 'are not even and greater than or equal to 5';
+ $this->assertEqual($want, $choice->format($string, 5));
+ }
+
+ function test_polish()
+ {
+ $choice = new ChoiceFormat();
+ $string = '[1] plik |{2,3,4} pliki
+ |[5,21] pliko\'w |{n: n % 10 > 1 && n %10 < 5} pliki |{n: n%10 >= 5 || n%10 <=1} pliko\'w';
+
+ $wants = array( 'plik' => array(1),
+ 'pliki' => array(2,3,4,22,23,24),
+ 'pliko\'w' => array(5,6,7,11,12,15,17,20,21,25,26,30));
+ foreach($wants as $want => $numbers)
+ {
+ foreach($numbers as $n)
+ $this->assertEqual($want, $choice->format($string, $n));
+ }
+ }
+
+ function test_russian()
+ {
+ $choice = new ChoiceFormat();
+ $string = '
+ {n: n % 10 == 1 && n % 100 != 11} test1
+ |{n: n % 10 >= 2 && n % 10 <= 4 && ( n % 100 < 10 || n % 100 >= 20 )} test2
+ |{n: 2} test3';
+
+ $wants = array('test1' => array(1,21,31,41),
+ 'test2' => array(2,4, 22, 24, 32, 34),
+ 'test3' => array(0, 5,6,7,8,9,10,11,12,13,14, 20,25,26,30)
+ );
+ foreach($wants as $want => $numbers)
+ {
+ foreach($numbers as $n)
+ $this->assertEqual($want, $choice->format($string, $n));
+ }
+ }
+
+ function test_english()
+ {
+ $choice = new ChoiceFormat();
+ $string = '[0] none |{n: n % 10 == 1} 1st |{n: n % 10 == 2} 2nd |{n: n % 10 == 3} 3rd |{n:n} th';
+
+ $wants = array('none' => array(0),
+ '1st' => array(1,11,21),
+ '2nd' => array(2,12,22),
+ '3rd' => array(3,13,23),
+ 'th' => array(4,5,6,7,14,15)
+ );
+ foreach($wants as $want => $numbers)
+ {
+ foreach($numbers as $n)
+ $this->assertEqual($want, $choice->format($string, $n));
+ }
+ }
+}
+
?> \ No newline at end of file
diff --git a/tests/simple_unit/I18N/CultureInfoTest.php b/tests/simple_unit/I18N/CultureInfoTest.php
index 840d8f17..7df7deeb 100644
--- a/tests/simple_unit/I18N/CultureInfoTest.php
+++ b/tests/simple_unit/I18N/CultureInfoTest.php
@@ -1,13 +1,13 @@
-<?php
-
-Prado::using('System.I18N.core.*');
-class CultureInfoTest extends UnitTestCase
-{
- function test_missing_english_names_returns_culture_code()
- {
- $culture = new CultureInfo('iw');
- $this->assertEqual($culture->getEnglishName(), 'iw');
- }
-}
-
+<?php
+
+Prado::using('System.I18N.core.*');
+class CultureInfoTest extends UnitTestCase
+{
+ function test_missing_english_names_returns_culture_code()
+ {
+ $culture = new CultureInfo('iw');
+ $this->assertEqual($culture->getEnglishName(), 'iw');
+ }
+}
+
?> \ No newline at end of file
diff --git a/tests/simple_unit/I18N/MysqlMessageSourceTestCase.php b/tests/simple_unit/I18N/MysqlMessageSourceTestCase.php
index 2fc96163..80e9c1fd 100644
--- a/tests/simple_unit/I18N/MysqlMessageSourceTestCase.php
+++ b/tests/simple_unit/I18N/MysqlMessageSourceTestCase.php
@@ -1,45 +1,45 @@
-<?php
-
-Prado::using('System.I18N.core.MessageSource_MySQL');
-Prado::using('System.I18N.core.MessageFormat');
-
-class MysqlMessageSourceTestCase extends UnitTestCase
-{
- private $_source;
-
- function get_source()
- {
- if($this->_source===null)
- {
- $this->_source = new MessageSource_MySQL('mysq://prado:prado@localhost/i18n_test');
- $this->_source->setCulture('en_AU');
- }
- return $this->_source;
- }
-
-/*
- function test_source()
- {
- $source = $this->get_source();
- $this->assertEqual(3, count($source->catalogues()));
- }
-
- function test_load_source()
- {
- $source = $this->get_source();
- $this->assertTrue($source->load());
- }
-
- function test_message_format()
- {
- $formatter = new MessageFormat($this->get_source());
- var_dump($formatter->format('Hello'));
- var_dump($formatter->format('Goodbye'));
- //$this->assertEqual($formatter->format('Hello'),'G\'day Mate!');
-
- //$this->assertEqual($formatter->format('Goodbye'), 'Goodbye');
- }
-*/
-}
-
+<?php
+
+Prado::using('System.I18N.core.MessageSource_MySQL');
+Prado::using('System.I18N.core.MessageFormat');
+
+class MysqlMessageSourceTestCase extends UnitTestCase
+{
+ private $_source;
+
+ function get_source()
+ {
+ if($this->_source===null)
+ {
+ $this->_source = new MessageSource_MySQL('mysq://prado:prado@localhost/i18n_test');
+ $this->_source->setCulture('en_AU');
+ }
+ return $this->_source;
+ }
+
+/*
+ function test_source()
+ {
+ $source = $this->get_source();
+ $this->assertEqual(3, count($source->catalogues()));
+ }
+
+ function test_load_source()
+ {
+ $source = $this->get_source();
+ $this->assertTrue($source->load());
+ }
+
+ function test_message_format()
+ {
+ $formatter = new MessageFormat($this->get_source());
+ var_dump($formatter->format('Hello'));
+ var_dump($formatter->format('Goodbye'));
+ //$this->assertEqual($formatter->format('Hello'),'G\'day Mate!');
+
+ //$this->assertEqual($formatter->format('Goodbye'), 'Goodbye');
+ }
+*/
+}
+
?> \ No newline at end of file