@@ -14,106 +14,103 @@ class DigitTextTest extends PHPUnit_Framework_TestCase
1414 */
1515 protected $ object ;
1616
17- /**
18- * @covers Helldar\DigitText\DigitText::text
19- */
20- public function testText ()
21- {
22- $ this ->testRu ();
23- $ this ->testEn ();
24- }
25-
2617 /**
2718 * Russian localization testing.
2819 *
2920 * @author Andrey Helldar <helldar@ai-rus.com>
3021 *
31- * @version 2016-11-28
22+ * @since 2016-11-28
23+ * @since 2017-03-27
3224 *
3325 * @since 1.0
3426 */
3527 public function testRu ()
3628 {
3729 $ result = array (
38- $ this ->object ->number (null , 'ru ' ) => 'ноль ' ,
39- $ this ->object ->number (64.23 , 'ru ' , true ) => 'шестьдесят четыре руб 23 коп ' ,
40- $ this ->object ->number (764 , 'ru ' ) => 'семьсот шестьдесят четыре ' ,
41- $ this ->object ->number (2866 , 'ru ' ) => 'две тысячи восемьсот шестьдесят шесть ' ,
42- $ this ->object ->number (7700 , 'ru ' ) => 'семь тысяч семьсот ' ,
43- $ this ->object ->number ('10,000 ' , 'ru ' ) => 'десять тысяч ' ,
44- $ this ->object ->number (14383 , 'ru ' ) => 'четырнадцать тысячи триста восемьдесят три ' ,
45- $ this ->object ->number (20383 , 'ru ' ) => 'двадцать тысяч триста восемьдесят три ' ,
46- $ this ->object ->number (700383 , 'ru ' ) => 'семьсот тысяч триста восемьдесят три ' ,
47- $ this ->object ->number (7644383 , 'ru ' ) => 'семь миллионов шестьсот сорок четыре тысячи триста восемьдесят три ' ,
48- $ this ->object ->number (70043783.65 , 'ru ' , true ) => 'семьдесят миллионов сорок три тысячи семьсот восемьдесят три руб 65 коп ' ,
49- $ this ->object ->number (786443783 , 'ru ' ) => 'семьсот восемьдесят шесть миллионов четыреста сорок три тысячи семьсот восемьдесят три ' ,
50- $ this ->object ->number (109 , 'ru ' ) => 'сто девять ' ,
51- $ this ->object ->number (110 , 'ru ' ) => 'сто десять ' ,
52- $ this ->object ->number (111 , 'ru ' ) => 'сто одиннадцать ' ,
53- $ this ->object ->number (112 , 'ru ' ) => 'сто двенадцать ' ,
54- $ this ->object ->number (116 , 'ru ' ) => 'сто шестнадцать ' ,
55- $ this ->object ->number (118 , 'ru ' ) => 'сто восемнадцать ' ,
56- $ this ->object ->number (120 , 'ru ' ) => 'сто двадцать ' ,
57- $ this ->object ->number (121 , 'ru ' ) => 'сто двадцать один ' ,
30+ $ this ->object ->get (0 , 'ru ' ) => 'ноль ' ,
31+ $ this ->object ->get (64.23 , 'ru ' , true ) => 'шестьдесят четыре руб 23 коп ' ,
32+ $ this ->object ->get (764 , 'ru ' ) => 'семьсот шестьдесят четыре ' ,
33+ $ this ->object ->get (2866 , 'ru ' ) => 'две тысячи восемьсот шестьдесят шесть ' ,
34+ $ this ->object ->get (7700 , 'ru ' ) => 'семь тысяч семьсот ' ,
35+ $ this ->object ->get ('10,000 ' , 'ru ' ) => 'десять тысяч ' ,
36+ $ this ->object ->get (14383 , 'ru ' ) => 'четырнадцать тысячи триста восемьдесят три ' ,
37+ $ this ->object ->get (20383 , 'ru ' ) => 'двадцать тысяч триста восемьдесят три ' ,
38+ $ this ->object ->get (700383 , 'ru ' ) => 'семьсот тысяч триста восемьдесят три ' ,
39+ $ this ->object ->get (7644383 , 'ru ' ) => 'семь миллионов шестьсот сорок четыре тысячи триста восемьдесят три ' ,
40+ $ this ->object ->get (70043783.65 , 'ru ' , true ) => 'семьдесят миллионов сорок три тысячи семьсот восемьдесят три руб 65 коп ' ,
41+ $ this ->object ->get (786443783 , 'ru ' ) => 'семьсот восемьдесят шесть миллионов четыреста сорок три тысячи семьсот восемьдесят три ' ,
42+ $ this ->object ->get (109 , 'ru ' ) => 'сто девять ' ,
43+ $ this ->object ->get (110 , 'ru ' ) => 'сто десять ' ,
44+ $ this ->object ->get (111 , 'ru ' ) => 'сто одиннадцать ' ,
45+ $ this ->object ->get (112 , 'ru ' ) => 'сто двенадцать ' ,
46+ $ this ->object ->get (116 , 'ru ' ) => 'сто шестнадцать ' ,
47+ $ this ->object ->get (118 , 'ru ' ) => 'сто восемнадцать ' ,
48+ $ this ->object ->get (120 , 'ru ' ) => 'сто двадцать ' ,
49+ $ this ->object ->get (121 , 'ru ' ) => 'сто двадцать один ' ,
50+ $ this ->object ->get (10010 , 'ru ' ) => 'десять тысяч десять ' ,
51+ $ this ->object ->get (10110 , 'ru ' ) => 'десять тысяч сто десять ' ,
52+ $ this ->object ->get (510110 , 'ru ' ) => 'пятьсот десять тысяч сто десять ' ,
5853 );
5954
60- $ this ->testDigits ($ result );
55+ $ this ->runTestDigits ($ result );
6156 }
6257
6358 /**
64- * Testing the translation of numbers to text equivalent .
59+ * English localization testing .
6560 *
6661 * @author Andrey Helldar <helldar@ai-rus.com>
6762 *
6863 * @version 2016-11-28
6964 *
7065 * @since 1.0
71- *
72- * @param array $items
7366 */
74- public function testDigits ( $ items = array () )
67+ public function testEn ( )
7568 {
76- foreach ($ items as $ key => $ result ) {
77- $ this ->assertEquals ($ result , $ key );
78- }
69+ $ result = array (
70+ $ this ->object ->get () => 'zero ' ,
71+ $ this ->object ->get (64.23 , 'en ' , true ) => 'sixty four dollars 23 cents ' ,
72+ $ this ->object ->get (764 ) => 'seven hundred sixty four ' ,
73+ $ this ->object ->get (2866 ) => 'two thousands eight hundred sixty six ' ,
74+ $ this ->object ->get (7700 ) => 'seven thousands seven hundred ' ,
75+ $ this ->object ->get ('10,000 ' ) => 'ten thousands ' ,
76+ $ this ->object ->get (14383 ) => 'fourteen thousands three hundred eighty three ' ,
77+ $ this ->object ->get (20383 ) => 'twenty thousands three hundred eighty three ' ,
78+ $ this ->object ->get (700383 ) => 'seven hundred thousands three hundred eighty three ' ,
79+ $ this ->object ->get (7644383 ) => 'seven million six hundred forty four thousands three hundred eighty three ' ,
80+ $ this ->object ->get (70043783.65 , 'en ' , true ) => 'seventy million forty three thousands seven hundred eighty three dollars 65 cents ' ,
81+ $ this ->object ->get (786443783 ) => 'seven hundred eighty six million four hundred forty three thousands seven hundred eighty three ' ,
82+ $ this ->object ->get (109 ) => 'one hundred nine ' ,
83+ $ this ->object ->get (110 ) => 'one hundred ten ' ,
84+ $ this ->object ->get (111 ) => 'one hundred eleven ' ,
85+ $ this ->object ->get (112 ) => 'one hundred twelve ' ,
86+ $ this ->object ->get (115 ) => 'one hundred fifteen ' ,
87+ $ this ->object ->get (116 ) => 'one hundred sixteen ' ,
88+ $ this ->object ->get (118 ) => 'one hundred eighteen ' ,
89+ $ this ->object ->get (120 ) => 'one hundred twenty ' ,
90+ $ this ->object ->get (121 ) => 'one hundred twenty one ' ,
91+ $ this ->object ->get (10010 ) => 'ten thousands ten ' ,
92+ $ this ->object ->get (10110 ) => 'ten thousands one hundred ten ' ,
93+ $ this ->object ->get (510110 ) => 'five hundred ten thousands one hundred ten ' ,
94+ );
95+
96+ $ this ->runTestDigits ($ result );
7997 }
8098
8199 /**
82- * English localization testing .
100+ * Testing the translation of numbers to text equivalent .
83101 *
84102 * @author Andrey Helldar <helldar@ai-rus.com>
85103 *
86- * @version 2016-11-28
104+ * @since 2016-11-28
105+ * @since 2017-03-27
87106 *
88- * @since 1.0
107+ * @param array $items
89108 */
90- public function testEn ( )
109+ public function runTestDigits ( $ items = array () )
91110 {
92- $ result = array (
93- $ this ->object ->number () => 'zero ' ,
94- $ this ->object ->number (64.23 , 'en ' , true ) => 'sixty four dollars 23 cents ' ,
95- $ this ->object ->number (764 ) => 'seven hundred sixty four ' ,
96- $ this ->object ->number (2866 ) => 'two thousands eight hundred sixty six ' ,
97- $ this ->object ->number (7700 ) => 'seven thousands seven hundred ' ,
98- $ this ->object ->number ('10,000 ' ) => 'ten thousands ' ,
99- $ this ->object ->number (14383 ) => 'fourteen thousands three hundred eighty three ' ,
100- $ this ->object ->number (20383 ) => 'twenty thousands three hundred eighty three ' ,
101- $ this ->object ->number (700383 ) => 'seven hundred thousands three hundred eighty three ' ,
102- $ this ->object ->number (7644383 ) => 'seven million six hundred forty four thousands three hundred eighty three ' ,
103- $ this ->object ->number (70043783.65 , 'en ' , true ) => 'seventy million forty three thousands seven hundred eighty three dollars 65 cents ' ,
104- $ this ->object ->number (786443783 ) => 'seven hundred eighty six million four hundred forty three thousands seven hundred eighty three ' ,
105- $ this ->object ->number (109 ) => 'one hundred nine ' ,
106- $ this ->object ->number (110 ) => 'one hundred ten ' ,
107- $ this ->object ->number (111 ) => 'one hundred eleven ' ,
108- $ this ->object ->number (112 ) => 'one hundred twelve ' ,
109- $ this ->object ->number (115 ) => 'one hundred fifteen ' ,
110- $ this ->object ->number (116 ) => 'one hundred sixteen ' ,
111- $ this ->object ->number (118 ) => 'one hundred eighteen ' ,
112- $ this ->object ->number (120 ) => 'one hundred twenty ' ,
113- $ this ->object ->number (121 ) => 'one hundred twenty one ' ,
114- );
115-
116- $ this ->testDigits ($ result );
111+ foreach ($ items as $ key => $ result ) {
112+ $ this ->assertEquals ($ result , $ key );
113+ }
117114 }
118115
119116 /**
0 commit comments