diff options
Diffstat (limited to 'vendor/symfony/intl/Symfony/Component/Intl/Tests')
36 files changed, 4125 insertions, 0 deletions
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php new file mode 100644 index 00000000..08f3a566 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/AbstractCollatorTest.php | |||
@@ -0,0 +1,62 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\Collator; | ||
13 | |||
14 | use Symfony\Component\Intl\Collator\Collator; | ||
15 | use Symfony\Component\Intl\Locale; | ||
16 | |||
17 | /** | ||
18 | * Test case for Collator implementations. | ||
19 | * | ||
20 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
21 | */ | ||
22 | abstract class AbstractCollatorTest extends \PHPUnit_Framework_TestCase | ||
23 | { | ||
24 | /** | ||
25 | * @dataProvider asortProvider | ||
26 | */ | ||
27 | public function testAsort($array, $sortFlag, $expected) | ||
28 | { | ||
29 | $collator = $this->getCollator('en'); | ||
30 | $collator->asort($array, $sortFlag); | ||
31 | $this->assertSame($expected, $array); | ||
32 | } | ||
33 | |||
34 | public function asortProvider() | ||
35 | { | ||
36 | return array( | ||
37 | /* array, sortFlag, expected */ | ||
38 | array( | ||
39 | array('a', 'b', 'c'), | ||
40 | Collator::SORT_REGULAR, | ||
41 | array('a', 'b', 'c'), | ||
42 | ), | ||
43 | array( | ||
44 | array('c', 'b', 'a'), | ||
45 | Collator::SORT_REGULAR, | ||
46 | array(2 => 'a', 1 => 'b', 0 => 'c'), | ||
47 | ), | ||
48 | array( | ||
49 | array('b', 'c', 'a'), | ||
50 | Collator::SORT_REGULAR, | ||
51 | array(2 => 'a', 0 => 'b', 1 => 'c'), | ||
52 | ), | ||
53 | ); | ||
54 | } | ||
55 | |||
56 | /** | ||
57 | * @param string $locale | ||
58 | * | ||
59 | * @return \Collator | ||
60 | */ | ||
61 | abstract protected function getCollator($locale); | ||
62 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/CollatorTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/CollatorTest.php new file mode 100644 index 00000000..a4e4e56b --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/CollatorTest.php | |||
@@ -0,0 +1,109 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\Collator; | ||
13 | |||
14 | use Symfony\Component\Intl\Collator\Collator; | ||
15 | use Symfony\Component\Intl\Globals\IntlGlobals; | ||
16 | |||
17 | class CollatorTest extends AbstractCollatorTest | ||
18 | { | ||
19 | /** | ||
20 | * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException | ||
21 | */ | ||
22 | public function testConstructorWithUnsupportedLocale() | ||
23 | { | ||
24 | new Collator('pt_BR'); | ||
25 | } | ||
26 | |||
27 | /** | ||
28 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
29 | */ | ||
30 | public function testCompare() | ||
31 | { | ||
32 | $collator = $this->getCollator('en'); | ||
33 | $collator->compare('a', 'b'); | ||
34 | } | ||
35 | |||
36 | /** | ||
37 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
38 | */ | ||
39 | public function testGetAttribute() | ||
40 | { | ||
41 | $collator = $this->getCollator('en'); | ||
42 | $collator->getAttribute(Collator::NUMERIC_COLLATION); | ||
43 | } | ||
44 | |||
45 | public function testGetErrorCode() | ||
46 | { | ||
47 | $collator = $this->getCollator('en'); | ||
48 | $this->assertEquals(IntlGlobals::U_ZERO_ERROR, $collator->getErrorCode()); | ||
49 | } | ||
50 | |||
51 | public function testGetErrorMessage() | ||
52 | { | ||
53 | $collator = $this->getCollator('en'); | ||
54 | $this->assertEquals('U_ZERO_ERROR', $collator->getErrorMessage()); | ||
55 | } | ||
56 | |||
57 | public function testGetLocale() | ||
58 | { | ||
59 | $collator = $this->getCollator('en'); | ||
60 | $this->assertEquals('en', $collator->getLocale()); | ||
61 | } | ||
62 | |||
63 | /** | ||
64 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
65 | */ | ||
66 | public function testGetSortKey() | ||
67 | { | ||
68 | $collator = $this->getCollator('en'); | ||
69 | $collator->getSortKey('Hello'); | ||
70 | } | ||
71 | |||
72 | /** | ||
73 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
74 | */ | ||
75 | public function testGetStrength() | ||
76 | { | ||
77 | $collator = $this->getCollator('en'); | ||
78 | $collator->getStrength(); | ||
79 | } | ||
80 | |||
81 | /** | ||
82 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
83 | */ | ||
84 | public function testSetAttribute() | ||
85 | { | ||
86 | $collator = $this->getCollator('en'); | ||
87 | $collator->setAttribute(Collator::NUMERIC_COLLATION, Collator::ON); | ||
88 | } | ||
89 | |||
90 | /** | ||
91 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
92 | */ | ||
93 | public function testSetStrength() | ||
94 | { | ||
95 | $collator = $this->getCollator('en'); | ||
96 | $collator->setStrength(Collator::PRIMARY); | ||
97 | } | ||
98 | |||
99 | public function testStaticCreate() | ||
100 | { | ||
101 | $collator = Collator::create('en'); | ||
102 | $this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator); | ||
103 | } | ||
104 | |||
105 | protected function getCollator($locale) | ||
106 | { | ||
107 | return new Collator($locale); | ||
108 | } | ||
109 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php new file mode 100644 index 00000000..c8dbc131 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Collator/Verification/CollatorTest.php | |||
@@ -0,0 +1,37 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\Collator\Verification; | ||
13 | |||
14 | use Symfony\Component\Intl\Locale; | ||
15 | use Symfony\Component\Intl\Tests\Collator\AbstractCollatorTest; | ||
16 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
17 | |||
18 | /** | ||
19 | * Verifies that {@link AbstractCollatorTest} matches the behavior of the | ||
20 | * {@link \Collator} class in a specific version of ICU. | ||
21 | * | ||
22 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
23 | */ | ||
24 | class CollatorTest extends AbstractCollatorTest | ||
25 | { | ||
26 | protected function setUp() | ||
27 | { | ||
28 | IntlTestHelper::requireFullIntl($this); | ||
29 | |||
30 | parent::setUp(); | ||
31 | } | ||
32 | |||
33 | protected function getCollator($locale) | ||
34 | { | ||
35 | return new \Collator($locale); | ||
36 | } | ||
37 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php new file mode 100644 index 00000000..3ffb4909 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php | |||
@@ -0,0 +1,932 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\DateFormatter; | ||
13 | |||
14 | use Symfony\Component\Intl\DateFormatter\IntlDateFormatter; | ||
15 | use Symfony\Component\Intl\Globals\IntlGlobals; | ||
16 | use Symfony\Component\Intl\Intl; | ||
17 | |||
18 | /** | ||
19 | * Test case for IntlDateFormatter implementations. | ||
20 | * | ||
21 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
22 | */ | ||
23 | abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase | ||
24 | { | ||
25 | /** | ||
26 | * When a time zone is not specified, it uses the system default however it returns null in the getter method | ||
27 | * @covers Symfony\Component\Intl\DateFormatter\IntlDateFormatter::getTimeZoneId | ||
28 | * @see StubIntlDateFormatterTest::testDefaultTimeZoneIntl() | ||
29 | */ | ||
30 | public function testConstructorDefaultTimeZone() | ||
31 | { | ||
32 | $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT); | ||
33 | |||
34 | // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method | ||
35 | if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { | ||
36 | $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId()); | ||
37 | } else { | ||
38 | $this->assertNull($formatter->getTimeZoneId()); | ||
39 | } | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * @dataProvider formatProvider | ||
44 | */ | ||
45 | public function testFormat($pattern, $timestamp, $expected) | ||
46 | { | ||
47 | $errorCode = IntlGlobals::U_ZERO_ERROR; | ||
48 | $errorMessage = 'U_ZERO_ERROR'; | ||
49 | |||
50 | $formatter = $this->getDefaultDateFormatter($pattern); | ||
51 | $this->assertSame($expected, $formatter->format($timestamp)); | ||
52 | $this->assertIsIntlSuccess($formatter, $errorMessage, $errorCode); | ||
53 | } | ||
54 | |||
55 | public function formatProvider() | ||
56 | { | ||
57 | $formatData = array( | ||
58 | /* general */ | ||
59 | array('y-M-d', 0, '1970-1-1'), | ||
60 | array("EEE, MMM d, ''yy", 0, "Thu, Jan 1, '70"), | ||
61 | array('h:mm a', 0, '12:00 AM'), | ||
62 | array('yyyyy.MMMM.dd hh:mm aaa', 0, '01970.January.01 12:00 AM'), | ||
63 | |||
64 | /* escaping */ | ||
65 | array("'M'", 0, 'M'), | ||
66 | array("'yy'", 0, 'yy'), | ||
67 | array("'''yy'", 0, "'yy"), | ||
68 | array("''y", 0, "'1970"), | ||
69 | array("''yy", 0, "'70"), | ||
70 | array("H 'o'' clock'", 0, "0 o' clock"), | ||
71 | |||
72 | /* month */ | ||
73 | array('M', 0, '1'), | ||
74 | array('MM', 0, '01'), | ||
75 | array('MMM', 0, 'Jan'), | ||
76 | array('MMMM', 0, 'January'), | ||
77 | array('MMMMM', 0, 'J'), | ||
78 | array('MMMMMM', 0, '000001'), | ||
79 | |||
80 | array('L', 0, '1'), | ||
81 | array('LL', 0, '01'), | ||
82 | array('LLL', 0, 'Jan'), | ||
83 | array('LLLL', 0, 'January'), | ||
84 | array('LLLLL', 0, 'J'), | ||
85 | array('LLLLLL', 0, '000001'), | ||
86 | |||
87 | /* year */ | ||
88 | array('y', 0, '1970'), | ||
89 | array('yy', 0, '70'), | ||
90 | array('yyy', 0, '1970'), | ||
91 | array('yyyy', 0, '1970'), | ||
92 | array('yyyyy', 0, '01970'), | ||
93 | array('yyyyyy', 0, '001970'), | ||
94 | |||
95 | /* day */ | ||
96 | array('d', 0, '1'), | ||
97 | array('dd', 0, '01'), | ||
98 | array('ddd', 0, '001'), | ||
99 | |||
100 | /* quarter */ | ||
101 | array('Q', 0, '1'), | ||
102 | array('QQ', 0, '01'), | ||
103 | array('QQQ', 0, 'Q1'), | ||
104 | array('QQQQ', 0, '1st quarter'), | ||
105 | array('QQQQQ', 0, '1st quarter'), | ||
106 | |||
107 | array('q', 0, '1'), | ||
108 | array('qq', 0, '01'), | ||
109 | array('qqq', 0, 'Q1'), | ||
110 | array('qqqq', 0, '1st quarter'), | ||
111 | array('qqqqq', 0, '1st quarter'), | ||
112 | |||
113 | // 4 months | ||
114 | array('Q', 7776000, '2'), | ||
115 | array('QQ', 7776000, '02'), | ||
116 | array('QQQ', 7776000, 'Q2'), | ||
117 | array('QQQQ', 7776000, '2nd quarter'), | ||
118 | |||
119 | // 7 months | ||
120 | array('QQQQ', 15638400, '3rd quarter'), | ||
121 | |||
122 | // 10 months | ||
123 | array('QQQQ', 23587200, '4th quarter'), | ||
124 | |||
125 | /* 12-hour (1-12) */ | ||
126 | array('h', 0, '12'), | ||
127 | array('hh', 0, '12'), | ||
128 | array('hhh', 0, '012'), | ||
129 | |||
130 | array('h', 1, '12'), | ||
131 | array('h', 3600, '1'), | ||
132 | array('h', 43200, '12'), // 12 hours | ||
133 | |||
134 | /* day of year */ | ||
135 | array('D', 0, '1'), | ||
136 | array('D', 86400, '2'), // 1 day | ||
137 | array('D', 31536000, '1'), // 1 year | ||
138 | array('D', 31622400, '2'), // 1 year + 1 day | ||
139 | |||
140 | /* day of week */ | ||
141 | array('E', 0, 'Thu'), | ||
142 | array('EE', 0, 'Thu'), | ||
143 | array('EEE', 0, 'Thu'), | ||
144 | array('EEEE', 0, 'Thursday'), | ||
145 | array('EEEEE', 0, 'T'), | ||
146 | array('EEEEEE', 0, 'Thu'), | ||
147 | |||
148 | array('E', 1296540000, 'Tue'), // 2011-02-01 | ||
149 | array('E', 1296950400, 'Sun'), // 2011-02-06 | ||
150 | |||
151 | /* am/pm marker */ | ||
152 | array('a', 0, 'AM'), | ||
153 | array('aa', 0, 'AM'), | ||
154 | array('aaa', 0, 'AM'), | ||
155 | array('aaaa', 0, 'AM'), | ||
156 | |||
157 | // 12 hours | ||
158 | array('a', 43200, 'PM'), | ||
159 | array('aa', 43200, 'PM'), | ||
160 | array('aaa', 43200, 'PM'), | ||
161 | array('aaaa', 43200, 'PM'), | ||
162 | |||
163 | /* 24-hour (0-23) */ | ||
164 | array('H', 0, '0'), | ||
165 | array('HH', 0, '00'), | ||
166 | array('HHH', 0, '000'), | ||
167 | |||
168 | array('H', 1, '0'), | ||
169 | array('H', 3600, '1'), | ||
170 | array('H', 43200, '12'), | ||
171 | array('H', 46800, '13'), | ||
172 | |||
173 | /* 24-hour (1-24) */ | ||
174 | array('k', 0, '24'), | ||
175 | array('kk', 0, '24'), | ||
176 | array('kkk', 0, '024'), | ||
177 | |||
178 | array('k', 1, '24'), | ||
179 | array('k', 3600, '1'), | ||
180 | array('k', 43200, '12'), | ||
181 | array('k', 46800, '13'), | ||
182 | |||
183 | /* 12-hour (0-11) */ | ||
184 | array('K', 0, '0'), | ||
185 | array('KK', 0, '00'), | ||
186 | array('KKK', 0, '000'), | ||
187 | |||
188 | array('K', 1, '0'), | ||
189 | array('K', 3600, '1'), | ||
190 | array('K', 43200, '0'), // 12 hours | ||
191 | |||
192 | /* minute */ | ||
193 | array('m', 0, '0'), | ||
194 | array('mm', 0, '00'), | ||
195 | array('mmm', 0, '000'), | ||
196 | |||
197 | array('m', 1, '0'), | ||
198 | array('m', 60, '1'), | ||
199 | array('m', 120, '2'), | ||
200 | array('m', 180, '3'), | ||
201 | array('m', 3600, '0'), | ||
202 | array('m', 3660, '1'), | ||
203 | array('m', 43200, '0'), // 12 hours | ||
204 | |||
205 | /* second */ | ||
206 | array('s', 0, '0'), | ||
207 | array('ss', 0, '00'), | ||
208 | array('sss', 0, '000'), | ||
209 | |||
210 | array('s', 1, '1'), | ||
211 | array('s', 2, '2'), | ||
212 | array('s', 5, '5'), | ||
213 | array('s', 30, '30'), | ||
214 | array('s', 59, '59'), | ||
215 | array('s', 60, '0'), | ||
216 | array('s', 120, '0'), | ||
217 | array('s', 180, '0'), | ||
218 | array('s', 3600, '0'), | ||
219 | array('s', 3601, '1'), | ||
220 | array('s', 3630, '30'), | ||
221 | array('s', 43200, '0'), // 12 hours | ||
222 | |||
223 | // general | ||
224 | array("yyyy.MM.dd 'at' HH:mm:ss zzz", 0, '1970.01.01 at 00:00:00 GMT'), | ||
225 | array('K:mm a, z', 0, '0:00 AM, GMT'), | ||
226 | |||
227 | // timezone | ||
228 | array('z', 0, 'GMT'), | ||
229 | array('zz', 0, 'GMT'), | ||
230 | array('zzz', 0, 'GMT'), | ||
231 | array('zzzz', 0, 'GMT'), | ||
232 | array('zzzzz', 0, 'GMT'), | ||
233 | ); | ||
234 | |||
235 | // As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances | ||
236 | if (version_compare(PHP_VERSION, '5.3.4', '>=')) { | ||
237 | $dateTime = new \DateTime('@0'); | ||
238 | |||
239 | /* general, DateTime */ | ||
240 | $formatData[] = array('y-M-d', $dateTime, '1970-1-1'); | ||
241 | $formatData[] = array("EEE, MMM d, ''yy", $dateTime, "Thu, Jan 1, '70"); | ||
242 | $formatData[] = array('h:mm a', $dateTime, '12:00 AM'); | ||
243 | $formatData[] = array('yyyyy.MMMM.dd hh:mm aaa', $dateTime, '01970.January.01 12:00 AM'); | ||
244 | |||
245 | $formatData[] = array("yyyy.MM.dd 'at' HH:mm:ss zzz", $dateTime, '1970.01.01 at 00:00:00 GMT'); | ||
246 | $formatData[] = array('K:mm a, z', $dateTime, '0:00 AM, GMT'); | ||
247 | } | ||
248 | |||
249 | return $formatData; | ||
250 | } | ||
251 | |||
252 | /** | ||
253 | * @dataProvider formatErrorProvider | ||
254 | */ | ||
255 | public function testFormatIllegalArgumentError($pattern, $timestamp, $errorMessage) | ||
256 | { | ||
257 | $errorCode = IntlGlobals::U_ILLEGAL_ARGUMENT_ERROR; | ||
258 | |||
259 | $formatter = $this->getDefaultDateFormatter($pattern); | ||
260 | $this->assertFalse($formatter->format($timestamp)); | ||
261 | $this->assertIsIntlFailure($formatter, $errorMessage, $errorCode); | ||
262 | } | ||
263 | |||
264 | public function formatErrorProvider() | ||
265 | { | ||
266 | // With PHP 5.5 IntlDateFormatter accepts empty values ('0') | ||
267 | if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { | ||
268 | return array( | ||
269 | array('y-M-d', 'foobar', 'datefmt_format: string \'foobar\' is not numeric, which would be required for it to be a valid date: U_ILLEGAL_ARGUMENT_ERROR') | ||
270 | ); | ||
271 | } | ||
272 | |||
273 | $message = 'datefmt_format: takes either an array or an integer timestamp value : U_ILLEGAL_ARGUMENT_ERROR'; | ||
274 | |||
275 | if (version_compare(PHP_VERSION, '5.3.4', '>=')) { | ||
276 | $message = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object: U_ILLEGAL_ARGUMENT_ERROR'; | ||
277 | } | ||
278 | |||
279 | return array( | ||
280 | array('y-M-d', '0', $message), | ||
281 | array('y-M-d', 'foobar', $message), | ||
282 | ); | ||
283 | } | ||
284 | |||
285 | /** | ||
286 | * @dataProvider formatWithTimezoneProvider | ||
287 | */ | ||
288 | public function testFormatWithTimezone($timestamp, $timezone, $expected) | ||
289 | { | ||
290 | $pattern = 'yyyy-MM-dd HH:mm:ss'; | ||
291 | $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, $timezone, IntlDateFormatter::GREGORIAN, $pattern); | ||
292 | $this->assertSame($expected, $formatter->format($timestamp)); | ||
293 | } | ||
294 | |||
295 | public function formatWithTimezoneProvider() | ||
296 | { | ||
297 | $data = array( | ||
298 | array(0, 'UTC', '1970-01-01 00:00:00'), | ||
299 | array(0, 'GMT', '1970-01-01 00:00:00'), | ||
300 | array(0, 'GMT-03:00', '1969-12-31 21:00:00'), | ||
301 | array(0, 'GMT+03:00', '1970-01-01 03:00:00'), | ||
302 | array(0, 'Europe/Zurich', '1970-01-01 01:00:00'), | ||
303 | array(0, 'Europe/Paris', '1970-01-01 01:00:00'), | ||
304 | array(0, 'Africa/Cairo', '1970-01-01 02:00:00'), | ||
305 | array(0, 'Africa/Casablanca', '1970-01-01 00:00:00'), | ||
306 | array(0, 'Africa/Djibouti', '1970-01-01 03:00:00'), | ||
307 | array(0, 'Africa/Johannesburg', '1970-01-01 02:00:00'), | ||
308 | array(0, 'America/Antigua', '1969-12-31 20:00:00'), | ||
309 | array(0, 'America/Toronto', '1969-12-31 19:00:00'), | ||
310 | array(0, 'America/Vancouver', '1969-12-31 16:00:00'), | ||
311 | array(0, 'Asia/Aqtau', '1970-01-01 05:00:00'), | ||
312 | array(0, 'Asia/Bangkok', '1970-01-01 07:00:00'), | ||
313 | array(0, 'Asia/Dubai', '1970-01-01 04:00:00'), | ||
314 | array(0, 'Australia/Brisbane', '1970-01-01 10:00:00'), | ||
315 | array(0, 'Australia/Eucla', '1970-01-01 08:45:00'), | ||
316 | array(0, 'Australia/Melbourne', '1970-01-01 10:00:00'), | ||
317 | array(0, 'Europe/Berlin', '1970-01-01 01:00:00'), | ||
318 | array(0, 'Europe/Dublin', '1970-01-01 01:00:00'), | ||
319 | array(0, 'Europe/Warsaw', '1970-01-01 01:00:00'), | ||
320 | array(0, 'Pacific/Fiji', '1970-01-01 12:00:00'), | ||
321 | ); | ||
322 | |||
323 | // As of PHP 5.5, intl ext no longer fallbacks invalid time zones to UTC | ||
324 | if (!version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { | ||
325 | // When time zone not exists, uses UTC by default | ||
326 | $data[] = array(0, 'Foo/Bar', '1970-01-01 00:00:00'); | ||
327 | $data[] = array(0, 'UTC+04:30', '1970-01-01 00:00:00'); | ||
328 | $data[] = array(0, 'UTC+04:AA', '1970-01-01 00:00:00'); | ||
329 | } | ||
330 | |||
331 | return $data; | ||
332 | } | ||
333 | |||
334 | public function testFormatWithGmtTimezone() | ||
335 | { | ||
336 | $formatter = $this->getDefaultDateFormatter('zzzz'); | ||
337 | |||
338 | if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { | ||
339 | $formatter->setTimeZone('GMT+03:00'); | ||
340 | } else { | ||
341 | $formatter->setTimeZoneId('GMT+03:00'); | ||
342 | } | ||
343 | |||
344 | $this->assertEquals('GMT+03:00', $formatter->format(0)); | ||
345 | } | ||
346 | |||
347 | public function testFormatWithGmtTimeZoneAndMinutesOffset() | ||
348 | { | ||
349 | $formatter = $this->getDefaultDateFormatter('zzzz'); | ||
350 | |||
351 | if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { | ||
352 | $formatter->setTimeZone('GMT+00:30'); | ||
353 | } else { | ||
354 | $formatter->setTimeZoneId('GMT+00:30'); | ||
355 | } | ||
356 | |||
357 | $this->assertEquals('GMT+00:30', $formatter->format(0)); | ||
358 | } | ||
359 | |||
360 | public function testFormatWithNonStandardTimezone() | ||
361 | { | ||
362 | $formatter = $this->getDefaultDateFormatter('zzzz'); | ||
363 | |||
364 | if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { | ||
365 | $formatter->setTimeZone('Pacific/Fiji'); | ||
366 | } else { | ||
367 | $formatter->setTimeZoneId('Pacific/Fiji'); | ||
368 | } | ||
369 | |||
370 | $this->assertEquals('Fiji Standard Time', $formatter->format(0)); | ||
371 | } | ||
372 | |||
373 | public function testFormatWithConstructorTimezone() | ||
374 | { | ||
375 | $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC'); | ||
376 | $formatter->setPattern('yyyy-MM-dd HH:mm:ss'); | ||
377 | |||
378 | $this->assertEquals( | ||
379 | $this->getDateTime(0)->format('Y-m-d H:i:s'), | ||
380 | $formatter->format(0) | ||
381 | ); | ||
382 | } | ||
383 | |||
384 | public function testFormatWithTimezoneFromEnvironmentVariable() | ||
385 | { | ||
386 | if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { | ||
387 | $this->markTestSkipped('IntlDateFormatter in PHP 5.5 no longer depends on TZ environment.'); | ||
388 | } | ||
389 | |||
390 | $tz = getenv('TZ'); | ||
391 | putenv('TZ=Europe/London'); | ||
392 | |||
393 | $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT); | ||
394 | $formatter->setPattern('yyyy-MM-dd HH:mm:ss'); | ||
395 | |||
396 | $this->assertEquals( | ||
397 | $this->getDateTime(0)->format('Y-m-d H:i:s'), | ||
398 | $formatter->format(0) | ||
399 | ); | ||
400 | |||
401 | $this->assertEquals('Europe/London', getenv('TZ')); | ||
402 | |||
403 | // Restores TZ. | ||
404 | putenv('TZ='.$tz); | ||
405 | } | ||
406 | |||
407 | public function testFormatWithTimezoneFromPhp() | ||
408 | { | ||
409 | if (!version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { | ||
410 | $this->markTestSkipped('Only in PHP 5.5 IntlDateFormatter depends on default timezone (`date_default_timezone_get()`).'); | ||
411 | } | ||
412 | |||
413 | $tz = date_default_timezone_get(); | ||
414 | date_default_timezone_set('Europe/London'); | ||
415 | |||
416 | $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT); | ||
417 | $formatter->setPattern('yyyy-MM-dd HH:mm:ss'); | ||
418 | |||
419 | $this->assertEquals( | ||
420 | $this->getDateTime(0)->format('Y-m-d H:i:s'), | ||
421 | $formatter->format(0) | ||
422 | ); | ||
423 | |||
424 | $this->assertEquals('Europe/London', date_default_timezone_get()); | ||
425 | |||
426 | // Restores TZ. | ||
427 | date_default_timezone_set($tz); | ||
428 | } | ||
429 | |||
430 | /** | ||
431 | * @dataProvider dateAndTimeTypeProvider | ||
432 | */ | ||
433 | public function testDateAndTimeType($timestamp, $datetype, $timetype, $expected) | ||
434 | { | ||
435 | $formatter = $this->getDateFormatter('en', $datetype, $timetype, 'UTC'); | ||
436 | $this->assertSame($expected, $formatter->format($timestamp)); | ||
437 | } | ||
438 | |||
439 | public function dateAndTimeTypeProvider() | ||
440 | { | ||
441 | return array( | ||
442 | array(0, IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'Thursday, January 1, 1970'), | ||
443 | array(0, IntlDateFormatter::LONG, IntlDateFormatter::NONE, 'January 1, 1970'), | ||
444 | array(0, IntlDateFormatter::MEDIUM, IntlDateFormatter::NONE, 'Jan 1, 1970'), | ||
445 | array(0, IntlDateFormatter::SHORT, IntlDateFormatter::NONE, '1/1/70'), | ||
446 | array(0, IntlDateFormatter::NONE, IntlDateFormatter::FULL, '12:00:00 AM GMT'), | ||
447 | array(0, IntlDateFormatter::NONE, IntlDateFormatter::LONG, '12:00:00 AM GMT'), | ||
448 | array(0, IntlDateFormatter::NONE, IntlDateFormatter::MEDIUM, '12:00:00 AM'), | ||
449 | array(0, IntlDateFormatter::NONE, IntlDateFormatter::SHORT, '12:00 AM'), | ||
450 | ); | ||
451 | } | ||
452 | |||
453 | public function testGetCalendar() | ||
454 | { | ||
455 | $formatter = $this->getDefaultDateFormatter(); | ||
456 | $this->assertEquals(IntlDateFormatter::GREGORIAN, $formatter->getCalendar()); | ||
457 | } | ||
458 | |||
459 | public function testGetDateType() | ||
460 | { | ||
461 | $formatter = $this->getDateFormatter('en', IntlDateFormatter::FULL, IntlDateFormatter::NONE); | ||
462 | $this->assertEquals(IntlDateFormatter::FULL, $formatter->getDateType()); | ||
463 | } | ||
464 | |||
465 | public function testGetLocale() | ||
466 | { | ||
467 | $formatter = $this->getDefaultDateFormatter(); | ||
468 | $this->assertEquals('en', $formatter->getLocale()); | ||
469 | } | ||
470 | |||
471 | public function testGetPattern() | ||
472 | { | ||
473 | $formatter = $this->getDateFormatter('en', IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'UTC', IntlDateFormatter::GREGORIAN, 'yyyy-MM-dd'); | ||
474 | $this->assertEquals('yyyy-MM-dd', $formatter->getPattern()); | ||
475 | } | ||
476 | |||
477 | public function testGetTimeType() | ||
478 | { | ||
479 | $formatter = $this->getDateFormatter('en', IntlDateFormatter::NONE, IntlDateFormatter::FULL); | ||
480 | $this->assertEquals(IntlDateFormatter::FULL, $formatter->getTimeType()); | ||
481 | } | ||
482 | |||
483 | /** | ||
484 | * @dataProvider parseProvider | ||
485 | */ | ||
486 | public function testParse($pattern, $value, $expected) | ||
487 | { | ||
488 | $errorCode = IntlGlobals::U_ZERO_ERROR; | ||
489 | $errorMessage = 'U_ZERO_ERROR'; | ||
490 | |||
491 | $formatter = $this->getDefaultDateFormatter($pattern); | ||
492 | $this->assertSame($expected, $formatter->parse($value)); | ||
493 | $this->assertIsIntlSuccess($formatter, $errorMessage, $errorCode); | ||
494 | } | ||
495 | |||
496 | public function parseProvider() | ||
497 | { | ||
498 | return array_merge( | ||
499 | $this->parseYearProvider(), | ||
500 | $this->parseQuarterProvider(), | ||
501 | $this->parseMonthProvider(), | ||
502 | $this->parseStandaloneMonthProvider(), | ||
503 | $this->parseDayProvider(), | ||
504 | $this->parseDayOfWeekProvider(), | ||
505 | $this->parseDayOfYearProvider(), | ||
506 | $this->parseHour12ClockOneBasedProvider(), | ||
507 | $this->parseHour12ClockZeroBasedProvider(), | ||
508 | $this->parseHour24ClockOneBasedProvider(), | ||
509 | $this->parseHour24ClockZeroBasedProvider(), | ||
510 | $this->parseMinuteProvider(), | ||
511 | $this->parseSecondProvider(), | ||
512 | $this->parseTimezoneProvider(), | ||
513 | $this->parseAmPmProvider(), | ||
514 | $this->parseStandaloneAmPmProvider(), | ||
515 | $this->parseRegexMetaCharsProvider(), | ||
516 | $this->parseQuoteCharsProvider(), | ||
517 | $this->parseDashSlashProvider() | ||
518 | ); | ||
519 | } | ||
520 | |||
521 | public function parseYearProvider() | ||
522 | { | ||
523 | return array( | ||
524 | array('y-M-d', '1970-1-1', 0), | ||
525 | array('yy-M-d', '70-1-1', 0), | ||
526 | ); | ||
527 | } | ||
528 | |||
529 | public function parseQuarterProvider() | ||
530 | { | ||
531 | return array( | ||
532 | array('Q', '1', 0), | ||
533 | array('QQ', '01', 0), | ||
534 | array('QQQ', 'Q1', 0), | ||
535 | array('QQQQ', '1st quarter', 0), | ||
536 | array('QQQQQ', '1st quarter', 0), | ||
537 | |||
538 | array('Q', '2', 7776000), | ||
539 | array('QQ', '02', 7776000), | ||
540 | array('QQQ', 'Q2', 7776000), | ||
541 | array('QQQQ', '2nd quarter', 7776000), | ||
542 | array('QQQQQ', '2nd quarter', 7776000), | ||
543 | |||
544 | array('q', '1', 0), | ||
545 | array('qq', '01', 0), | ||
546 | array('qqq', 'Q1', 0), | ||
547 | array('qqqq', '1st quarter', 0), | ||
548 | array('qqqqq', '1st quarter', 0), | ||
549 | ); | ||
550 | } | ||
551 | |||
552 | public function parseMonthProvider() | ||
553 | { | ||
554 | return array( | ||
555 | array('y-M-d', '1970-1-1', 0), | ||
556 | array('y-MMM-d', '1970-Jan-1', 0), | ||
557 | array('y-MMMM-d', '1970-January-1', 0), | ||
558 | ); | ||
559 | } | ||
560 | |||
561 | public function parseStandaloneMonthProvider() | ||
562 | { | ||
563 | return array( | ||
564 | array('y-L-d', '1970-1-1', 0), | ||
565 | array('y-LLL-d', '1970-Jan-1', 0), | ||
566 | array('y-LLLL-d', '1970-January-1', 0), | ||
567 | ); | ||
568 | } | ||
569 | |||
570 | public function parseDayProvider() | ||
571 | { | ||
572 | return array( | ||
573 | array('y-M-d', '1970-1-1', 0), | ||
574 | array('y-M-dd', '1970-1-01', 0), | ||
575 | array('y-M-ddd', '1970-1-001', 0), | ||
576 | ); | ||
577 | } | ||
578 | |||
579 | public function parseDayOfWeekProvider() | ||
580 | { | ||
581 | return array( | ||
582 | array('E', 'Thu', 0), | ||
583 | array('EE', 'Thu', 0), | ||
584 | array('EEE', 'Thu', 0), | ||
585 | array('EEEE', 'Thursday', 0), | ||
586 | array('EEEEE', 'T', 432000), | ||
587 | array('EEEEEE', 'Thu', 0), | ||
588 | ); | ||
589 | } | ||
590 | |||
591 | public function parseDayOfYearProvider() | ||
592 | { | ||
593 | return array( | ||
594 | array('D', '1', 0), | ||
595 | array('D', '2', 86400), | ||
596 | ); | ||
597 | } | ||
598 | |||
599 | public function parseHour12ClockOneBasedProvider() | ||
600 | { | ||
601 | return array( | ||
602 | // 12 hours (1-12) | ||
603 | array('y-M-d h', '1970-1-1 1', 3600), | ||
604 | array('y-M-d h', '1970-1-1 10', 36000), | ||
605 | array('y-M-d hh', '1970-1-1 11', 39600), | ||
606 | array('y-M-d hh', '1970-1-1 12', 0), | ||
607 | array('y-M-d hh a', '1970-1-1 0 AM', 0), | ||
608 | array('y-M-d hh a', '1970-1-1 1 AM', 3600), | ||
609 | array('y-M-d hh a', '1970-1-1 10 AM', 36000), | ||
610 | array('y-M-d hh a', '1970-1-1 11 AM', 39600), | ||
611 | array('y-M-d hh a', '1970-1-1 12 AM', 0), | ||
612 | array('y-M-d hh a', '1970-1-1 23 AM', 82800), | ||
613 | array('y-M-d hh a', '1970-1-1 24 AM', 86400), | ||
614 | array('y-M-d hh a', '1970-1-1 0 PM', 43200), | ||
615 | array('y-M-d hh a', '1970-1-1 1 PM', 46800), | ||
616 | array('y-M-d hh a', '1970-1-1 10 PM', 79200), | ||
617 | array('y-M-d hh a', '1970-1-1 11 PM', 82800), | ||
618 | array('y-M-d hh a', '1970-1-1 12 PM', 43200), | ||
619 | array('y-M-d hh a', '1970-1-1 23 PM', 126000), | ||
620 | array('y-M-d hh a', '1970-1-1 24 PM', 129600), | ||
621 | ); | ||
622 | } | ||
623 | |||
624 | public function parseHour12ClockZeroBasedProvider() | ||
625 | { | ||
626 | return array( | ||
627 | // 12 hours (0-11) | ||
628 | array('y-M-d K', '1970-1-1 1', 3600), | ||
629 | array('y-M-d K', '1970-1-1 10', 36000), | ||
630 | array('y-M-d KK', '1970-1-1 11', 39600), | ||
631 | array('y-M-d KK', '1970-1-1 12', 43200), | ||
632 | array('y-M-d KK a', '1970-1-1 0 AM', 0), | ||
633 | array('y-M-d KK a', '1970-1-1 1 AM', 3600), | ||
634 | array('y-M-d KK a', '1970-1-1 10 AM', 36000), | ||
635 | array('y-M-d KK a', '1970-1-1 11 AM', 39600), | ||
636 | array('y-M-d KK a', '1970-1-1 12 AM', 43200), | ||
637 | array('y-M-d KK a', '1970-1-1 23 AM', 82800), | ||
638 | array('y-M-d KK a', '1970-1-1 24 AM', 86400), | ||
639 | array('y-M-d KK a', '1970-1-1 0 PM', 43200), | ||
640 | array('y-M-d KK a', '1970-1-1 1 PM', 46800), | ||
641 | array('y-M-d KK a', '1970-1-1 10 PM', 79200), | ||
642 | array('y-M-d KK a', '1970-1-1 11 PM', 82800), | ||
643 | array('y-M-d KK a', '1970-1-1 12 PM', 86400), | ||
644 | array('y-M-d KK a', '1970-1-1 23 PM', 126000), | ||
645 | array('y-M-d KK a', '1970-1-1 24 PM', 129600), | ||
646 | ); | ||
647 | } | ||
648 | |||
649 | public function parseHour24ClockOneBasedProvider() | ||
650 | { | ||
651 | return array( | ||
652 | // 24 hours (1-24) | ||
653 | array('y-M-d k', '1970-1-1 1', 3600), | ||
654 | array('y-M-d k', '1970-1-1 10', 36000), | ||
655 | array('y-M-d kk', '1970-1-1 11', 39600), | ||
656 | array('y-M-d kk', '1970-1-1 12', 43200), | ||
657 | array('y-M-d kk', '1970-1-1 23', 82800), | ||
658 | array('y-M-d kk', '1970-1-1 24', 0), | ||
659 | array('y-M-d kk a', '1970-1-1 0 AM', 0), | ||
660 | array('y-M-d kk a', '1970-1-1 1 AM', 0), | ||
661 | array('y-M-d kk a', '1970-1-1 10 AM', 0), | ||
662 | array('y-M-d kk a', '1970-1-1 11 AM', 0), | ||
663 | array('y-M-d kk a', '1970-1-1 12 AM', 0), | ||
664 | array('y-M-d kk a', '1970-1-1 23 AM', 0), | ||
665 | array('y-M-d kk a', '1970-1-1 24 AM', 0), | ||
666 | array('y-M-d kk a', '1970-1-1 0 PM', 43200), | ||
667 | array('y-M-d kk a', '1970-1-1 1 PM', 43200), | ||
668 | array('y-M-d kk a', '1970-1-1 10 PM', 43200), | ||
669 | array('y-M-d kk a', '1970-1-1 11 PM', 43200), | ||
670 | array('y-M-d kk a', '1970-1-1 12 PM', 43200), | ||
671 | array('y-M-d kk a', '1970-1-1 23 PM', 43200), | ||
672 | array('y-M-d kk a', '1970-1-1 24 PM', 43200), | ||
673 | ); | ||
674 | } | ||
675 | |||
676 | public function parseHour24ClockZeroBasedProvider() | ||
677 | { | ||
678 | return array( | ||
679 | // 24 hours (0-23) | ||
680 | array('y-M-d H', '1970-1-1 0', 0), | ||
681 | array('y-M-d H', '1970-1-1 1', 3600), | ||
682 | array('y-M-d H', '1970-1-1 10', 36000), | ||
683 | array('y-M-d HH', '1970-1-1 11', 39600), | ||
684 | array('y-M-d HH', '1970-1-1 12', 43200), | ||
685 | array('y-M-d HH', '1970-1-1 23', 82800), | ||
686 | array('y-M-d HH a', '1970-1-1 0 AM', 0), | ||
687 | array('y-M-d HH a', '1970-1-1 1 AM', 0), | ||
688 | array('y-M-d HH a', '1970-1-1 10 AM', 0), | ||
689 | array('y-M-d HH a', '1970-1-1 11 AM', 0), | ||
690 | array('y-M-d HH a', '1970-1-1 12 AM', 0), | ||
691 | array('y-M-d HH a', '1970-1-1 23 AM', 0), | ||
692 | array('y-M-d HH a', '1970-1-1 24 AM', 0), | ||
693 | array('y-M-d HH a', '1970-1-1 0 PM', 43200), | ||
694 | array('y-M-d HH a', '1970-1-1 1 PM', 43200), | ||
695 | array('y-M-d HH a', '1970-1-1 10 PM', 43200), | ||
696 | array('y-M-d HH a', '1970-1-1 11 PM', 43200), | ||
697 | array('y-M-d HH a', '1970-1-1 12 PM', 43200), | ||
698 | array('y-M-d HH a', '1970-1-1 23 PM', 43200), | ||
699 | array('y-M-d HH a', '1970-1-1 24 PM', 43200), | ||
700 | ); | ||
701 | } | ||
702 | |||
703 | public function parseMinuteProvider() | ||
704 | { | ||
705 | return array( | ||
706 | array('y-M-d HH:m', '1970-1-1 0:1', 60), | ||
707 | array('y-M-d HH:mm', '1970-1-1 0:10', 600), | ||
708 | ); | ||
709 | } | ||
710 | |||
711 | public function parseSecondProvider() | ||
712 | { | ||
713 | return array( | ||
714 | array('y-M-d HH:mm:s', '1970-1-1 00:01:1', 61), | ||
715 | array('y-M-d HH:mm:ss', '1970-1-1 00:01:10', 70), | ||
716 | ); | ||
717 | } | ||
718 | |||
719 | public function parseTimezoneProvider() | ||
720 | { | ||
721 | return array( | ||
722 | array('y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT-03:00', 10800), | ||
723 | array('y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT-04:00', 14400), | ||
724 | array('y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT-00:00', 0), | ||
725 | array('y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT+03:00', -10800), | ||
726 | array('y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT+04:00', -14400), | ||
727 | array('y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT-0300', 10800), | ||
728 | array('y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT+0300', -10800), | ||
729 | |||
730 | // a previous timezone parsing should not change the timezone for the next parsing | ||
731 | array('y-M-d HH:mm:ss', '1970-1-1 00:00:00', 0), | ||
732 | ); | ||
733 | } | ||
734 | |||
735 | public function parseAmPmProvider() | ||
736 | { | ||
737 | return array( | ||
738 | // AM/PM (already covered by hours tests) | ||
739 | array('y-M-d HH:mm:ss a', '1970-1-1 00:00:00 AM', 0), | ||
740 | array('y-M-d HH:mm:ss a', '1970-1-1 00:00:00 PM', 43200), | ||
741 | ); | ||
742 | } | ||
743 | |||
744 | public function parseStandaloneAmPmProvider() | ||
745 | { | ||
746 | return array( | ||
747 | array('a', 'AM', 0), | ||
748 | array('a', 'PM', 43200), | ||
749 | ); | ||
750 | } | ||
751 | |||
752 | public function parseRegexMetaCharsProvider() | ||
753 | { | ||
754 | return array( | ||
755 | // regexp meta chars in the pattern string | ||
756 | array('y[M-d', '1970[1-1', 0), | ||
757 | array('y[M/d', '1970[1/1', 0), | ||
758 | ); | ||
759 | } | ||
760 | |||
761 | public function parseQuoteCharsProvider() | ||
762 | { | ||
763 | return array( | ||
764 | array("'M'", 'M', 0), | ||
765 | array("'yy'", 'yy', 0), | ||
766 | array("'''yy'", "'yy", 0), | ||
767 | array("''y", "'1970", 0), | ||
768 | array("H 'o'' clock'", "0 o' clock", 0), | ||
769 | ); | ||
770 | } | ||
771 | |||
772 | public function parseDashSlashProvider() | ||
773 | { | ||
774 | return array( | ||
775 | array('y-M-d', '1970/1/1', 0), | ||
776 | array('yy-M-d', '70/1/1', 0), | ||
777 | array('y/M/d', '1970-1-1', 0), | ||
778 | array('yy/M/d', '70-1-1', 0), | ||
779 | ); | ||
780 | } | ||
781 | |||
782 | /** | ||
783 | * @dataProvider parseErrorProvider | ||
784 | */ | ||
785 | public function testParseError($pattern, $value) | ||
786 | { | ||
787 | $errorCode = IntlGlobals::U_PARSE_ERROR; | ||
788 | $errorMessage = 'Date parsing failed: U_PARSE_ERROR'; | ||
789 | |||
790 | $formatter = $this->getDefaultDateFormatter($pattern); | ||
791 | $this->assertFalse($formatter->parse($value)); | ||
792 | $this->assertIsIntlFailure($formatter, $errorMessage, $errorCode); | ||
793 | } | ||
794 | |||
795 | public function parseErrorProvider() | ||
796 | { | ||
797 | return array( | ||
798 | // 1 char month | ||
799 | array('y-MMMMM-d', '1970-J-1'), | ||
800 | array('y-MMMMM-d', '1970-S-1'), | ||
801 | |||
802 | // standalone 1 char month | ||
803 | array('y-LLLLL-d', '1970-J-1'), | ||
804 | array('y-LLLLL-d', '1970-S-1'), | ||
805 | ); | ||
806 | } | ||
807 | |||
808 | /* | ||
809 | * https://github.com/symfony/symfony/issues/4242 | ||
810 | */ | ||
811 | public function testParseAfterError() | ||
812 | { | ||
813 | $this->testParseError('y-MMMMM-d', '1970-J-1'); | ||
814 | $this->testParse('y-M-d', '1970-1-1', 0); | ||
815 | } | ||
816 | |||
817 | public function testParseWithNullPositionValue() | ||
818 | { | ||
819 | $position = null; | ||
820 | $formatter = $this->getDefaultDateFormatter('y'); | ||
821 | $this->assertSame(0, $formatter->parse('1970', $position)); | ||
822 | $this->assertNull($position); | ||
823 | } | ||
824 | |||
825 | public function testSetPattern() | ||
826 | { | ||
827 | $formatter = $this->getDefaultDateFormatter(); | ||
828 | $formatter->setPattern('yyyy-MM-dd'); | ||
829 | $this->assertEquals('yyyy-MM-dd', $formatter->getPattern()); | ||
830 | } | ||
831 | |||
832 | /** | ||
833 | * @covers Symfony\Component\Intl\DateFormatter\IntlDateFormatter::getTimeZoneId | ||
834 | * @dataProvider setTimeZoneIdProvider | ||
835 | */ | ||
836 | public function testSetTimeZoneId($timeZoneId, $expectedTimeZoneId) | ||
837 | { | ||
838 | $formatter = $this->getDefaultDateFormatter(); | ||
839 | |||
840 | if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { | ||
841 | $formatter->setTimeZone($timeZoneId); | ||
842 | } else { | ||
843 | $formatter->setTimeZoneId($timeZoneId); | ||
844 | } | ||
845 | |||
846 | $this->assertEquals($expectedTimeZoneId, $formatter->getTimeZoneId()); | ||
847 | } | ||
848 | |||
849 | public function setTimeZoneIdProvider() | ||
850 | { | ||
851 | return array( | ||
852 | array('UTC', 'UTC'), | ||
853 | array('GMT', 'GMT'), | ||
854 | array('GMT-03:00', 'GMT-03:00'), | ||
855 | array('Europe/Zurich', 'Europe/Zurich'), | ||
856 | array('GMT-0300', 'GMT-0300'), | ||
857 | array('Foo/Bar', 'Foo/Bar'), | ||
858 | array('GMT+00:AA', 'GMT+00:AA'), | ||
859 | array('GMT+00AA', 'GMT+00AA'), | ||
860 | ); | ||
861 | } | ||
862 | |||
863 | protected function getDefaultDateFormatter($pattern = null) | ||
864 | { | ||
865 | return $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN, $pattern); | ||
866 | } | ||
867 | |||
868 | protected function getDateTime($timestamp = null) | ||
869 | { | ||
870 | if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { | ||
871 | $timeZone = date_default_timezone_get(); | ||
872 | } else { | ||
873 | $timeZone = getenv('TZ') ?: 'UTC'; | ||
874 | } | ||
875 | |||
876 | $dateTime = new \DateTime(); | ||
877 | $dateTime->setTimestamp(null === $timestamp ? time() : $timestamp); | ||
878 | $dateTime->setTimeZone(new \DateTimeZone($timeZone)); | ||
879 | |||
880 | return $dateTime; | ||
881 | } | ||
882 | |||
883 | protected function assertIsIntlFailure($formatter, $errorMessage, $errorCode) | ||
884 | { | ||
885 | $this->assertSame($errorMessage, $this->getIntlErrorMessage()); | ||
886 | $this->assertSame($errorCode, $this->getIntlErrorCode()); | ||
887 | $this->assertTrue($this->isIntlFailure($this->getIntlErrorCode())); | ||
888 | $this->assertSame($errorMessage, $formatter->getErrorMessage()); | ||
889 | $this->assertSame($errorCode, $formatter->getErrorCode()); | ||
890 | $this->assertTrue($this->isIntlFailure($formatter->getErrorCode())); | ||
891 | } | ||
892 | |||
893 | protected function assertIsIntlSuccess($formatter, $errorMessage, $errorCode) | ||
894 | { | ||
895 | /* @var IntlDateFormatter $formatter */ | ||
896 | $this->assertSame($errorMessage, $this->getIntlErrorMessage()); | ||
897 | $this->assertSame($errorCode, $this->getIntlErrorCode()); | ||
898 | $this->assertFalse($this->isIntlFailure($this->getIntlErrorCode())); | ||
899 | $this->assertSame($errorMessage, $formatter->getErrorMessage()); | ||
900 | $this->assertSame($errorCode, $formatter->getErrorCode()); | ||
901 | $this->assertFalse($this->isIntlFailure($formatter->getErrorCode())); | ||
902 | } | ||
903 | |||
904 | /** | ||
905 | * @param $locale | ||
906 | * @param $datetype | ||
907 | * @param $timetype | ||
908 | * @param null $timezone | ||
909 | * @param int $calendar | ||
910 | * @param null $pattern | ||
911 | * | ||
912 | * @return mixed | ||
913 | */ | ||
914 | abstract protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null); | ||
915 | |||
916 | /** | ||
917 | * @return string | ||
918 | */ | ||
919 | abstract protected function getIntlErrorMessage(); | ||
920 | |||
921 | /** | ||
922 | * @return integer | ||
923 | */ | ||
924 | abstract protected function getIntlErrorCode(); | ||
925 | |||
926 | /** | ||
927 | * @param integer $errorCode | ||
928 | * | ||
929 | * @return Boolean | ||
930 | */ | ||
931 | abstract protected function isIntlFailure($errorCode); | ||
932 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php new file mode 100644 index 00000000..d7227aeb --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php | |||
@@ -0,0 +1,220 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\DateFormatter; | ||
13 | |||
14 | use Symfony\Component\Intl\DateFormatter\IntlDateFormatter; | ||
15 | use Symfony\Component\Intl\Globals\IntlGlobals; | ||
16 | |||
17 | class IntlDateFormatterTest extends AbstractIntlDateFormatterTest | ||
18 | { | ||
19 | public function testConstructor() | ||
20 | { | ||
21 | $formatter = new IntlDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN, 'y-M-d'); | ||
22 | $this->assertEquals('y-M-d', $formatter->getPattern()); | ||
23 | } | ||
24 | |||
25 | /** | ||
26 | * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException | ||
27 | */ | ||
28 | public function testConstructorWithUnsupportedLocale() | ||
29 | { | ||
30 | new IntlDateFormatter('pt_BR', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT); | ||
31 | } | ||
32 | |||
33 | public function testStaticCreate() | ||
34 | { | ||
35 | $formatter = IntlDateFormatter::create('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT); | ||
36 | $this->assertInstanceOf('\Symfony\Component\Intl\DateFormatter\IntlDateFormatter', $formatter); | ||
37 | } | ||
38 | |||
39 | public function testFormatWithUnsupportedTimestampArgument() | ||
40 | { | ||
41 | $formatter = $this->getDefaultDateFormatter(); | ||
42 | |||
43 | $localtime = array( | ||
44 | 'tm_sec' => 59, | ||
45 | 'tm_min' => 3, | ||
46 | 'tm_hour' => 15, | ||
47 | 'tm_mday' => 15, | ||
48 | 'tm_mon' => 3, | ||
49 | 'tm_year' => 112, | ||
50 | 'tm_wday' => 0, | ||
51 | 'tm_yday' => 105, | ||
52 | 'tm_isdst' => 0 | ||
53 | ); | ||
54 | |||
55 | try { | ||
56 | $formatter->format($localtime); | ||
57 | } catch (\Exception $e) { | ||
58 | $this->assertInstanceOf('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException', $e); | ||
59 | |||
60 | if (version_compare(PHP_VERSION, '5.3.4', '>=')) { | ||
61 | $this->assertStringEndsWith('Only integer unix timestamps and DateTime objects are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage()); | ||
62 | } else { | ||
63 | $this->assertStringEndsWith('Only integer unix timestamps are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage()); | ||
64 | } | ||
65 | } | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException | ||
70 | */ | ||
71 | public function testFormatWithUnimplementedChars() | ||
72 | { | ||
73 | $pattern = 'Y'; | ||
74 | $formatter = new IntlDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', IntlDateFormatter::GREGORIAN, $pattern); | ||
75 | $formatter->format(0); | ||
76 | } | ||
77 | |||
78 | /** | ||
79 | * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException | ||
80 | */ | ||
81 | public function testFormatWithNonIntegerTimestamp() | ||
82 | { | ||
83 | $formatter = $this->getDefaultDateFormatter(); | ||
84 | $formatter->format(array()); | ||
85 | } | ||
86 | |||
87 | public function testGetErrorCode() | ||
88 | { | ||
89 | $formatter = $this->getDefaultDateFormatter(); | ||
90 | $this->assertEquals(IntlGlobals::getErrorCode(), $formatter->getErrorCode()); | ||
91 | } | ||
92 | |||
93 | public function testGetErrorMessage() | ||
94 | { | ||
95 | $formatter = $this->getDefaultDateFormatter(); | ||
96 | $this->assertEquals(IntlGlobals::getErrorMessage(), $formatter->getErrorMessage()); | ||
97 | } | ||
98 | |||
99 | public function testIsLenient() | ||
100 | { | ||
101 | $formatter = $this->getDefaultDateFormatter(); | ||
102 | $this->assertFalse($formatter->isLenient()); | ||
103 | } | ||
104 | |||
105 | /** | ||
106 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
107 | */ | ||
108 | public function testLocaltime() | ||
109 | { | ||
110 | $formatter = $this->getDefaultDateFormatter(); | ||
111 | $formatter->localtime('Wednesday, December 31, 1969 4:00:00 PM PT'); | ||
112 | } | ||
113 | |||
114 | /** | ||
115 | * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException | ||
116 | */ | ||
117 | public function testParseWithNotNullPositionValue() | ||
118 | { | ||
119 | $position = 0; | ||
120 | $formatter = $this->getDefaultDateFormatter('y'); | ||
121 | $this->assertSame(0, $formatter->parse('1970', $position)); | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
126 | */ | ||
127 | public function testSetCalendar() | ||
128 | { | ||
129 | $formatter = $this->getDefaultDateFormatter(); | ||
130 | $formatter->setCalendar(IntlDateFormatter::GREGORIAN); | ||
131 | } | ||
132 | |||
133 | /** | ||
134 | * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException | ||
135 | */ | ||
136 | public function testSetLenient() | ||
137 | { | ||
138 | $formatter = $this->getDefaultDateFormatter(); | ||
139 | $formatter->setLenient(true); | ||
140 | } | ||
141 | |||
142 | /** | ||
143 | * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException | ||
144 | */ | ||
145 | public function testFormatWithGmtTimeZoneAndMinutesOffset() | ||
146 | { | ||
147 | parent::testFormatWithGmtTimeZoneAndMinutesOffset(); | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException | ||
152 | */ | ||
153 | public function testFormatWithNonStandardTimezone() | ||
154 | { | ||
155 | parent::testFormatWithNonStandardTimezone(); | ||
156 | } | ||
157 | |||
158 | public function parseStandaloneAmPmProvider() | ||
159 | { | ||
160 | return $this->notImplemented(parent::parseStandaloneAmPmProvider()); | ||
161 | } | ||
162 | |||
163 | public function parseDayOfWeekProvider() | ||
164 | { | ||
165 | return $this->notImplemented(parent::parseDayOfWeekProvider()); | ||
166 | } | ||
167 | |||
168 | public function parseDayOfYearProvider() | ||
169 | { | ||
170 | return $this->notImplemented(parent::parseDayOfYearProvider()); | ||
171 | } | ||
172 | |||
173 | public function parseQuarterProvider() | ||
174 | { | ||
175 | return $this->notImplemented(parent::parseQuarterProvider()); | ||
176 | } | ||
177 | |||
178 | protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null) | ||
179 | { | ||
180 | return new IntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern); | ||
181 | } | ||
182 | |||
183 | protected function getIntlErrorMessage() | ||
184 | { | ||
185 | return IntlGlobals::getErrorMessage(); | ||
186 | } | ||
187 | |||
188 | protected function getIntlErrorCode() | ||
189 | { | ||
190 | return IntlGlobals::getErrorCode(); | ||
191 | } | ||
192 | |||
193 | protected function isIntlFailure($errorCode) | ||
194 | { | ||
195 | return IntlGlobals::isFailure($errorCode); | ||
196 | } | ||
197 | |||
198 | /** | ||
199 | * Just to document the differences between the stub and the intl | ||
200 | * implementations. The intl can parse any of the tested formats alone. The | ||
201 | * stub does not implement them as it would be needed to add more | ||
202 | * abstraction, passing more context to the transformers objects. Any of the | ||
203 | * formats are ignored alone or with date/time data (years, months, days, | ||
204 | * hours, minutes and seconds). | ||
205 | * | ||
206 | * Also in intl, format like 'ss E' for '10 2' (2nd day of year | ||
207 | * + 10 seconds) are added, then we have 86,400 seconds (24h * 60min * 60s) | ||
208 | * + 10 seconds | ||
209 | * | ||
210 | * @param array $dataSets | ||
211 | * | ||
212 | * @return array | ||
213 | */ | ||
214 | private function notImplemented(array $dataSets) | ||
215 | { | ||
216 | return array_map(function ($row) { | ||
217 | return array($row[0], $row[1], 0); | ||
218 | }, $dataSets); | ||
219 | } | ||
220 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php new file mode 100644 index 00000000..7fbf854f --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/DateFormatter/Verification/IntlDateFormatterTest.php | |||
@@ -0,0 +1,64 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\DateFormatter\Verification; | ||
13 | |||
14 | use Symfony\Component\Intl\DateFormatter\IntlDateFormatter; | ||
15 | use Symfony\Component\Intl\Tests\DateFormatter\AbstractIntlDateFormatterTest; | ||
16 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
17 | |||
18 | /** | ||
19 | * Verifies that {@link AbstractIntlDateFormatterTest} matches the behavior of | ||
20 | * the {@link \IntlDateFormatter} class in a specific version of ICU. | ||
21 | * | ||
22 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
23 | */ | ||
24 | class IntlDateFormatterTest extends AbstractIntlDateFormatterTest | ||
25 | { | ||
26 | protected function setUp() | ||
27 | { | ||
28 | IntlTestHelper::requireFullIntl($this); | ||
29 | |||
30 | parent::setUp(); | ||
31 | } | ||
32 | |||
33 | /** | ||
34 | * It seems IntlDateFormatter caches the timezone id when not explicitly set via constructor or by the | ||
35 | * setTimeZoneId() method. Since testFormatWithDefaultTimezoneIntl() runs using the default environment | ||
36 | * time zone, this test would use it too if not running in a separated process. | ||
37 | * | ||
38 | * @runInSeparateProcess | ||
39 | */ | ||
40 | public function testFormatWithTimezoneFromEnvironmentVariable() | ||
41 | { | ||
42 | parent::testFormatWithTimezoneFromEnvironmentVariable(); | ||
43 | } | ||
44 | |||
45 | protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null) | ||
46 | { | ||
47 | return new \IntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern); | ||
48 | } | ||
49 | |||
50 | protected function getIntlErrorMessage() | ||
51 | { | ||
52 | return intl_get_error_message(); | ||
53 | } | ||
54 | |||
55 | protected function getIntlErrorCode() | ||
56 | { | ||
57 | return intl_get_error_code(); | ||
58 | } | ||
59 | |||
60 | protected function isIntlFailure($errorCode) | ||
61 | { | ||
62 | return intl_is_failure($errorCode); | ||
63 | } | ||
64 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/AbstractIntlGlobalsTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/AbstractIntlGlobalsTest.php new file mode 100644 index 00000000..0a937d5e --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/AbstractIntlGlobalsTest.php | |||
@@ -0,0 +1,41 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\Globals; | ||
13 | |||
14 | /** | ||
15 | * Test case for intl function implementations. | ||
16 | * | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | abstract class AbstractIntlGlobalsTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | public function errorNameProvider() | ||
22 | { | ||
23 | return array ( | ||
24 | array(-129, '[BOGUS UErrorCode]'), | ||
25 | array(0, 'U_ZERO_ERROR'), | ||
26 | array(1, 'U_ILLEGAL_ARGUMENT_ERROR'), | ||
27 | array(9, 'U_PARSE_ERROR'), | ||
28 | array(129, '[BOGUS UErrorCode]'), | ||
29 | ); | ||
30 | } | ||
31 | |||
32 | /** | ||
33 | * @dataProvider errorNameProvider | ||
34 | */ | ||
35 | public function testGetErrorName($errorCode, $errorName) | ||
36 | { | ||
37 | $this->assertSame($errorName, $this->getIntlErrorName($errorCode)); | ||
38 | } | ||
39 | |||
40 | abstract protected function getIntlErrorName($errorCode); | ||
41 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/IntlGlobalsTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/IntlGlobalsTest.php new file mode 100644 index 00000000..34e3a6a3 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/IntlGlobalsTest.php | |||
@@ -0,0 +1,22 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\Globals; | ||
13 | |||
14 | use Symfony\Component\Intl\Globals\IntlGlobals; | ||
15 | |||
16 | class IntlGlobalsTest extends AbstractIntlGlobalsTest | ||
17 | { | ||
18 | protected function getIntlErrorName($errorCode) | ||
19 | { | ||
20 | return IntlGlobals::getErrorName($errorCode); | ||
21 | } | ||
22 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/Verification/IntlGlobalsTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/Verification/IntlGlobalsTest.php new file mode 100644 index 00000000..c46033d8 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Globals/Verification/IntlGlobalsTest.php | |||
@@ -0,0 +1,36 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\Globals\Verification; | ||
13 | |||
14 | use Symfony\Component\Intl\Tests\Globals\AbstractIntlGlobalsTest; | ||
15 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
16 | |||
17 | /** | ||
18 | * Verifies that {@link AbstractIntlGlobalsTest} matches the behavior of the | ||
19 | * intl functions with a specific version of ICU. | ||
20 | * | ||
21 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
22 | */ | ||
23 | class IntlGlobalsTest extends AbstractIntlGlobalsTest | ||
24 | { | ||
25 | protected function setUp() | ||
26 | { | ||
27 | IntlTestHelper::requireFullIntl($this); | ||
28 | |||
29 | parent::setUp(); | ||
30 | } | ||
31 | |||
32 | protected function getIntlErrorName($errorCode) | ||
33 | { | ||
34 | return intl_error_name($errorCode); | ||
35 | } | ||
36 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/AbstractLocaleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/AbstractLocaleTest.php new file mode 100644 index 00000000..08569fad --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/AbstractLocaleTest.php | |||
@@ -0,0 +1,29 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\Locale; | ||
13 | |||
14 | /** | ||
15 | * Test case for Locale implementations. | ||
16 | * | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | abstract class AbstractLocaleTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | public function testSetDefault() | ||
22 | { | ||
23 | $this->call('setDefault', 'en_GB'); | ||
24 | |||
25 | $this->assertSame('en_GB', $this->call('getDefault')); | ||
26 | } | ||
27 | |||
28 | abstract protected function call($methodName); | ||
29 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/LocaleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/LocaleTest.php new file mode 100644 index 00000000..7e957187 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/LocaleTest.php | |||
@@ -0,0 +1,159 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\Locale; | ||
13 | |||
14 | class LocaleTest extends AbstractLocaleTest | ||
15 | { | ||
16 | /** | ||
17 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
18 | */ | ||
19 | public function testAcceptFromHttp() | ||
20 | { | ||
21 | $this->call('acceptFromHttp', 'pt-br,en-us;q=0.7,en;q=0.5'); | ||
22 | } | ||
23 | |||
24 | /** | ||
25 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
26 | */ | ||
27 | public function testComposeLocale() | ||
28 | { | ||
29 | $subtags = array( | ||
30 | 'language' => 'pt', | ||
31 | 'script' => 'Latn', | ||
32 | 'region' => 'BR' | ||
33 | ); | ||
34 | $this->call('composeLocale', $subtags); | ||
35 | } | ||
36 | |||
37 | /** | ||
38 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
39 | */ | ||
40 | public function testFilterMatches() | ||
41 | { | ||
42 | $this->call('filterMatches', 'pt-BR', 'pt-BR'); | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
47 | */ | ||
48 | public function testGetAllVariants() | ||
49 | { | ||
50 | $this->call('getAllVariants', 'pt_BR_Latn'); | ||
51 | } | ||
52 | |||
53 | /** | ||
54 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
55 | */ | ||
56 | public function testGetDisplayLanguage() | ||
57 | { | ||
58 | $this->call('getDisplayLanguage', 'pt-Latn-BR', 'en'); | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
63 | */ | ||
64 | public function testGetDisplayName() | ||
65 | { | ||
66 | $this->call('getDisplayName', 'pt-Latn-BR', 'en'); | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
71 | */ | ||
72 | public function testGetDisplayRegion() | ||
73 | { | ||
74 | $this->call('getDisplayRegion', 'pt-Latn-BR', 'en'); | ||
75 | } | ||
76 | |||
77 | /** | ||
78 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
79 | */ | ||
80 | public function testGetDisplayScript() | ||
81 | { | ||
82 | $this->call('getDisplayScript', 'pt-Latn-BR', 'en'); | ||
83 | } | ||
84 | |||
85 | /** | ||
86 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
87 | */ | ||
88 | public function testGetDisplayVariant() | ||
89 | { | ||
90 | $this->call('getDisplayVariant', 'pt-Latn-BR', 'en'); | ||
91 | } | ||
92 | |||
93 | /** | ||
94 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
95 | */ | ||
96 | public function testGetKeywords() | ||
97 | { | ||
98 | $this->call('getKeywords', 'pt-BR@currency=BRL'); | ||
99 | } | ||
100 | |||
101 | /** | ||
102 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
103 | */ | ||
104 | public function testGetPrimaryLanguage() | ||
105 | { | ||
106 | $this->call('getPrimaryLanguage', 'pt-Latn-BR'); | ||
107 | } | ||
108 | |||
109 | /** | ||
110 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
111 | */ | ||
112 | public function testGetRegion() | ||
113 | { | ||
114 | $this->call('getRegion', 'pt-Latn-BR'); | ||
115 | } | ||
116 | |||
117 | /** | ||
118 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
119 | */ | ||
120 | public function testGetScript() | ||
121 | { | ||
122 | $this->call('getScript', 'pt-Latn-BR'); | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
127 | */ | ||
128 | public function testLookup() | ||
129 | { | ||
130 | $langtag = array( | ||
131 | 'pt-Latn-BR', | ||
132 | 'pt-BR' | ||
133 | ); | ||
134 | $this->call('lookup', $langtag, 'pt-BR-x-priv1'); | ||
135 | } | ||
136 | |||
137 | /** | ||
138 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
139 | */ | ||
140 | public function testParseLocale() | ||
141 | { | ||
142 | $this->call('parseLocale', 'pt-Latn-BR'); | ||
143 | } | ||
144 | |||
145 | /** | ||
146 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
147 | */ | ||
148 | public function testSetDefault() | ||
149 | { | ||
150 | $this->call('setDefault', 'pt_BR'); | ||
151 | } | ||
152 | |||
153 | protected function call($methodName) | ||
154 | { | ||
155 | $args = array_slice(func_get_args(), 1); | ||
156 | |||
157 | return call_user_func_array(array('Symfony\Component\Intl\Locale\Locale', $methodName), $args); | ||
158 | } | ||
159 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/Verification/LocaleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/Verification/LocaleTest.php new file mode 100644 index 00000000..39d4f3cb --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Locale/Verification/LocaleTest.php | |||
@@ -0,0 +1,38 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\Locale\Verification; | ||
13 | |||
14 | use Symfony\Component\Intl\Tests\Locale\AbstractLocaleTest; | ||
15 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
16 | |||
17 | /** | ||
18 | * Verifies that {@link AbstractLocaleTest} matches the behavior of the | ||
19 | * {@link Locale} class with a specific version of ICU. | ||
20 | * | ||
21 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
22 | */ | ||
23 | class LocaleTest extends AbstractLocaleTest | ||
24 | { | ||
25 | protected function setUp() | ||
26 | { | ||
27 | IntlTestHelper::requireFullIntl($this); | ||
28 | |||
29 | parent::setUp(); | ||
30 | } | ||
31 | |||
32 | protected function call($methodName) | ||
33 | { | ||
34 | $args = array_slice(func_get_args(), 1); | ||
35 | |||
36 | return call_user_func_array(array('Locale', $methodName), $args); | ||
37 | } | ||
38 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php new file mode 100644 index 00000000..ad5581b4 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php | |||
@@ -0,0 +1,707 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\NumberFormatter; | ||
13 | |||
14 | use Symfony\Component\Intl\Globals\IntlGlobals; | ||
15 | use Symfony\Component\Intl\Intl; | ||
16 | use Symfony\Component\Intl\Locale; | ||
17 | use Symfony\Component\Intl\NumberFormatter\NumberFormatter; | ||
18 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
19 | |||
20 | /** | ||
21 | * Note that there are some values written like -2147483647 - 1. This is the lower 32bit int max and is a known | ||
22 | * behavior of PHP. | ||
23 | */ | ||
24 | abstract class AbstractNumberFormatterTest extends \PHPUnit_Framework_TestCase | ||
25 | { | ||
26 | /** | ||
27 | * @dataProvider formatCurrencyWithDecimalStyleProvider | ||
28 | */ | ||
29 | public function testFormatCurrencyWithDecimalStyle($value, $currency, $expected) | ||
30 | { | ||
31 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
32 | $this->assertEquals($expected, $formatter->formatCurrency($value, $currency)); | ||
33 | } | ||
34 | |||
35 | public function formatCurrencyWithDecimalStyleProvider() | ||
36 | { | ||
37 | return array( | ||
38 | array(100, 'ALL', '100'), | ||
39 | array(100, 'BRL', '100.00'), | ||
40 | array(100, 'CRC', '100'), | ||
41 | array(100, 'JPY', '100'), | ||
42 | array(100, 'CHF', '100'), | ||
43 | array(-100, 'ALL', '-100'), | ||
44 | array(-100, 'BRL', '-100'), | ||
45 | array(-100, 'CRC', '-100'), | ||
46 | array(-100, 'JPY', '-100'), | ||
47 | array(-100, 'CHF', '-100'), | ||
48 | array(1000.12, 'ALL', '1,000.12'), | ||
49 | array(1000.12, 'BRL', '1,000.12'), | ||
50 | array(1000.12, 'CRC', '1,000.12'), | ||
51 | array(1000.12, 'JPY', '1,000.12'), | ||
52 | array(1000.12, 'CHF', '1,000.12') | ||
53 | ); | ||
54 | } | ||
55 | |||
56 | /** | ||
57 | * @dataProvider formatCurrencyWithCurrencyStyleProvider | ||
58 | */ | ||
59 | public function testFormatCurrencyWithCurrencyStyle($value, $currency, $expected) | ||
60 | { | ||
61 | $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); | ||
62 | $this->assertEquals($expected, $formatter->formatCurrency($value, $currency)); | ||
63 | } | ||
64 | |||
65 | public function formatCurrencyWithCurrencyStyleProvider() | ||
66 | { | ||
67 | return array( | ||
68 | array(100, 'ALL', 'ALL100'), | ||
69 | array(-100, 'ALL', '(ALL100)'), | ||
70 | array(1000.12, 'ALL', 'ALL1,000'), | ||
71 | |||
72 | array(100, 'JPY', 'Â¥100'), | ||
73 | array(-100, 'JPY', '(Â¥100)'), | ||
74 | array(1000.12, 'JPY', 'Â¥1,000'), | ||
75 | |||
76 | array(100, 'EUR', '€100.00'), | ||
77 | array(-100, 'EUR', '(€100.00)'), | ||
78 | array(1000.12, 'EUR', '€1,000.12'), | ||
79 | ); | ||
80 | } | ||
81 | |||
82 | /** | ||
83 | * @dataProvider formatCurrencyWithCurrencyStyleCostaRicanColonsRoundingProvider | ||
84 | */ | ||
85 | public function testFormatCurrencyWithCurrencyStyleCostaRicanColonsRounding($value, $currency, $symbol, $expected) | ||
86 | { | ||
87 | $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); | ||
88 | $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency)); | ||
89 | } | ||
90 | |||
91 | public function formatCurrencyWithCurrencyStyleCostaRicanColonsRoundingProvider() | ||
92 | { | ||
93 | return array( | ||
94 | array(100, 'CRC', 'CRC', '%s100'), | ||
95 | array(-100, 'CRC', 'CRC', '(%s100)'), | ||
96 | array(1000.12, 'CRC', 'CRC', '%s1,000'), | ||
97 | ); | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * @dataProvider formatCurrencyWithCurrencyStyleBrazilianRealRoundingProvider | ||
102 | */ | ||
103 | public function testFormatCurrencyWithCurrencyStyleBrazilianRealRounding($value, $currency, $symbol, $expected) | ||
104 | { | ||
105 | $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); | ||
106 | $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency)); | ||
107 | } | ||
108 | |||
109 | public function formatCurrencyWithCurrencyStyleBrazilianRealRoundingProvider() | ||
110 | { | ||
111 | return array( | ||
112 | array(100, 'BRL', 'R', '%s$100.00'), | ||
113 | array(-100, 'BRL', 'R', '(%s$100.00)'), | ||
114 | array(1000.12, 'BRL', 'R', '%s$1,000.12'), | ||
115 | |||
116 | // Rounding checks | ||
117 | array(1000.121, 'BRL', 'R', '%s$1,000.12'), | ||
118 | array(1000.123, 'BRL', 'R', '%s$1,000.12'), | ||
119 | array(1000.125, 'BRL', 'R', '%s$1,000.12'), | ||
120 | array(1000.127, 'BRL', 'R', '%s$1,000.13'), | ||
121 | array(1000.129, 'BRL', 'R', '%s$1,000.13'), | ||
122 | array(11.50999, 'BRL', 'R', '%s$11.51'), | ||
123 | array(11.9999464, 'BRL', 'R', '%s$12.00') | ||
124 | ); | ||
125 | } | ||
126 | |||
127 | /** | ||
128 | * @dataProvider formatCurrencyWithCurrencyStyleSwissRoundingProvider | ||
129 | */ | ||
130 | public function testFormatCurrencyWithCurrencyStyleSwissRounding($value, $currency, $symbol, $expected) | ||
131 | { | ||
132 | $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); | ||
133 | $this->assertEquals(sprintf($expected, $symbol), $formatter->formatCurrency($value, $currency)); | ||
134 | } | ||
135 | |||
136 | public function formatCurrencyWithCurrencyStyleSwissRoundingProvider() | ||
137 | { | ||
138 | return array( | ||
139 | array(100, 'CHF', 'CHF', '%s100.00'), | ||
140 | array(-100, 'CHF', 'CHF', '(%s100.00)'), | ||
141 | array(1000.12, 'CHF', 'CHF', '%s1,000.10'), | ||
142 | array('1000.12', 'CHF', 'CHF', '%s1,000.10'), | ||
143 | |||
144 | // Rounding checks | ||
145 | array(1000.121, 'CHF', 'CHF', '%s1,000.10'), | ||
146 | array(1000.123, 'CHF', 'CHF', '%s1,000.10'), | ||
147 | array(1000.125, 'CHF', 'CHF', '%s1,000.10'), | ||
148 | array(1000.127, 'CHF', 'CHF', '%s1,000.15'), | ||
149 | array(1000.129, 'CHF', 'CHF', '%s1,000.15'), | ||
150 | |||
151 | array(1200000.00, 'CHF', 'CHF', '%s1,200,000.00'), | ||
152 | array(1200000.1, 'CHF', 'CHF', '%s1,200,000.10'), | ||
153 | array(1200000.10, 'CHF', 'CHF', '%s1,200,000.10'), | ||
154 | array(1200000.101, 'CHF', 'CHF', '%s1,200,000.10') | ||
155 | ); | ||
156 | } | ||
157 | |||
158 | public function testFormat() | ||
159 | { | ||
160 | $errorCode = IntlGlobals::U_ZERO_ERROR; | ||
161 | $errorMessage = 'U_ZERO_ERROR'; | ||
162 | |||
163 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
164 | $this->assertSame('9.555', $formatter->format(9.555)); | ||
165 | |||
166 | $this->assertSame($errorMessage, $this->getIntlErrorMessage()); | ||
167 | $this->assertSame($errorCode, $this->getIntlErrorCode()); | ||
168 | $this->assertFalse($this->isIntlFailure($this->getIntlErrorCode())); | ||
169 | $this->assertSame($errorMessage, $formatter->getErrorMessage()); | ||
170 | $this->assertSame($errorCode, $formatter->getErrorCode()); | ||
171 | $this->assertFalse($this->isIntlFailure($formatter->getErrorCode())); | ||
172 | } | ||
173 | |||
174 | public function testFormatWithCurrencyStyle() | ||
175 | { | ||
176 | $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); | ||
177 | $this->assertEquals('¤1.00', $formatter->format(1)); | ||
178 | } | ||
179 | |||
180 | /** | ||
181 | * @dataProvider formatTypeInt32Provider | ||
182 | */ | ||
183 | public function testFormatTypeInt32($formatter, $value, $expected, $message = '') | ||
184 | { | ||
185 | $formattedValue = $formatter->format($value, NumberFormatter::TYPE_INT32); | ||
186 | $this->assertEquals($expected, $formattedValue, $message); | ||
187 | } | ||
188 | |||
189 | public function formatTypeInt32Provider() | ||
190 | { | ||
191 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
192 | |||
193 | $message = '->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.'; | ||
194 | |||
195 | return array( | ||
196 | array($formatter, 1, '1'), | ||
197 | array($formatter, 1.1, '1'), | ||
198 | array($formatter, 2147483648, '-2,147,483,648', $message), | ||
199 | array($formatter, -2147483649, '2,147,483,647', $message), | ||
200 | ); | ||
201 | } | ||
202 | |||
203 | /** | ||
204 | * @dataProvider formatTypeInt32WithCurrencyStyleProvider | ||
205 | */ | ||
206 | public function testFormatTypeInt32WithCurrencyStyle($formatter, $value, $expected, $message = '') | ||
207 | { | ||
208 | $formattedValue = $formatter->format($value, NumberFormatter::TYPE_INT32); | ||
209 | $this->assertEquals($expected, $formattedValue, $message); | ||
210 | } | ||
211 | |||
212 | public function formatTypeInt32WithCurrencyStyleProvider() | ||
213 | { | ||
214 | $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); | ||
215 | |||
216 | $message = '->format() TYPE_INT32 formats inconsistently an integer if out of the 32 bit range.'; | ||
217 | |||
218 | return array( | ||
219 | array($formatter, 1, '¤1.00'), | ||
220 | array($formatter, 1.1, '¤1.00'), | ||
221 | array($formatter, 2147483648, '(¤2,147,483,648.00)', $message), | ||
222 | array($formatter, -2147483649, '¤2,147,483,647.00', $message) | ||
223 | ); | ||
224 | } | ||
225 | |||
226 | /** | ||
227 | * The parse() method works differently with integer out of the 32 bit range. format() works fine. | ||
228 | * @dataProvider formatTypeInt64Provider | ||
229 | */ | ||
230 | public function testFormatTypeInt64($formatter, $value, $expected) | ||
231 | { | ||
232 | $formattedValue = $formatter->format($value, NumberFormatter::TYPE_INT64); | ||
233 | $this->assertEquals($expected, $formattedValue); | ||
234 | } | ||
235 | |||
236 | public function formatTypeInt64Provider() | ||
237 | { | ||
238 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
239 | |||
240 | return array( | ||
241 | array($formatter, 1, '1'), | ||
242 | array($formatter, 1.1, '1'), | ||
243 | array($formatter, 2147483648, '2,147,483,648'), | ||
244 | array($formatter, -2147483649, '-2,147,483,649'), | ||
245 | ); | ||
246 | } | ||
247 | |||
248 | /** | ||
249 | * @dataProvider formatTypeInt64WithCurrencyStyleProvider | ||
250 | */ | ||
251 | public function testFormatTypeInt64WithCurrencyStyle($formatter, $value, $expected) | ||
252 | { | ||
253 | $formattedValue = $formatter->format($value, NumberFormatter::TYPE_INT64); | ||
254 | $this->assertEquals($expected, $formattedValue); | ||
255 | } | ||
256 | |||
257 | public function formatTypeInt64WithCurrencyStyleProvider() | ||
258 | { | ||
259 | $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); | ||
260 | |||
261 | return array( | ||
262 | array($formatter, 1, '¤1.00'), | ||
263 | array($formatter, 1.1, '¤1.00'), | ||
264 | array($formatter, 2147483648, '¤2,147,483,648.00'), | ||
265 | array($formatter, -2147483649, '(¤2,147,483,649.00)') | ||
266 | ); | ||
267 | } | ||
268 | |||
269 | /** | ||
270 | * @dataProvider formatTypeDoubleProvider | ||
271 | */ | ||
272 | public function testFormatTypeDouble($formatter, $value, $expected) | ||
273 | { | ||
274 | $formattedValue = $formatter->format($value, NumberFormatter::TYPE_DOUBLE); | ||
275 | $this->assertEquals($expected, $formattedValue); | ||
276 | } | ||
277 | |||
278 | public function formatTypeDoubleProvider() | ||
279 | { | ||
280 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
281 | |||
282 | return array( | ||
283 | array($formatter, 1, '1'), | ||
284 | array($formatter, 1.1, '1.1'), | ||
285 | ); | ||
286 | } | ||
287 | |||
288 | /** | ||
289 | * @dataProvider formatTypeDoubleWithCurrencyStyleProvider | ||
290 | */ | ||
291 | public function testFormatTypeDoubleWithCurrencyStyle($formatter, $value, $expected) | ||
292 | { | ||
293 | $formattedValue = $formatter->format($value, NumberFormatter::TYPE_DOUBLE); | ||
294 | $this->assertEquals($expected, $formattedValue); | ||
295 | } | ||
296 | |||
297 | public function formatTypeDoubleWithCurrencyStyleProvider() | ||
298 | { | ||
299 | $formatter = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); | ||
300 | |||
301 | return array( | ||
302 | array($formatter, 1, '¤1.00'), | ||
303 | array($formatter, 1.1, '¤1.10'), | ||
304 | ); | ||
305 | } | ||
306 | |||
307 | /** | ||
308 | * @dataProvider formatTypeCurrencyProvider | ||
309 | * @expectedException \PHPUnit_Framework_Error_Warning | ||
310 | */ | ||
311 | public function testFormatTypeCurrency($formatter, $value) | ||
312 | { | ||
313 | $formatter->format($value, NumberFormatter::TYPE_CURRENCY); | ||
314 | } | ||
315 | |||
316 | /** | ||
317 | * @dataProvider formatTypeCurrencyProvider | ||
318 | */ | ||
319 | public function testFormatTypeCurrencyReturn($formatter, $value) | ||
320 | { | ||
321 | $this->assertFalse(@$formatter->format($value, NumberFormatter::TYPE_CURRENCY)); | ||
322 | } | ||
323 | |||
324 | public function formatTypeCurrencyProvider() | ||
325 | { | ||
326 | $df = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
327 | $cf = $this->getNumberFormatter('en', NumberFormatter::CURRENCY); | ||
328 | |||
329 | return array( | ||
330 | array($df, 1), | ||
331 | array($cf, 1), | ||
332 | ); | ||
333 | } | ||
334 | |||
335 | /** | ||
336 | * @dataProvider formatFractionDigitsProvider | ||
337 | */ | ||
338 | public function testFormatFractionDigits($value, $expected, $fractionDigits = null, $expectedFractionDigits = 1) | ||
339 | { | ||
340 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
341 | |||
342 | if (null !== $fractionDigits) { | ||
343 | $attributeRet = $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, $fractionDigits); | ||
344 | } | ||
345 | |||
346 | $formattedValue = $formatter->format($value); | ||
347 | $this->assertSame($expected, $formattedValue); | ||
348 | $this->assertSame($expectedFractionDigits, $formatter->getAttribute(NumberFormatter::FRACTION_DIGITS)); | ||
349 | |||
350 | if (isset($attributeRet)) { | ||
351 | $this->assertTrue($attributeRet); | ||
352 | } | ||
353 | } | ||
354 | |||
355 | public function formatFractionDigitsProvider() | ||
356 | { | ||
357 | return array( | ||
358 | array(1.123, '1.123', null, 0), | ||
359 | array(1.123, '1', 0, 0), | ||
360 | array(1.123, '1.1', 1, 1), | ||
361 | array(1.123, '1.12', 2, 2), | ||
362 | array(1.123, '1', -1, 0), | ||
363 | array(1.123, '1', 'abc', 0) | ||
364 | ); | ||
365 | } | ||
366 | |||
367 | /** | ||
368 | * @dataProvider formatGroupingUsedProvider | ||
369 | */ | ||
370 | public function testFormatGroupingUsed($value, $expected, $groupingUsed = null, $expectedGroupingUsed = 1) | ||
371 | { | ||
372 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
373 | |||
374 | if (null !== $groupingUsed) { | ||
375 | $attributeRet = $formatter->setAttribute(NumberFormatter::GROUPING_USED, $groupingUsed); | ||
376 | } | ||
377 | |||
378 | $formattedValue = $formatter->format($value); | ||
379 | $this->assertSame($expected, $formattedValue); | ||
380 | $this->assertSame($expectedGroupingUsed, $formatter->getAttribute(NumberFormatter::GROUPING_USED)); | ||
381 | |||
382 | if (isset($attributeRet)) { | ||
383 | $this->assertTrue($attributeRet); | ||
384 | } | ||
385 | } | ||
386 | |||
387 | public function formatGroupingUsedProvider() | ||
388 | { | ||
389 | return array( | ||
390 | array(1000, '1,000', null, 1), | ||
391 | array(1000, '1000', 0, 0), | ||
392 | array(1000, '1,000', 1, 1), | ||
393 | array(1000, '1,000', 2, 1), | ||
394 | array(1000, '1000', 'abc', 0), | ||
395 | array(1000, '1,000', -1, 1), | ||
396 | ); | ||
397 | } | ||
398 | |||
399 | /** | ||
400 | * @dataProvider formatRoundingModeRoundHalfUpProvider | ||
401 | */ | ||
402 | public function testFormatRoundingModeHalfUp($value, $expected) | ||
403 | { | ||
404 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
405 | $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2); | ||
406 | |||
407 | $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_HALFUP); | ||
408 | $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_HALFUP rounding mode.'); | ||
409 | } | ||
410 | |||
411 | public function formatRoundingModeRoundHalfUpProvider() | ||
412 | { | ||
413 | // The commented value is differently rounded by intl's NumberFormatter in 32 and 64 bit architectures | ||
414 | return array( | ||
415 | array(1.121, '1.12'), | ||
416 | array(1.123, '1.12'), | ||
417 | // array(1.125, '1.13'), | ||
418 | array(1.127, '1.13'), | ||
419 | array(1.129, '1.13'), | ||
420 | ); | ||
421 | } | ||
422 | |||
423 | /** | ||
424 | * @dataProvider formatRoundingModeRoundHalfDownProvider | ||
425 | */ | ||
426 | public function testFormatRoundingModeHalfDown($value, $expected) | ||
427 | { | ||
428 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
429 | $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2); | ||
430 | |||
431 | $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_HALFDOWN); | ||
432 | $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_HALFDOWN rounding mode.'); | ||
433 | } | ||
434 | |||
435 | public function formatRoundingModeRoundHalfDownProvider() | ||
436 | { | ||
437 | return array( | ||
438 | array(1.121, '1.12'), | ||
439 | array(1.123, '1.12'), | ||
440 | array(1.125, '1.12'), | ||
441 | array(1.127, '1.13'), | ||
442 | array(1.129, '1.13'), | ||
443 | ); | ||
444 | } | ||
445 | |||
446 | /** | ||
447 | * @dataProvider formatRoundingModeRoundHalfEvenProvider | ||
448 | */ | ||
449 | public function testFormatRoundingModeHalfEven($value, $expected) | ||
450 | { | ||
451 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
452 | $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 2); | ||
453 | |||
454 | $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, NumberFormatter::ROUND_HALFEVEN); | ||
455 | $this->assertSame($expected, $formatter->format($value), '->format() with ROUND_HALFEVEN rounding mode.'); | ||
456 | } | ||
457 | |||
458 | public function formatRoundingModeRoundHalfEvenProvider() | ||
459 | { | ||
460 | return array( | ||
461 | array(1.121, '1.12'), | ||
462 | array(1.123, '1.12'), | ||
463 | array(1.125, '1.12'), | ||
464 | array(1.127, '1.13'), | ||
465 | array(1.129, '1.13'), | ||
466 | ); | ||
467 | } | ||
468 | |||
469 | public function testGetLocale() | ||
470 | { | ||
471 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
472 | $this->assertEquals('en', $formatter->getLocale()); | ||
473 | } | ||
474 | |||
475 | /** | ||
476 | * @dataProvider parseProvider | ||
477 | */ | ||
478 | public function testParse($value, $expected, $message = '') | ||
479 | { | ||
480 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
481 | $parsedValue = $formatter->parse($value, NumberFormatter::TYPE_DOUBLE); | ||
482 | $this->assertSame($expected, $parsedValue, $message); | ||
483 | |||
484 | if ($expected === false) { | ||
485 | $errorCode = IntlGlobals::U_PARSE_ERROR; | ||
486 | $errorMessage = 'Number parsing failed: U_PARSE_ERROR'; | ||
487 | } else { | ||
488 | $errorCode = IntlGlobals::U_ZERO_ERROR; | ||
489 | $errorMessage = 'U_ZERO_ERROR'; | ||
490 | } | ||
491 | |||
492 | $this->assertSame($errorMessage, $this->getIntlErrorMessage()); | ||
493 | $this->assertSame($errorCode, $this->getIntlErrorCode()); | ||
494 | $this->assertSame($errorCode !== 0, $this->isIntlFailure($this->getIntlErrorCode())); | ||
495 | $this->assertSame($errorMessage, $formatter->getErrorMessage()); | ||
496 | $this->assertSame($errorCode, $formatter->getErrorCode()); | ||
497 | $this->assertSame($errorCode !== 0, $this->isIntlFailure($formatter->getErrorCode())); | ||
498 | } | ||
499 | |||
500 | public function parseProvider() | ||
501 | { | ||
502 | return array( | ||
503 | array('prefix1', false, '->parse() does not parse a number with a string prefix.'), | ||
504 | array('1suffix', (float) 1, '->parse() parses a number with a string suffix.'), | ||
505 | ); | ||
506 | } | ||
507 | |||
508 | /** | ||
509 | * @expectedException \PHPUnit_Framework_Error_Warning | ||
510 | */ | ||
511 | public function testParseTypeDefault() | ||
512 | { | ||
513 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
514 | $formatter->parse('1', NumberFormatter::TYPE_DEFAULT); | ||
515 | } | ||
516 | |||
517 | /** | ||
518 | * @dataProvider parseTypeInt32Provider | ||
519 | */ | ||
520 | public function testParseTypeInt32($value, $expected, $message = '') | ||
521 | { | ||
522 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
523 | $parsedValue = $formatter->parse($value, NumberFormatter::TYPE_INT32); | ||
524 | $this->assertSame($expected, $parsedValue); | ||
525 | } | ||
526 | |||
527 | public function parseTypeInt32Provider() | ||
528 | { | ||
529 | return array( | ||
530 | array('1', 1), | ||
531 | array('1.1', 1), | ||
532 | array('2,147,483,647', 2147483647), | ||
533 | array('-2,147,483,648', -2147483647 - 1), | ||
534 | array('2,147,483,648', false, '->parse() TYPE_INT32 returns false when the number is greater than the integer positive range.'), | ||
535 | array('-2,147,483,649', false, '->parse() TYPE_INT32 returns false when the number is greater than the integer negative range.') | ||
536 | ); | ||
537 | } | ||
538 | |||
539 | public function testParseTypeInt64With32BitIntegerInPhp32Bit() | ||
540 | { | ||
541 | IntlTestHelper::require32Bit($this); | ||
542 | |||
543 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
544 | |||
545 | $parsedValue = $formatter->parse('2,147,483,647', NumberFormatter::TYPE_INT64); | ||
546 | $this->assertInternalType('integer', $parsedValue); | ||
547 | $this->assertEquals(2147483647, $parsedValue); | ||
548 | |||
549 | $parsedValue = $formatter->parse('-2,147,483,648', NumberFormatter::TYPE_INT64); | ||
550 | |||
551 | // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 | ||
552 | // The negative PHP_INT_MAX was being converted to float | ||
553 | if ( | ||
554 | (version_compare(PHP_VERSION, '5.4.0', '<') && version_compare(PHP_VERSION, '5.3.14', '>=')) || | ||
555 | version_compare(PHP_VERSION, '5.4.4', '>=') | ||
556 | ) { | ||
557 | $this->assertInternalType('int', $parsedValue); | ||
558 | } else { | ||
559 | $this->assertInternalType('float', $parsedValue); | ||
560 | } | ||
561 | |||
562 | $this->assertEquals(-2147483648, $parsedValue); | ||
563 | } | ||
564 | |||
565 | public function testParseTypeInt64With32BitIntegerInPhp64Bit() | ||
566 | { | ||
567 | IntlTestHelper::require64Bit($this); | ||
568 | |||
569 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
570 | |||
571 | $parsedValue = $formatter->parse('2,147,483,647', NumberFormatter::TYPE_INT64); | ||
572 | $this->assertInternalType('integer', $parsedValue); | ||
573 | $this->assertEquals(2147483647, $parsedValue); | ||
574 | |||
575 | $parsedValue = $formatter->parse('-2,147,483,648', NumberFormatter::TYPE_INT64); | ||
576 | $this->assertInternalType('integer', $parsedValue); | ||
577 | $this->assertEquals(-2147483647 - 1, $parsedValue); | ||
578 | } | ||
579 | |||
580 | /** | ||
581 | * If PHP is compiled in 32bit mode, the returned value for a 64bit integer are float numbers. | ||
582 | */ | ||
583 | public function testParseTypeInt64With64BitIntegerInPhp32Bit() | ||
584 | { | ||
585 | IntlTestHelper::require32Bit($this); | ||
586 | |||
587 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
588 | |||
589 | // int 64 using only 32 bit range strangeness | ||
590 | $parsedValue = $formatter->parse('2,147,483,648', NumberFormatter::TYPE_INT64); | ||
591 | $this->assertInternalType('float', $parsedValue); | ||
592 | $this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range.'); | ||
593 | |||
594 | $parsedValue = $formatter->parse('-2,147,483,649', NumberFormatter::TYPE_INT64); | ||
595 | $this->assertInternalType('float', $parsedValue); | ||
596 | $this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range.'); | ||
597 | } | ||
598 | |||
599 | /** | ||
600 | * If PHP is compiled in 64bit mode, the returned value for a 64bit integer are 32bit integer numbers. | ||
601 | */ | ||
602 | public function testParseTypeInt64With64BitIntegerInPhp64Bit() | ||
603 | { | ||
604 | IntlTestHelper::require64Bit($this); | ||
605 | |||
606 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
607 | |||
608 | $parsedValue = $formatter->parse('2,147,483,648', NumberFormatter::TYPE_INT64); | ||
609 | $this->assertInternalType('integer', $parsedValue); | ||
610 | |||
611 | // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 | ||
612 | // A 32 bit integer was being generated instead of a 64 bit integer | ||
613 | if ( | ||
614 | (version_compare(PHP_VERSION, '5.3.14', '<')) || | ||
615 | (version_compare(PHP_VERSION, '5.4.0', '>=') && version_compare(PHP_VERSION, '5.4.4', '<')) | ||
616 | ) { | ||
617 | $this->assertEquals(-2147483648, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range (PHP < 5.3.14 and PHP < 5.4.4).'); | ||
618 | } else { | ||
619 | $this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).'); | ||
620 | } | ||
621 | |||
622 | $parsedValue = $formatter->parse('-2,147,483,649', NumberFormatter::TYPE_INT64); | ||
623 | $this->assertInternalType('integer', $parsedValue); | ||
624 | |||
625 | // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 | ||
626 | // A 32 bit integer was being generated instead of a 64 bit integer | ||
627 | if ( | ||
628 | (version_compare(PHP_VERSION, '5.3.14', '<')) || | ||
629 | (version_compare(PHP_VERSION, '5.4.0', '>=') && version_compare(PHP_VERSION, '5.4.4', '<')) | ||
630 | ) { | ||
631 | $this->assertEquals(2147483647, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range (PHP < 5.3.14 and PHP < 5.4.4).'); | ||
632 | } else { | ||
633 | $this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).'); | ||
634 | } | ||
635 | } | ||
636 | |||
637 | /** | ||
638 | * @dataProvider parseTypeDoubleProvider | ||
639 | */ | ||
640 | public function testParseTypeDouble($value, $expectedValue) | ||
641 | { | ||
642 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
643 | $parsedValue = $formatter->parse($value, NumberFormatter::TYPE_DOUBLE); | ||
644 | $this->assertSame($expectedValue, $parsedValue); | ||
645 | } | ||
646 | |||
647 | public function parseTypeDoubleProvider() | ||
648 | { | ||
649 | return array( | ||
650 | array('1', (float) 1), | ||
651 | array('1.1', 1.1), | ||
652 | array('9,223,372,036,854,775,808', 9223372036854775808), | ||
653 | array('-9,223,372,036,854,775,809', -9223372036854775809), | ||
654 | ); | ||
655 | } | ||
656 | |||
657 | /** | ||
658 | * @expectedException \PHPUnit_Framework_Error_Warning | ||
659 | */ | ||
660 | public function testParseTypeCurrency() | ||
661 | { | ||
662 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
663 | $formatter->parse('1', NumberFormatter::TYPE_CURRENCY); | ||
664 | } | ||
665 | |||
666 | public function testParseWithNullPositionValue() | ||
667 | { | ||
668 | $position = null; | ||
669 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
670 | $formatter->parse('123', NumberFormatter::TYPE_INT32, $position); | ||
671 | $this->assertNull($position); | ||
672 | } | ||
673 | |||
674 | public function testParseWithNotNullPositionValue() | ||
675 | { | ||
676 | $position = 1; | ||
677 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
678 | $formatter->parse('123', NumberFormatter::TYPE_DOUBLE, $position); | ||
679 | $this->assertEquals(3, $position); | ||
680 | } | ||
681 | |||
682 | /** | ||
683 | * @param string $locale | ||
684 | * @param null $style | ||
685 | * @param null $pattern | ||
686 | * | ||
687 | * @return \NumberFormatter | ||
688 | */ | ||
689 | abstract protected function getNumberFormatter($locale = 'en', $style = null, $pattern = null); | ||
690 | |||
691 | /** | ||
692 | * @return string | ||
693 | */ | ||
694 | abstract protected function getIntlErrorMessage(); | ||
695 | |||
696 | /** | ||
697 | * @return integer | ||
698 | */ | ||
699 | abstract protected function getIntlErrorCode(); | ||
700 | |||
701 | /** | ||
702 | * @param integer $errorCode | ||
703 | * | ||
704 | * @return Boolean | ||
705 | */ | ||
706 | abstract protected function isIntlFailure($errorCode); | ||
707 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php new file mode 100644 index 00000000..36e89149 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php | |||
@@ -0,0 +1,239 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\NumberFormatter; | ||
13 | |||
14 | use Symfony\Component\Intl\Globals\IntlGlobals; | ||
15 | use Symfony\Component\Intl\NumberFormatter\NumberFormatter; | ||
16 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
17 | |||
18 | /** | ||
19 | * Note that there are some values written like -2147483647 - 1. This is the lower 32bit int max and is a known | ||
20 | * behavior of PHP. | ||
21 | */ | ||
22 | class NumberFormatterTest extends AbstractNumberFormatterTest | ||
23 | { | ||
24 | protected function setUp() | ||
25 | { | ||
26 | IntlTestHelper::requireIntl($this); | ||
27 | |||
28 | parent::setUp(); | ||
29 | } | ||
30 | |||
31 | /** | ||
32 | * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException | ||
33 | */ | ||
34 | public function testConstructorWithUnsupportedLocale() | ||
35 | { | ||
36 | new NumberFormatter('pt_BR'); | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException | ||
41 | */ | ||
42 | public function testConstructorWithUnsupportedStyle() | ||
43 | { | ||
44 | new NumberFormatter('en', NumberFormatter::PATTERN_DECIMAL); | ||
45 | } | ||
46 | |||
47 | /** | ||
48 | * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException | ||
49 | */ | ||
50 | public function testConstructorWithPatternDifferentThanNull() | ||
51 | { | ||
52 | new NumberFormatter('en', NumberFormatter::DECIMAL, ''); | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException | ||
57 | */ | ||
58 | public function testSetAttributeWithUnsupportedAttribute() | ||
59 | { | ||
60 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
61 | $formatter->setAttribute(NumberFormatter::LENIENT_PARSE, null); | ||
62 | } | ||
63 | |||
64 | /** | ||
65 | * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException | ||
66 | */ | ||
67 | public function testSetAttributeInvalidRoundingMode() | ||
68 | { | ||
69 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
70 | $formatter->setAttribute(NumberFormatter::ROUNDING_MODE, null); | ||
71 | } | ||
72 | |||
73 | public function testCreate() | ||
74 | { | ||
75 | $this->assertInstanceOf( | ||
76 | '\Symfony\Component\Intl\NumberFormatter\NumberFormatter', | ||
77 | NumberFormatter::create('en', NumberFormatter::DECIMAL) | ||
78 | ); | ||
79 | } | ||
80 | |||
81 | /** | ||
82 | * @expectedException \RuntimeException | ||
83 | */ | ||
84 | public function testFormatWithCurrencyStyle() | ||
85 | { | ||
86 | parent::testFormatWithCurrencyStyle(); | ||
87 | } | ||
88 | |||
89 | /** | ||
90 | * @dataProvider formatTypeInt32Provider | ||
91 | * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException | ||
92 | */ | ||
93 | public function testFormatTypeInt32($formatter, $value, $expected, $message = '') | ||
94 | { | ||
95 | parent::testFormatTypeInt32($formatter, $value, $expected, $message); | ||
96 | } | ||
97 | |||
98 | /** | ||
99 | * @dataProvider formatTypeInt32WithCurrencyStyleProvider | ||
100 | * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException | ||
101 | */ | ||
102 | public function testFormatTypeInt32WithCurrencyStyle($formatter, $value, $expected, $message = '') | ||
103 | { | ||
104 | parent::testFormatTypeInt32WithCurrencyStyle($formatter, $value, $expected, $message); | ||
105 | } | ||
106 | |||
107 | /** | ||
108 | * @dataProvider formatTypeInt64Provider | ||
109 | * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException | ||
110 | */ | ||
111 | public function testFormatTypeInt64($formatter, $value, $expected) | ||
112 | { | ||
113 | parent::testFormatTypeInt64($formatter, $value, $expected); | ||
114 | } | ||
115 | |||
116 | /** | ||
117 | * @dataProvider formatTypeInt64WithCurrencyStyleProvider | ||
118 | * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException | ||
119 | */ | ||
120 | public function testFormatTypeInt64WithCurrencyStyle($formatter, $value, $expected) | ||
121 | { | ||
122 | parent::testFormatTypeInt64WithCurrencyStyle($formatter, $value, $expected); | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * @dataProvider formatTypeDoubleProvider | ||
127 | * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException | ||
128 | */ | ||
129 | public function testFormatTypeDouble($formatter, $value, $expected) | ||
130 | { | ||
131 | parent::testFormatTypeDouble($formatter, $value, $expected); | ||
132 | } | ||
133 | |||
134 | /** | ||
135 | * @dataProvider formatTypeDoubleWithCurrencyStyleProvider | ||
136 | * @expectedException \Symfony\Component\Intl\Exception\NotImplementedException | ||
137 | */ | ||
138 | public function testFormatTypeDoubleWithCurrencyStyle($formatter, $value, $expected) | ||
139 | { | ||
140 | parent::testFormatTypeDoubleWithCurrencyStyle($formatter, $value, $expected); | ||
141 | } | ||
142 | |||
143 | /** | ||
144 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
145 | */ | ||
146 | public function testGetPattern() | ||
147 | { | ||
148 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
149 | $formatter->getPattern(); | ||
150 | } | ||
151 | |||
152 | /** | ||
153 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
154 | */ | ||
155 | public function testGetSymbol() | ||
156 | { | ||
157 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
158 | $formatter->getSymbol(null); | ||
159 | } | ||
160 | |||
161 | /** | ||
162 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
163 | */ | ||
164 | public function testGetTextAttribute() | ||
165 | { | ||
166 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
167 | $formatter->getTextAttribute(null); | ||
168 | } | ||
169 | |||
170 | public function testGetErrorCode() | ||
171 | { | ||
172 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
173 | $this->assertEquals(IntlGlobals::U_ZERO_ERROR, $formatter->getErrorCode()); | ||
174 | } | ||
175 | |||
176 | /** | ||
177 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
178 | */ | ||
179 | public function testParseCurrency() | ||
180 | { | ||
181 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
182 | $formatter->parseCurrency(null, $currency); | ||
183 | } | ||
184 | |||
185 | /** | ||
186 | * @expectedException \Symfony\Component\Intl\Exception\MethodArgumentNotImplementedException | ||
187 | */ | ||
188 | public function testParseWithNotNullPositionValue() | ||
189 | { | ||
190 | parent::testParseWithNotNullPositionValue(); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
195 | */ | ||
196 | public function testSetPattern() | ||
197 | { | ||
198 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
199 | $formatter->setPattern(null); | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
204 | */ | ||
205 | public function testSetSymbol() | ||
206 | { | ||
207 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
208 | $formatter->setSymbol(null, null); | ||
209 | } | ||
210 | |||
211 | /** | ||
212 | * @expectedException \Symfony\Component\Intl\Exception\MethodNotImplementedException | ||
213 | */ | ||
214 | public function testSetTextAttribute() | ||
215 | { | ||
216 | $formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL); | ||
217 | $formatter->setTextAttribute(null, null); | ||
218 | } | ||
219 | |||
220 | protected function getNumberFormatter($locale = 'en', $style = null, $pattern = null) | ||
221 | { | ||
222 | return new NumberFormatter($locale, $style, $pattern); | ||
223 | } | ||
224 | |||
225 | protected function getIntlErrorMessage() | ||
226 | { | ||
227 | return IntlGlobals::getErrorMessage(); | ||
228 | } | ||
229 | |||
230 | protected function getIntlErrorCode() | ||
231 | { | ||
232 | return IntlGlobals::getErrorCode(); | ||
233 | } | ||
234 | |||
235 | protected function isIntlFailure($errorCode) | ||
236 | { | ||
237 | return IntlGlobals::isFailure($errorCode); | ||
238 | } | ||
239 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php new file mode 100644 index 00000000..28e6fe90 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php | |||
@@ -0,0 +1,54 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\NumberFormatter\Verification; | ||
13 | |||
14 | use Symfony\Component\Intl\Tests\NumberFormatter\AbstractNumberFormatterTest; | ||
15 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
16 | |||
17 | /** | ||
18 | * Note that there are some values written like -2147483647 - 1. This is the lower 32bit int max and is a known | ||
19 | * behavior of PHP. | ||
20 | */ | ||
21 | class NumberFormatterTest extends AbstractNumberFormatterTest | ||
22 | { | ||
23 | protected function setUp() | ||
24 | { | ||
25 | IntlTestHelper::requireFullIntl($this); | ||
26 | |||
27 | parent::setUp(); | ||
28 | } | ||
29 | |||
30 | public function testCreate() | ||
31 | { | ||
32 | $this->assertInstanceOf('\NumberFormatter', \NumberFormatter::create('en', \NumberFormatter::DECIMAL)); | ||
33 | } | ||
34 | |||
35 | protected function getNumberFormatter($locale = 'en', $style = null, $pattern = null) | ||
36 | { | ||
37 | return new \NumberFormatter($locale, $style, $pattern); | ||
38 | } | ||
39 | |||
40 | protected function getIntlErrorMessage() | ||
41 | { | ||
42 | return intl_get_error_message(); | ||
43 | } | ||
44 | |||
45 | protected function getIntlErrorCode() | ||
46 | { | ||
47 | return intl_get_error_code(); | ||
48 | } | ||
49 | |||
50 | protected function isIntlFailure($errorCode) | ||
51 | { | ||
52 | return intl_is_failure($errorCode); | ||
53 | } | ||
54 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/AbstractBundleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/AbstractBundleTest.php new file mode 100644 index 00000000..6b075865 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/AbstractBundleTest.php | |||
@@ -0,0 +1,55 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\ResourceBundle; | ||
13 | |||
14 | /** | ||
15 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
16 | */ | ||
17 | class AbstractBundleTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | const RES_DIR = '/base/dirName'; | ||
20 | |||
21 | /** | ||
22 | * @var \Symfony\Component\Intl\ResourceBundle\AbstractBundle | ||
23 | */ | ||
24 | private $bundle; | ||
25 | |||
26 | /** | ||
27 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
28 | */ | ||
29 | private $reader; | ||
30 | |||
31 | protected function setUp() | ||
32 | { | ||
33 | $this->reader = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface'); | ||
34 | $this->bundle = $this->getMockForAbstractClass( | ||
35 | 'Symfony\Component\Intl\ResourceBundle\AbstractBundle', | ||
36 | array(self::RES_DIR, $this->reader) | ||
37 | ); | ||
38 | |||
39 | $this->bundle->expects($this->any()) | ||
40 | ->method('getDirectoryName') | ||
41 | ->will($this->returnValue('dirName')); | ||
42 | } | ||
43 | |||
44 | public function testGetLocales() | ||
45 | { | ||
46 | $locales = array('de', 'en', 'fr'); | ||
47 | |||
48 | $this->reader->expects($this->once()) | ||
49 | ->method('getLocales') | ||
50 | ->with(self::RES_DIR) | ||
51 | ->will($this->returnValue($locales)); | ||
52 | |||
53 | $this->assertSame($locales, $this->bundle->getLocales()); | ||
54 | } | ||
55 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/CurrencyBundleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/CurrencyBundleTest.php new file mode 100644 index 00000000..b66a6727 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/CurrencyBundleTest.php | |||
@@ -0,0 +1,98 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\ResourceBundle; | ||
13 | |||
14 | use Symfony\Component\Intl\ResourceBundle\CurrencyBundle; | ||
15 | |||
16 | /** | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class CurrencyBundleTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | const RES_DIR = '/base/curr'; | ||
22 | |||
23 | /** | ||
24 | * @var CurrencyBundle | ||
25 | */ | ||
26 | private $bundle; | ||
27 | |||
28 | /** | ||
29 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
30 | */ | ||
31 | private $reader; | ||
32 | |||
33 | protected function setUp() | ||
34 | { | ||
35 | $this->reader = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface'); | ||
36 | $this->bundle = new CurrencyBundle(self::RES_DIR, $this->reader); | ||
37 | } | ||
38 | |||
39 | public function testGetCurrencySymbol() | ||
40 | { | ||
41 | $this->reader->expects($this->once()) | ||
42 | ->method('readEntry') | ||
43 | ->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 1)) | ||
44 | ->will($this->returnValue('€')); | ||
45 | |||
46 | $this->assertSame('€', $this->bundle->getCurrencySymbol('EUR', 'en')); | ||
47 | } | ||
48 | |||
49 | public function testGetCurrencyName() | ||
50 | { | ||
51 | $this->reader->expects($this->once()) | ||
52 | ->method('readEntry') | ||
53 | ->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 0)) | ||
54 | ->will($this->returnValue('Euro')); | ||
55 | |||
56 | $this->assertSame('Euro', $this->bundle->getCurrencyName('EUR', 'en')); | ||
57 | } | ||
58 | |||
59 | public function testGetCurrencyNames() | ||
60 | { | ||
61 | $sortedCurrencies = array( | ||
62 | 'USD' => array(0 => 'Dollar'), | ||
63 | 'EUR' => array(0 => 'Euro'), | ||
64 | ); | ||
65 | |||
66 | $this->reader->expects($this->once()) | ||
67 | ->method('readEntry') | ||
68 | ->with(self::RES_DIR, 'en', array('Currencies')) | ||
69 | ->will($this->returnValue($sortedCurrencies)); | ||
70 | |||
71 | $sortedNames = array( | ||
72 | 'USD' => 'Dollar', | ||
73 | 'EUR' => 'Euro', | ||
74 | ); | ||
75 | |||
76 | $this->assertSame($sortedNames, $this->bundle->getCurrencyNames('en')); | ||
77 | } | ||
78 | |||
79 | public function testGetFractionDigits() | ||
80 | { | ||
81 | $this->reader->expects($this->once()) | ||
82 | ->method('readEntry') | ||
83 | ->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 2)) | ||
84 | ->will($this->returnValue(123)); | ||
85 | |||
86 | $this->assertSame(123, $this->bundle->getFractionDigits('EUR')); | ||
87 | } | ||
88 | |||
89 | public function testGetRoundingIncrement() | ||
90 | { | ||
91 | $this->reader->expects($this->once()) | ||
92 | ->method('readEntry') | ||
93 | ->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 3)) | ||
94 | ->will($this->returnValue(123)); | ||
95 | |||
96 | $this->assertSame(123, $this->bundle->getRoundingIncrement('EUR')); | ||
97 | } | ||
98 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/LanguageBundleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/LanguageBundleTest.php new file mode 100644 index 00000000..96031fc7 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/LanguageBundleTest.php | |||
@@ -0,0 +1,197 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\ResourceBundle; | ||
13 | |||
14 | use Symfony\Component\Intl\ResourceBundle\LanguageBundle; | ||
15 | |||
16 | /** | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class LanguageBundleTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | const RES_DIR = '/base/lang'; | ||
22 | |||
23 | /** | ||
24 | * @var LanguageBundle | ||
25 | */ | ||
26 | private $bundle; | ||
27 | |||
28 | /** | ||
29 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
30 | */ | ||
31 | private $reader; | ||
32 | |||
33 | protected function setUp() | ||
34 | { | ||
35 | $this->reader = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface'); | ||
36 | $this->bundle = new LanguageBundle(self::RES_DIR, $this->reader); | ||
37 | } | ||
38 | |||
39 | public function testGetLanguageName() | ||
40 | { | ||
41 | $languages = array( | ||
42 | 'de' => 'German', | ||
43 | 'en' => 'English', | ||
44 | ); | ||
45 | |||
46 | $this->reader->expects($this->once()) | ||
47 | ->method('readEntry') | ||
48 | ->with(self::RES_DIR, 'en', array('Languages')) | ||
49 | ->will($this->returnValue($languages)); | ||
50 | |||
51 | $this->assertSame('German', $this->bundle->getLanguageName('de', null, 'en')); | ||
52 | } | ||
53 | |||
54 | public function testGetLanguageNameWithRegion() | ||
55 | { | ||
56 | $languages = array( | ||
57 | 'de' => 'German', | ||
58 | 'en' => 'English', | ||
59 | 'en_GB' => 'British English', | ||
60 | ); | ||
61 | |||
62 | $this->reader->expects($this->once()) | ||
63 | ->method('readEntry') | ||
64 | ->with(self::RES_DIR, 'en', array('Languages')) | ||
65 | ->will($this->returnValue($languages)); | ||
66 | |||
67 | $this->assertSame('British English', $this->bundle->getLanguageName('en', 'GB', 'en')); | ||
68 | } | ||
69 | |||
70 | public function testGetLanguageNameWithUntranslatedRegion() | ||
71 | { | ||
72 | $languages = array( | ||
73 | 'de' => 'German', | ||
74 | 'en' => 'English', | ||
75 | ); | ||
76 | |||
77 | $this->reader->expects($this->once()) | ||
78 | ->method('readEntry') | ||
79 | ->with(self::RES_DIR, 'en', array('Languages')) | ||
80 | ->will($this->returnValue($languages)); | ||
81 | |||
82 | $this->assertSame('English', $this->bundle->getLanguageName('en', 'US', 'en')); | ||
83 | } | ||
84 | |||
85 | public function testGetLanguageNames() | ||
86 | { | ||
87 | $sortedLanguages = array( | ||
88 | 'en' => 'English', | ||
89 | 'de' => 'German', | ||
90 | ); | ||
91 | |||
92 | $this->reader->expects($this->once()) | ||
93 | ->method('readEntry') | ||
94 | ->with(self::RES_DIR, 'en', array('Languages')) | ||
95 | ->will($this->returnValue($sortedLanguages)); | ||
96 | |||
97 | $this->assertSame($sortedLanguages, $this->bundle->getLanguageNames('en')); | ||
98 | } | ||
99 | |||
100 | public function testGetScriptName() | ||
101 | { | ||
102 | $data = array( | ||
103 | 'Languages' => array( | ||
104 | 'de' => 'German', | ||
105 | 'en' => 'English', | ||
106 | ), | ||
107 | 'Scripts' => array( | ||
108 | 'Latn' => 'latin', | ||
109 | 'Cyrl' => 'cyrillique', | ||
110 | ), | ||
111 | ); | ||
112 | |||
113 | $this->reader->expects($this->once()) | ||
114 | ->method('read') | ||
115 | ->with(self::RES_DIR, 'en') | ||
116 | ->will($this->returnValue($data)); | ||
117 | |||
118 | $this->assertSame('latin', $this->bundle->getScriptName('Latn', null, 'en')); | ||
119 | } | ||
120 | |||
121 | public function testGetScriptNameIncludedInLanguage() | ||
122 | { | ||
123 | $data = array( | ||
124 | 'Languages' => array( | ||
125 | 'de' => 'German', | ||
126 | 'en' => 'English', | ||
127 | 'zh_Hans' => 'Simplified Chinese', | ||
128 | ), | ||
129 | 'Scripts' => array( | ||
130 | 'Latn' => 'latin', | ||
131 | 'Cyrl' => 'cyrillique', | ||
132 | ), | ||
133 | ); | ||
134 | |||
135 | $this->reader->expects($this->once()) | ||
136 | ->method('read') | ||
137 | ->with(self::RES_DIR, 'en') | ||
138 | ->will($this->returnValue($data)); | ||
139 | |||
140 | // Null because the script is included in the language anyway | ||
141 | $this->assertNull($this->bundle->getScriptName('Hans', 'zh', 'en')); | ||
142 | } | ||
143 | |||
144 | public function testGetScriptNameIncludedInLanguageInBraces() | ||
145 | { | ||
146 | $data = array( | ||
147 | 'Languages' => array( | ||
148 | 'de' => 'German', | ||
149 | 'en' => 'English', | ||
150 | 'zh_Hans' => 'Chinese (simplified)', | ||
151 | ), | ||
152 | 'Scripts' => array( | ||
153 | 'Latn' => 'latin', | ||
154 | 'Cyrl' => 'cyrillique', | ||
155 | ), | ||
156 | ); | ||
157 | |||
158 | $this->reader->expects($this->once()) | ||
159 | ->method('read') | ||
160 | ->with(self::RES_DIR, 'en') | ||
161 | ->will($this->returnValue($data)); | ||
162 | |||
163 | $this->assertSame('simplified', $this->bundle->getScriptName('Hans', 'zh', 'en')); | ||
164 | } | ||
165 | |||
166 | public function testGetScriptNameNoScriptsBlock() | ||
167 | { | ||
168 | $data = array( | ||
169 | 'Languages' => array( | ||
170 | 'de' => 'German', | ||
171 | 'en' => 'English', | ||
172 | ), | ||
173 | ); | ||
174 | |||
175 | $this->reader->expects($this->once()) | ||
176 | ->method('read') | ||
177 | ->with(self::RES_DIR, 'en') | ||
178 | ->will($this->returnValue($data)); | ||
179 | |||
180 | $this->assertNull($this->bundle->getScriptName('Latn', null, 'en')); | ||
181 | } | ||
182 | |||
183 | public function testGetScriptNames() | ||
184 | { | ||
185 | $sortedScripts = array( | ||
186 | 'Cyrl' => 'cyrillique', | ||
187 | 'Latn' => 'latin', | ||
188 | ); | ||
189 | |||
190 | $this->reader->expects($this->once()) | ||
191 | ->method('readEntry') | ||
192 | ->with(self::RES_DIR, 'en', array('Scripts')) | ||
193 | ->will($this->returnValue($sortedScripts)); | ||
194 | |||
195 | $this->assertSame($sortedScripts, $this->bundle->getScriptNames('en')); | ||
196 | } | ||
197 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/LocaleBundleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/LocaleBundleTest.php new file mode 100644 index 00000000..ddfdc3d2 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/LocaleBundleTest.php | |||
@@ -0,0 +1,64 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\ResourceBundle; | ||
13 | |||
14 | use Symfony\Component\Intl\ResourceBundle\LocaleBundle; | ||
15 | |||
16 | /** | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class LocaleBundleTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | const RES_DIR = '/base/locales'; | ||
22 | |||
23 | /** | ||
24 | * @var LocaleBundle | ||
25 | */ | ||
26 | private $bundle; | ||
27 | |||
28 | /** | ||
29 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
30 | */ | ||
31 | private $reader; | ||
32 | |||
33 | protected function setUp() | ||
34 | { | ||
35 | $this->reader = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface'); | ||
36 | $this->bundle = new LocaleBundle(self::RES_DIR, $this->reader); | ||
37 | } | ||
38 | |||
39 | public function testGetLocaleName() | ||
40 | { | ||
41 | $this->reader->expects($this->once()) | ||
42 | ->method('readEntry') | ||
43 | ->with(self::RES_DIR, 'en', array('Locales', 'de_AT')) | ||
44 | ->will($this->returnValue('German (Austria)')); | ||
45 | |||
46 | $this->assertSame('German (Austria)', $this->bundle->getLocaleName('de_AT', 'en')); | ||
47 | } | ||
48 | |||
49 | public function testGetLocaleNames() | ||
50 | { | ||
51 | $sortedLocales = array( | ||
52 | 'en_IE' => 'English (Ireland)', | ||
53 | 'en_GB' => 'English (United Kingdom)', | ||
54 | 'en_US' => 'English (United States)', | ||
55 | ); | ||
56 | |||
57 | $this->reader->expects($this->once()) | ||
58 | ->method('readEntry') | ||
59 | ->with(self::RES_DIR, 'en', array('Locales')) | ||
60 | ->will($this->returnValue($sortedLocales)); | ||
61 | |||
62 | $this->assertSame($sortedLocales, $this->bundle->getLocaleNames('en')); | ||
63 | } | ||
64 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/AbstractBundleReaderTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/AbstractBundleReaderTest.php new file mode 100644 index 00000000..2da7f90d --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/AbstractBundleReaderTest.php | |||
@@ -0,0 +1,64 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\ResourceBundle\Reader; | ||
13 | |||
14 | use Symfony\Component\Filesystem\Filesystem; | ||
15 | |||
16 | /** | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class AbstractBundleReaderTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | private $directory; | ||
22 | |||
23 | /** | ||
24 | * @var Filesystem | ||
25 | */ | ||
26 | private $filesystem; | ||
27 | |||
28 | /** | ||
29 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
30 | */ | ||
31 | private $reader; | ||
32 | |||
33 | protected function setUp() | ||
34 | { | ||
35 | $this->directory = sys_get_temp_dir() . '/AbstractBundleReaderTest/' . rand(1000, 9999); | ||
36 | $this->filesystem = new Filesystem(); | ||
37 | $this->reader = $this->getMockForAbstractClass('Symfony\Component\Intl\ResourceBundle\Reader\AbstractBundleReader'); | ||
38 | |||
39 | $this->filesystem->mkdir($this->directory); | ||
40 | } | ||
41 | |||
42 | protected function tearDown() | ||
43 | { | ||
44 | $this->filesystem->remove($this->directory); | ||
45 | } | ||
46 | |||
47 | public function testGetLocales() | ||
48 | { | ||
49 | $this->filesystem->touch($this->directory . '/en.foo'); | ||
50 | $this->filesystem->touch($this->directory . '/de.foo'); | ||
51 | $this->filesystem->touch($this->directory . '/fr.foo'); | ||
52 | $this->filesystem->touch($this->directory . '/bo.txt'); | ||
53 | $this->filesystem->touch($this->directory . '/gu.bin'); | ||
54 | $this->filesystem->touch($this->directory . '/s.lol'); | ||
55 | |||
56 | $this->reader->expects($this->any()) | ||
57 | ->method('getFileExtension') | ||
58 | ->will($this->returnValue('foo')); | ||
59 | |||
60 | $sortedLocales = array('de', 'en', 'fr'); | ||
61 | |||
62 | $this->assertSame($sortedLocales, $this->reader->getLocales($this->directory)); | ||
63 | } | ||
64 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/BinaryBundleReaderTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/BinaryBundleReaderTest.php new file mode 100644 index 00000000..3aefbae7 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/BinaryBundleReaderTest.php | |||
@@ -0,0 +1,58 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\ResourceBundle\Reader; | ||
13 | |||
14 | use Symfony\Component\Intl\ResourceBundle\Reader\BinaryBundleReader; | ||
15 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
16 | |||
17 | /** | ||
18 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
19 | */ | ||
20 | class BinaryBundleReaderTest extends \PHPUnit_Framework_TestCase | ||
21 | { | ||
22 | /** | ||
23 | * @var BinaryBundleReader | ||
24 | */ | ||
25 | private $reader; | ||
26 | |||
27 | protected function setUp() | ||
28 | { | ||
29 | IntlTestHelper::requireFullIntl($this); | ||
30 | |||
31 | $this->reader = new BinaryBundleReader(); | ||
32 | } | ||
33 | |||
34 | public function testReadReturnsArrayAccess() | ||
35 | { | ||
36 | $data = $this->reader->read(__DIR__ . '/Fixtures', 'en'); | ||
37 | |||
38 | $this->assertInstanceOf('\ArrayAccess', $data); | ||
39 | $this->assertSame('Bar', $data['Foo']); | ||
40 | $this->assertFalse(isset($data['ExistsNot'])); | ||
41 | } | ||
42 | |||
43 | /** | ||
44 | * @expectedException \Symfony\Component\Intl\Exception\RuntimeException | ||
45 | */ | ||
46 | public function testReadFailsIfNonExistingLocale() | ||
47 | { | ||
48 | $this->reader->read(__DIR__ . '/Fixtures', 'foo'); | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * @expectedException \Symfony\Component\Intl\Exception\RuntimeException | ||
53 | */ | ||
54 | public function testReadFailsIfNonExistingDirectory() | ||
55 | { | ||
56 | $this->reader->read(__DIR__ . '/foo', 'en'); | ||
57 | } | ||
58 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/NotAFile/en.php/.gitkeep b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/NotAFile/en.php/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/NotAFile/en.php/.gitkeep | |||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.php new file mode 100644 index 00000000..f2b06a91 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.php | |||
@@ -0,0 +1,14 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | return array( | ||
13 | 'Foo' => 'Bar', | ||
14 | ); | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.res b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.res new file mode 100644 index 00000000..c78e9045 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.res | |||
Binary files differ | |||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.txt b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.txt new file mode 100644 index 00000000..c788e996 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/en.txt | |||
@@ -0,0 +1,3 @@ | |||
1 | en{ | ||
2 | Foo{"Bar"} | ||
3 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/PhpBundleReaderTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/PhpBundleReaderTest.php new file mode 100644 index 00000000..2fee3559 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/PhpBundleReaderTest.php | |||
@@ -0,0 +1,63 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\ResourceBundle\Reader; | ||
13 | |||
14 | use Symfony\Component\Intl\ResourceBundle\Reader\PhpBundleReader; | ||
15 | |||
16 | /** | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class PhpBundleReaderTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | /** | ||
22 | * @var PhpBundleReader | ||
23 | */ | ||
24 | private $reader; | ||
25 | |||
26 | protected function setUp() | ||
27 | { | ||
28 | $this->reader = new PhpBundleReader(); | ||
29 | } | ||
30 | |||
31 | public function testReadReturnsArray() | ||
32 | { | ||
33 | $data = $this->reader->read(__DIR__ . '/Fixtures', 'en'); | ||
34 | |||
35 | $this->assertTrue(is_array($data)); | ||
36 | $this->assertSame('Bar', $data['Foo']); | ||
37 | $this->assertFalse(isset($data['ExistsNot'])); | ||
38 | } | ||
39 | |||
40 | /** | ||
41 | * @expectedException \Symfony\Component\Intl\Exception\InvalidArgumentException | ||
42 | */ | ||
43 | public function testReadFailsIfLocaleOtherThanEn() | ||
44 | { | ||
45 | $this->reader->read(__DIR__ . '/Fixtures', 'foo'); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * @expectedException \Symfony\Component\Intl\Exception\RuntimeException | ||
50 | */ | ||
51 | public function testReadFailsIfNonExistingDirectory() | ||
52 | { | ||
53 | $this->reader->read(__DIR__ . '/foo', 'en'); | ||
54 | } | ||
55 | |||
56 | /** | ||
57 | * @expectedException \Symfony\Component\Intl\Exception\RuntimeException | ||
58 | */ | ||
59 | public function testReadFailsIfNotAFile() | ||
60 | { | ||
61 | $this->reader->read(__DIR__ . '/Fixtures/NotAFile', 'en'); | ||
62 | } | ||
63 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php new file mode 100644 index 00000000..600236eb --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php | |||
@@ -0,0 +1,223 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\ResourceBundle\Reader; | ||
13 | |||
14 | use Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReader; | ||
15 | |||
16 | /** | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class StructuredBundleReaderTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | const RES_DIR = '/res/dir'; | ||
22 | |||
23 | /** | ||
24 | * @var StructuredBundleReader | ||
25 | */ | ||
26 | private $reader; | ||
27 | |||
28 | /** | ||
29 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
30 | */ | ||
31 | private $readerImpl; | ||
32 | |||
33 | protected function setUp() | ||
34 | { | ||
35 | $this->readerImpl = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface'); | ||
36 | $this->reader = new StructuredBundleReader($this->readerImpl); | ||
37 | } | ||
38 | |||
39 | public function testGetLocales() | ||
40 | { | ||
41 | $locales = array('en', 'de', 'fr'); | ||
42 | |||
43 | $this->readerImpl->expects($this->once()) | ||
44 | ->method('getLocales') | ||
45 | ->with(self::RES_DIR) | ||
46 | ->will($this->returnValue($locales)); | ||
47 | |||
48 | $this->assertSame($locales, $this->reader->getLocales(self::RES_DIR)); | ||
49 | } | ||
50 | |||
51 | public function testRead() | ||
52 | { | ||
53 | $data = array('foo', 'bar'); | ||
54 | |||
55 | $this->readerImpl->expects($this->once()) | ||
56 | ->method('read') | ||
57 | ->with(self::RES_DIR, 'en') | ||
58 | ->will($this->returnValue($data)); | ||
59 | |||
60 | $this->assertSame($data, $this->reader->read(self::RES_DIR, 'en')); | ||
61 | } | ||
62 | |||
63 | public function testReadEntryNoParams() | ||
64 | { | ||
65 | $data = array('foo', 'bar'); | ||
66 | |||
67 | $this->readerImpl->expects($this->once()) | ||
68 | ->method('read') | ||
69 | ->with(self::RES_DIR, 'en') | ||
70 | ->will($this->returnValue($data)); | ||
71 | |||
72 | $this->assertSame($data, $this->reader->readEntry(self::RES_DIR, 'en', array())); | ||
73 | } | ||
74 | |||
75 | public function testReadEntryWithParam() | ||
76 | { | ||
77 | $data = array('Foo' => array('Bar' => 'Baz')); | ||
78 | |||
79 | $this->readerImpl->expects($this->once()) | ||
80 | ->method('read') | ||
81 | ->with(self::RES_DIR, 'en') | ||
82 | ->will($this->returnValue($data)); | ||
83 | |||
84 | $this->assertSame('Baz', $this->reader->readEntry(self::RES_DIR, 'en', array('Foo', 'Bar'))); | ||
85 | } | ||
86 | |||
87 | public function testReadEntryWithUnresolvablePath() | ||
88 | { | ||
89 | $data = array('Foo' => 'Baz'); | ||
90 | |||
91 | $this->readerImpl->expects($this->once()) | ||
92 | ->method('read') | ||
93 | ->with(self::RES_DIR, 'en') | ||
94 | ->will($this->returnValue($data)); | ||
95 | |||
96 | $this->assertNull($this->reader->readEntry(self::RES_DIR, 'en', array('Foo', 'Bar'))); | ||
97 | } | ||
98 | |||
99 | public function readMergedEntryProvider() | ||
100 | { | ||
101 | return array( | ||
102 | array('foo', null, 'foo'), | ||
103 | array(null, 'foo', 'foo'), | ||
104 | array(array('foo', 'bar'), null, array('foo', 'bar')), | ||
105 | array(array('foo', 'bar'), array(), array('foo', 'bar')), | ||
106 | array(null, array('baz'), array('baz')), | ||
107 | array(array(), array('baz'), array('baz')), | ||
108 | array(array('foo', 'bar'), array('baz'), array('baz', 'foo', 'bar')), | ||
109 | ); | ||
110 | } | ||
111 | |||
112 | /** | ||
113 | * @dataProvider readMergedEntryProvider | ||
114 | */ | ||
115 | public function testReadMergedEntryNoParams($childData, $parentData, $result) | ||
116 | { | ||
117 | $this->readerImpl->expects($this->at(0)) | ||
118 | ->method('read') | ||
119 | ->with(self::RES_DIR, 'en_GB') | ||
120 | ->will($this->returnValue($childData)); | ||
121 | |||
122 | if (null === $childData || is_array($childData)) { | ||
123 | $this->readerImpl->expects($this->at(1)) | ||
124 | ->method('read') | ||
125 | ->with(self::RES_DIR, 'en') | ||
126 | ->will($this->returnValue($parentData)); | ||
127 | } | ||
128 | |||
129 | $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array(), true)); | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * @dataProvider readMergedEntryProvider | ||
134 | */ | ||
135 | public function testReadMergedEntryWithParams($childData, $parentData, $result) | ||
136 | { | ||
137 | $this->readerImpl->expects($this->at(0)) | ||
138 | ->method('read') | ||
139 | ->with(self::RES_DIR, 'en_GB') | ||
140 | ->will($this->returnValue(array('Foo' => array('Bar' => $childData)))); | ||
141 | |||
142 | if (null === $childData || is_array($childData)) { | ||
143 | $this->readerImpl->expects($this->at(1)) | ||
144 | ->method('read') | ||
145 | ->with(self::RES_DIR, 'en') | ||
146 | ->will($this->returnValue(array('Foo' => array('Bar' => $parentData)))); | ||
147 | } | ||
148 | |||
149 | $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); | ||
150 | } | ||
151 | |||
152 | public function testReadMergedEntryWithUnresolvablePath() | ||
153 | { | ||
154 | $this->readerImpl->expects($this->at(0)) | ||
155 | ->method('read') | ||
156 | ->with(self::RES_DIR, 'en_GB') | ||
157 | ->will($this->returnValue(array('Foo' => 'Baz'))); | ||
158 | |||
159 | $this->readerImpl->expects($this->at(1)) | ||
160 | ->method('read') | ||
161 | ->with(self::RES_DIR, 'en') | ||
162 | ->will($this->returnValue(array('Foo' => 'Bar'))); | ||
163 | |||
164 | $this->assertNull($this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); | ||
165 | } | ||
166 | |||
167 | public function testReadMergedEntryWithUnresolvablePathInParent() | ||
168 | { | ||
169 | $this->readerImpl->expects($this->at(0)) | ||
170 | ->method('read') | ||
171 | ->with(self::RES_DIR, 'en_GB') | ||
172 | ->will($this->returnValue(array('Foo' => array('Bar' => array('three'))))); | ||
173 | |||
174 | $this->readerImpl->expects($this->at(1)) | ||
175 | ->method('read') | ||
176 | ->with(self::RES_DIR, 'en') | ||
177 | ->will($this->returnValue(array('Foo' => 'Bar'))); | ||
178 | |||
179 | $result = array('three'); | ||
180 | |||
181 | $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); | ||
182 | } | ||
183 | |||
184 | public function testReadMergedEntryWithUnresolvablePathInChild() | ||
185 | { | ||
186 | $this->readerImpl->expects($this->at(0)) | ||
187 | ->method('read') | ||
188 | ->with(self::RES_DIR, 'en_GB') | ||
189 | ->will($this->returnValue(array('Foo' => 'Baz'))); | ||
190 | |||
191 | $this->readerImpl->expects($this->at(1)) | ||
192 | ->method('read') | ||
193 | ->with(self::RES_DIR, 'en') | ||
194 | ->will($this->returnValue(array('Foo' => array('Bar' => array('one', 'two'))))); | ||
195 | |||
196 | $result = array('one', 'two'); | ||
197 | |||
198 | $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); | ||
199 | } | ||
200 | |||
201 | /** | ||
202 | * @dataProvider readMergedEntryProvider | ||
203 | */ | ||
204 | public function testReadMergedEntryWithTraversables($childData, $parentData, $result) | ||
205 | { | ||
206 | $parentData = is_array($parentData) ? new \ArrayObject($parentData) : $parentData; | ||
207 | $childData = is_array($childData) ? new \ArrayObject($childData) : $childData; | ||
208 | |||
209 | $this->readerImpl->expects($this->at(0)) | ||
210 | ->method('read') | ||
211 | ->with(self::RES_DIR, 'en_GB') | ||
212 | ->will($this->returnValue(array('Foo' => array('Bar' => $childData)))); | ||
213 | |||
214 | if (null === $childData || $childData instanceof \ArrayObject) { | ||
215 | $this->readerImpl->expects($this->at(1)) | ||
216 | ->method('read') | ||
217 | ->with(self::RES_DIR, 'en') | ||
218 | ->will($this->returnValue(array('Foo' => array('Bar' => $parentData)))); | ||
219 | } | ||
220 | |||
221 | $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); | ||
222 | } | ||
223 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/RegionBundleTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/RegionBundleTest.php new file mode 100644 index 00000000..ccdf904c --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/RegionBundleTest.php | |||
@@ -0,0 +1,63 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\ResourceBundle; | ||
13 | |||
14 | use Symfony\Component\Intl\ResourceBundle\RegionBundle; | ||
15 | |||
16 | /** | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class RegionBundleTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | const RES_DIR = '/base/region'; | ||
22 | |||
23 | /** | ||
24 | * @var RegionBundle | ||
25 | */ | ||
26 | private $bundle; | ||
27 | |||
28 | /** | ||
29 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
30 | */ | ||
31 | private $reader; | ||
32 | |||
33 | protected function setUp() | ||
34 | { | ||
35 | $this->reader = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface'); | ||
36 | $this->bundle = new RegionBundle(self::RES_DIR, $this->reader); | ||
37 | } | ||
38 | |||
39 | public function testGetCountryName() | ||
40 | { | ||
41 | $this->reader->expects($this->once()) | ||
42 | ->method('readEntry') | ||
43 | ->with(self::RES_DIR, 'en', array('Countries', 'AT')) | ||
44 | ->will($this->returnValue('Austria')); | ||
45 | |||
46 | $this->assertSame('Austria', $this->bundle->getCountryName('AT', 'en')); | ||
47 | } | ||
48 | |||
49 | public function testGetCountryNames() | ||
50 | { | ||
51 | $sortedCountries = array( | ||
52 | 'AT' => 'Austria', | ||
53 | 'DE' => 'Germany', | ||
54 | ); | ||
55 | |||
56 | $this->reader->expects($this->once()) | ||
57 | ->method('readEntry') | ||
58 | ->with(self::RES_DIR, 'en', array('Countries')) | ||
59 | ->will($this->returnValue($sortedCountries)); | ||
60 | |||
61 | $this->assertSame($sortedCountries, $this->bundle->getCountryNames('en')); | ||
62 | } | ||
63 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Util/RingBufferTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Util/RingBufferTest.php new file mode 100644 index 00000000..d6f7d8a0 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Util/RingBufferTest.php | |||
@@ -0,0 +1,101 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\ResourceBundle\Util; | ||
13 | |||
14 | use Symfony\Component\Intl\ResourceBundle\Util\RingBuffer; | ||
15 | |||
16 | /** | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class RingBufferTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | /** | ||
22 | * @var RingBuffer | ||
23 | */ | ||
24 | private $buffer; | ||
25 | |||
26 | protected function setUp() | ||
27 | { | ||
28 | $this->buffer = new RingBuffer(2); | ||
29 | } | ||
30 | |||
31 | public function testWriteWithinBuffer() | ||
32 | { | ||
33 | $this->buffer[0] = 'foo'; | ||
34 | $this->buffer['bar'] = 'baz'; | ||
35 | |||
36 | $this->assertTrue(isset($this->buffer[0])); | ||
37 | $this->assertTrue(isset($this->buffer['bar'])); | ||
38 | $this->assertSame('foo', $this->buffer[0]); | ||
39 | $this->assertSame('baz', $this->buffer['bar']); | ||
40 | } | ||
41 | |||
42 | public function testWritePastBuffer() | ||
43 | { | ||
44 | $this->buffer[0] = 'foo'; | ||
45 | $this->buffer['bar'] = 'baz'; | ||
46 | $this->buffer[2] = 'bam'; | ||
47 | |||
48 | $this->assertTrue(isset($this->buffer['bar'])); | ||
49 | $this->assertTrue(isset($this->buffer[2])); | ||
50 | $this->assertSame('baz', $this->buffer['bar']); | ||
51 | $this->assertSame('bam', $this->buffer[2]); | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * @expectedException \Symfony\Component\Intl\Exception\OutOfBoundsException | ||
56 | */ | ||
57 | public function testReadNonExistingFails() | ||
58 | { | ||
59 | $this->buffer['foo']; | ||
60 | } | ||
61 | |||
62 | public function testQueryNonExisting() | ||
63 | { | ||
64 | $this->assertFalse(isset($this->buffer['foo'])); | ||
65 | } | ||
66 | |||
67 | public function testUnsetNonExistingSucceeds() | ||
68 | { | ||
69 | unset($this->buffer['foo']); | ||
70 | |||
71 | $this->assertFalse(isset($this->buffer['foo'])); | ||
72 | } | ||
73 | |||
74 | /** | ||
75 | * @expectedException \Symfony\Component\Intl\Exception\OutOfBoundsException | ||
76 | */ | ||
77 | public function testReadOverwrittenFails() | ||
78 | { | ||
79 | $this->buffer[0] = 'foo'; | ||
80 | $this->buffer['bar'] = 'baz'; | ||
81 | $this->buffer[2] = 'bam'; | ||
82 | |||
83 | $this->buffer[0]; | ||
84 | } | ||
85 | |||
86 | public function testQueryOverwritten() | ||
87 | { | ||
88 | $this->assertFalse(isset($this->buffer[0])); | ||
89 | } | ||
90 | |||
91 | public function testUnsetOverwrittenSucceeds() | ||
92 | { | ||
93 | $this->buffer[0] = 'foo'; | ||
94 | $this->buffer['bar'] = 'baz'; | ||
95 | $this->buffer[2] = 'bam'; | ||
96 | |||
97 | unset($this->buffer[0]); | ||
98 | |||
99 | $this->assertFalse(isset($this->buffer[0])); | ||
100 | } | ||
101 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.php new file mode 100644 index 00000000..1ded57a7 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.php | |||
@@ -0,0 +1,23 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | return array( | ||
13 | 'Entry1' => array( | ||
14 | 'Array' => array( | ||
15 | 0 => 'foo', | ||
16 | 1 => 'bar', | ||
17 | ), | ||
18 | 'Integer' => 5, | ||
19 | 'Boolean' => false, | ||
20 | 'Float' => 1.23, | ||
21 | ), | ||
22 | 'Entry2' => 'String', | ||
23 | ); | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.res b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.res new file mode 100644 index 00000000..7c1f71eb --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.res | |||
Binary files differ | |||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.txt b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.txt new file mode 100644 index 00000000..0ee0d7f2 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.txt | |||
@@ -0,0 +1,23 @@ | |||
1 | en{ | ||
2 | Entry1{ | ||
3 | Array{ | ||
4 | "foo", | ||
5 | "bar", | ||
6 | { | ||
7 | Key{"value"} | ||
8 | }, | ||
9 | } | ||
10 | Integer:int{5} | ||
11 | IntVector:intvector{ | ||
12 | 0, | ||
13 | 1, | ||
14 | 2, | ||
15 | 3, | ||
16 | } | ||
17 | FalseBoolean{"false"} | ||
18 | TrueBoolean{"true"} | ||
19 | Null{""} | ||
20 | Float{"1.23"} | ||
21 | } | ||
22 | Entry2{"String"} | ||
23 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/PhpBundleWriterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/PhpBundleWriterTest.php new file mode 100644 index 00000000..03302834 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/PhpBundleWriterTest.php | |||
@@ -0,0 +1,62 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\ResourceBundle\Writer; | ||
13 | |||
14 | use Symfony\Component\Filesystem\Filesystem; | ||
15 | use Symfony\Component\Intl\ResourceBundle\Writer\PhpBundleWriter; | ||
16 | |||
17 | /** | ||
18 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
19 | */ | ||
20 | class PhpBundleWriterTest extends \PHPUnit_Framework_TestCase | ||
21 | { | ||
22 | /** | ||
23 | * @var PhpBundleWriter | ||
24 | */ | ||
25 | private $writer; | ||
26 | |||
27 | private $directory; | ||
28 | |||
29 | /** | ||
30 | * @var Filesystem | ||
31 | */ | ||
32 | private $filesystem; | ||
33 | |||
34 | protected function setUp() | ||
35 | { | ||
36 | $this->writer = new PhpBundleWriter(); | ||
37 | $this->directory = sys_get_temp_dir() . '/PhpBundleWriterTest/' . rand(1000, 9999); | ||
38 | $this->filesystem = new Filesystem(); | ||
39 | |||
40 | $this->filesystem->mkdir($this->directory); | ||
41 | } | ||
42 | |||
43 | protected function tearDown() | ||
44 | { | ||
45 | $this->filesystem->remove($this->directory); | ||
46 | } | ||
47 | |||
48 | public function testWrite() | ||
49 | { | ||
50 | $this->writer->write($this->directory, 'en', array( | ||
51 | 'Entry1' => array( | ||
52 | 'Array' => array('foo', 'bar'), | ||
53 | 'Integer' => 5, | ||
54 | 'Boolean' => false, | ||
55 | 'Float' => 1.23, | ||
56 | ), | ||
57 | 'Entry2' => 'String', | ||
58 | )); | ||
59 | |||
60 | $this->assertFileEquals(__DIR__ . '/Fixtures/en.php', $this->directory . '/en.php'); | ||
61 | } | ||
62 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php new file mode 100644 index 00000000..cbe0c8d8 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php | |||
@@ -0,0 +1,67 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\ResourceBundle\Writer; | ||
13 | |||
14 | use Symfony\Component\Filesystem\Filesystem; | ||
15 | use Symfony\Component\Intl\ResourceBundle\Writer\TextBundleWriter; | ||
16 | |||
17 | /** | ||
18 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
19 | * | ||
20 | * @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt | ||
21 | */ | ||
22 | class TextBundleWriterTest extends \PHPUnit_Framework_TestCase | ||
23 | { | ||
24 | /** | ||
25 | * @var TextBundleWriter | ||
26 | */ | ||
27 | private $writer; | ||
28 | |||
29 | private $directory; | ||
30 | |||
31 | /** | ||
32 | * @var Filesystem | ||
33 | */ | ||
34 | private $filesystem; | ||
35 | |||
36 | protected function setUp() | ||
37 | { | ||
38 | $this->writer = new TextBundleWriter(); | ||
39 | $this->directory = sys_get_temp_dir() . '/TextBundleWriterTest/' . rand(1000, 9999); | ||
40 | $this->filesystem = new Filesystem(); | ||
41 | |||
42 | $this->filesystem->mkdir($this->directory); | ||
43 | } | ||
44 | |||
45 | protected function tearDown() | ||
46 | { | ||
47 | $this->filesystem->remove($this->directory); | ||
48 | } | ||
49 | |||
50 | public function testWrite() | ||
51 | { | ||
52 | $this->writer->write($this->directory, 'en', array( | ||
53 | 'Entry1' => array( | ||
54 | 'Array' => array('foo', 'bar', array('Key' => 'value')), | ||
55 | 'Integer' => 5, | ||
56 | 'IntVector' => array(0, 1, 2, 3), | ||
57 | 'FalseBoolean' => false, | ||
58 | 'TrueBoolean' => true, | ||
59 | 'Null' => null, | ||
60 | 'Float' => 1.23, | ||
61 | ), | ||
62 | 'Entry2' => 'String', | ||
63 | )); | ||
64 | |||
65 | $this->assertFileEquals(__DIR__ . '/Fixtures/en.txt', $this->directory . '/en.txt'); | ||
66 | } | ||
67 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php new file mode 100644 index 00000000..d1a7e8c1 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php | |||
@@ -0,0 +1,111 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\Util; | ||
13 | |||
14 | use Symfony\Component\Intl\Util\IcuVersion; | ||
15 | |||
16 | /** | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class IcuVersionTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | public function normalizeProvider() | ||
22 | { | ||
23 | return array( | ||
24 | array(null, '1', '10'), | ||
25 | array(null, '1.2', '12'), | ||
26 | array(null, '1.2.3', '12.3'), | ||
27 | array(null, '1.2.3.4', '12.3.4'), | ||
28 | array(1, '1', '10'), | ||
29 | array(1, '1.2', '12'), | ||
30 | array(1, '1.2.3', '12'), | ||
31 | array(1, '1.2.3.4', '12'), | ||
32 | array(2, '1', '10'), | ||
33 | array(2, '1.2', '12'), | ||
34 | array(2, '1.2.3', '12.3'), | ||
35 | array(2, '1.2.3.4', '12.3'), | ||
36 | array(3, '1', '10'), | ||
37 | array(3, '1.2', '12'), | ||
38 | array(3, '1.2.3', '12.3'), | ||
39 | array(3, '1.2.3.4', '12.3.4'), | ||
40 | ); | ||
41 | } | ||
42 | |||
43 | /** | ||
44 | * @dataProvider normalizeProvider | ||
45 | */ | ||
46 | public function testNormalize($precision, $version, $result) | ||
47 | { | ||
48 | $this->assertSame($result, IcuVersion::normalize($version, $precision)); | ||
49 | } | ||
50 | |||
51 | public function compareProvider() | ||
52 | { | ||
53 | return array( | ||
54 | array(null, '1', '==', '1', true), | ||
55 | array(null, '1.0', '==', '1.1', false), | ||
56 | array(null, '1.0.0', '==', '1.0.1', false), | ||
57 | array(null, '1.0.0.0', '==', '1.0.0.1', false), | ||
58 | array(null, '1.0.0.0.0', '==', '1.0.0.0.1', false), | ||
59 | |||
60 | array(null, '1', '==', '10', true), | ||
61 | array(null, '1.0', '==', '11', false), | ||
62 | array(null, '1.0.0', '==', '10.1', false), | ||
63 | array(null, '1.0.0.0', '==', '10.0.1', false), | ||
64 | array(null, '1.0.0.0.0', '==', '10.0.0.1', false), | ||
65 | |||
66 | array(1, '1', '==', '1', true), | ||
67 | array(1, '1.0', '==', '1.1', false), | ||
68 | array(1, '1.0.0', '==', '1.0.1', true), | ||
69 | array(1, '1.0.0.0', '==', '1.0.0.1', true), | ||
70 | array(1, '1.0.0.0.0', '==', '1.0.0.0.1', true), | ||
71 | |||
72 | array(1, '1', '==', '10', true), | ||
73 | array(1, '1.0', '==', '11', false), | ||
74 | array(1, '1.0.0', '==', '10.1', true), | ||
75 | array(1, '1.0.0.0', '==', '10.0.1', true), | ||
76 | array(1, '1.0.0.0.0', '==', '10.0.0.1', true), | ||
77 | |||
78 | array(2, '1', '==', '1', true), | ||
79 | array(2, '1.0', '==', '1.1', false), | ||
80 | array(2, '1.0.0', '==', '1.0.1', false), | ||
81 | array(2, '1.0.0.0', '==', '1.0.0.1', true), | ||
82 | array(2, '1.0.0.0.0', '==', '1.0.0.0.1', true), | ||
83 | |||
84 | array(2, '1', '==', '10', true), | ||
85 | array(2, '1.0', '==', '11', false), | ||
86 | array(2, '1.0.0', '==', '10.1', false), | ||
87 | array(2, '1.0.0.0', '==', '10.0.1', true), | ||
88 | array(2, '1.0.0.0.0', '==', '10.0.0.1', true), | ||
89 | |||
90 | array(3, '1', '==', '1', true), | ||
91 | array(3, '1.0', '==', '1.1', false), | ||
92 | array(3, '1.0.0', '==', '1.0.1', false), | ||
93 | array(3, '1.0.0.0', '==', '1.0.0.1', false), | ||
94 | array(3, '1.0.0.0.0', '==', '1.0.0.0.1', true), | ||
95 | |||
96 | array(3, '1', '==', '10', true), | ||
97 | array(3, '1.0', '==', '11', false), | ||
98 | array(3, '1.0.0', '==', '10.1', false), | ||
99 | array(3, '1.0.0.0', '==', '10.0.1', false), | ||
100 | array(3, '1.0.0.0.0', '==', '10.0.0.1', true), | ||
101 | ); | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * @dataProvider compareProvider | ||
106 | */ | ||
107 | public function testCompare($precision, $version1, $operator, $version2, $result) | ||
108 | { | ||
109 | $this->assertSame($result, IcuVersion::compare($version1, $version2, $operator, $precision)); | ||
110 | } | ||
111 | } | ||
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/VersionTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/VersionTest.php new file mode 100644 index 00000000..60cec6c0 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/VersionTest.php | |||
@@ -0,0 +1,87 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\Tests\Util; | ||
13 | |||
14 | use Symfony\Component\Intl\Util\Version; | ||
15 | |||
16 | /** | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class VersionTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | public function normalizeProvider() | ||
22 | { | ||
23 | return array( | ||
24 | array(null, '1', '1'), | ||
25 | array(null, '1.2', '1.2'), | ||
26 | array(null, '1.2.3', '1.2.3'), | ||
27 | array(null, '1.2.3.4', '1.2.3.4'), | ||
28 | array(1, '1', '1'), | ||
29 | array(1, '1.2', '1'), | ||
30 | array(1, '1.2.3', '1'), | ||
31 | array(1, '1.2.3.4', '1'), | ||
32 | array(2, '1', '1'), | ||
33 | array(2, '1.2', '1.2'), | ||
34 | array(2, '1.2.3', '1.2'), | ||
35 | array(2, '1.2.3.4', '1.2'), | ||
36 | array(3, '1', '1'), | ||
37 | array(3, '1.2', '1.2'), | ||
38 | array(3, '1.2.3', '1.2.3'), | ||
39 | array(3, '1.2.3.4', '1.2.3'), | ||
40 | array(4, '1', '1'), | ||
41 | array(4, '1.2', '1.2'), | ||
42 | array(4, '1.2.3', '1.2.3'), | ||
43 | array(4, '1.2.3.4', '1.2.3.4'), | ||
44 | ); | ||
45 | } | ||
46 | |||
47 | /** | ||
48 | * @dataProvider normalizeProvider | ||
49 | */ | ||
50 | public function testNormalize($precision, $version, $result) | ||
51 | { | ||
52 | $this->assertSame($result, Version::normalize($version, $precision)); | ||
53 | } | ||
54 | |||
55 | public function compareProvider() | ||
56 | { | ||
57 | return array( | ||
58 | array(null, '1', '==', '1', true), | ||
59 | array(null, '1.0', '==', '1.1', false), | ||
60 | array(null, '1.0.0', '==', '1.0.1', false), | ||
61 | array(null, '1.0.0.0', '==', '1.0.0.1', false), | ||
62 | |||
63 | array(1, '1', '==', '1', true), | ||
64 | array(1, '1.0', '==', '1.1', true), | ||
65 | array(1, '1.0.0', '==', '1.0.1', true), | ||
66 | array(1, '1.0.0.0', '==', '1.0.0.1', true), | ||
67 | |||
68 | array(2, '1', '==', '1', true), | ||
69 | array(2, '1.0', '==', '1.1', false), | ||
70 | array(2, '1.0.0', '==', '1.0.1', true), | ||
71 | array(2, '1.0.0.0', '==', '1.0.0.1', true), | ||
72 | |||
73 | array(3, '1', '==', '1', true), | ||
74 | array(3, '1.0', '==', '1.1', false), | ||
75 | array(3, '1.0.0', '==', '1.0.1', false), | ||
76 | array(3, '1.0.0.0', '==', '1.0.0.1', true), | ||
77 | ); | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | * @dataProvider compareProvider | ||
82 | */ | ||
83 | public function testCompare($precision, $version1, $operator, $version2, $result) | ||
84 | { | ||
85 | $this->assertSame($result, Version::compare($version1, $version2, $operator, $precision)); | ||
86 | } | ||
87 | } | ||