summaryrefslogtreecommitdiff
path: root/ext/intl
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2017-10-20 13:55:32 +0200
committerAnatol Belski <ab@php.net>2017-10-20 13:55:32 +0200
commit877e0b04bc476859e21d48ae349c2a994987fdb0 (patch)
tree874bb3e81f800b5d64f87533db8f8a28080e908f /ext/intl
parent9071ff5c872ece8c94c3863e1b6852d7f579c269 (diff)
downloadphp-git-877e0b04bc476859e21d48ae349c2a994987fdb0.tar.gz
Sync some tests for compat with ICU 58.1+
Diffstat (limited to 'ext/intl')
-rw-r--r--ext/intl/tests/breakiter_getPartsIterator_basic.phpt6
-rw-r--r--ext/intl/tests/breakiter_getPartsIterator_basic2.phpt39
-rw-r--r--ext/intl/tests/breakiter_preceding_basic.phpt6
-rw-r--r--ext/intl/tests/breakiter_preceding_basic2.phpt25
-rw-r--r--ext/intl/tests/dateformat_create_cal_arg_variant4.phpt1
-rw-r--r--ext/intl/tests/dateformat_create_cal_arg_variant5.phpt54
-rw-r--r--ext/intl/tests/dateformat_get_set_calendar_variant4.phpt1
-rw-r--r--ext/intl/tests/dateformat_get_set_calendar_variant5.phpt56
-rw-r--r--ext/intl/tests/uconverter_oop_callback.phpt1
-rw-r--r--ext/intl/tests/uconverter_oop_callback2.phpt57
10 files changed, 242 insertions, 4 deletions
diff --git a/ext/intl/tests/breakiter_getPartsIterator_basic.phpt b/ext/intl/tests/breakiter_getPartsIterator_basic.phpt
index 36ad80d5fb..58516ea745 100644
--- a/ext/intl/tests/breakiter_getPartsIterator_basic.phpt
+++ b/ext/intl/tests/breakiter_getPartsIterator_basic.phpt
@@ -1,9 +1,11 @@
--TEST--
-IntlBreakIterator::getPartsIterator(): basic test
+IntlBreakIterator::getPartsIterator(): basic test, ICU <= 57.1
--SKIPIF--
<?php
if (!extension_loaded('intl'))
die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '57.1') >= 0) die('skip for ICU <= 57.1');
+?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
@@ -34,4 +36,4 @@ Array
[2] => bar
)
int(0)
-==DONE== \ No newline at end of file
+==DONE==
diff --git a/ext/intl/tests/breakiter_getPartsIterator_basic2.phpt b/ext/intl/tests/breakiter_getPartsIterator_basic2.phpt
new file mode 100644
index 0000000000..c802f963af
--- /dev/null
+++ b/ext/intl/tests/breakiter_getPartsIterator_basic2.phpt
@@ -0,0 +1,39 @@
+--TEST--
+IntlBreakIterator::getPartsIterator(): basic test, ICU >= 58.1
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '57.1') < 0) die('skip for ICU >= 58.1');
+?>
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+
+$bi = IntlBreakIterator::createWordInstance('pt');
+$pi = $bi->getPartsIterator();
+var_dump(get_class($pi));
+print_r(iterator_to_array($pi));
+
+$bi->setText("foo bar");
+$pi = $bi->getPartsIterator();
+var_dump(get_class($pi->getBreakIterator()));
+print_r(iterator_to_array($pi));
+var_dump($pi->getRuleStatus());
+?>
+==DONE==
+--EXPECT--
+string(17) "IntlPartsIterator"
+Array
+(
+)
+string(26) "IntlRuleBasedBreakIterator"
+Array
+(
+ [0] => foo
+ [1] =>
+ [2] => bar
+)
+int(200)
+==DONE==
diff --git a/ext/intl/tests/breakiter_preceding_basic.phpt b/ext/intl/tests/breakiter_preceding_basic.phpt
index 6fa8dd7fa7..7ef8804c4f 100644
--- a/ext/intl/tests/breakiter_preceding_basic.phpt
+++ b/ext/intl/tests/breakiter_preceding_basic.phpt
@@ -1,9 +1,11 @@
--TEST--
-IntlBreakIterator::preceding(): basic test
+IntlBreakIterator::preceding(): basic test, ICU <= 57.1
--SKIPIF--
<?php
if (!extension_loaded('intl'))
die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '57.1') >= 0) die('skip for ICU <= 57.1');
+?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
@@ -21,4 +23,4 @@ var_dump($bi->preceding(-1));
int(4)
int(21)
int(0)
-==DONE== \ No newline at end of file
+==DONE==
diff --git a/ext/intl/tests/breakiter_preceding_basic2.phpt b/ext/intl/tests/breakiter_preceding_basic2.phpt
new file mode 100644
index 0000000000..e84e5fc469
--- /dev/null
+++ b/ext/intl/tests/breakiter_preceding_basic2.phpt
@@ -0,0 +1,25 @@
+--TEST--
+IntlBreakIterator::preceding(): basic test, ICU >= 58.1
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+if (version_compare(INTL_ICU_VERSION, '57.1') < 0) die('skip for ICU >= 58.1');
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+
+$bi = IntlBreakIterator::createWordInstance('pt');
+$bi->setText('foo bar trans zoo bee');
+
+var_dump($bi->preceding(5));
+var_dump($bi->preceding(50));
+var_dump($bi->preceding(-1));
+?>
+==DONE==
+--EXPECT--
+int(4)
+int(21)
+int(-1)
+==DONE==
diff --git a/ext/intl/tests/dateformat_create_cal_arg_variant4.phpt b/ext/intl/tests/dateformat_create_cal_arg_variant4.phpt
index 4086e4558a..4796b93abd 100644
--- a/ext/intl/tests/dateformat_create_cal_arg_variant4.phpt
+++ b/ext/intl/tests/dateformat_create_cal_arg_variant4.phpt
@@ -4,6 +4,7 @@ IntlDateFormatter: several forms of the calendar arg
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '57.1') >= 0) die('skip for ICU <= 57.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
diff --git a/ext/intl/tests/dateformat_create_cal_arg_variant5.phpt b/ext/intl/tests/dateformat_create_cal_arg_variant5.phpt
new file mode 100644
index 0000000000..b42d0b3dad
--- /dev/null
+++ b/ext/intl/tests/dateformat_create_cal_arg_variant5.phpt
@@ -0,0 +1,54 @@
+--TEST--
+IntlDateFormatter: several forms of the calendar arg
+--SKIPIF--
+<?php
+if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '57.1') < 0) die('skip for ICU >= 58.1'); ?>
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+$ts = strtotime('2012-01-01 00:00:00 UTC');
+
+$cal = new IntlGregorianCalendar('UTC', NULL);
+$df = new IntlDateFormatter('es_ES', 0, 0, NULL, $cal);
+echo $df->format($ts), "\n";
+
+$cal = IntlCalendar::createInstance('UTC', 'en@calendar=islamic');
+$df = new IntlDateFormatter('es_ES', 0, 0, NULL, $cal);
+echo $df->format($ts), "\n";
+
+//override calendar's timezone
+$cal = new IntlGregorianCalendar('UTC', NULL);
+$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Madrid', $cal);
+echo $df->format($ts), "\n";
+
+//default calendar is gregorian
+$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0);
+echo $df->format($ts), "\n";
+
+//try now with traditional
+$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, NULL, IntlDateFormatter::TRADITIONAL);
+echo $df->format($ts), "\n";
+
+//the timezone can be overridden when not specifying a calendar
+$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, 'UTC', IntlDateFormatter::TRADITIONAL);
+echo $df->format($ts), "\n";
+
+$df = new IntlDateFormatter('es_ES', 0, 0, 'UTC', 0);
+echo $df->format($ts), "\n";
+
+?>
+==DONE==
+--EXPECTF--
+domingo%S 1 de enero de 2012, 0:00:00 (tiempo universal coordinado)
+domingo%S 8 de safar de 1433, 0:00:00 (tiempo universal coordinado)
+domingo, 1 de enero de 2012, 1:00:00 (hora estándar de Europa central)
+sábado, 31 de diciembre de 2011 d. C., 23:00:00 (hora estándar de las Azores)
+sábado, 7 de safar de 1433 AH, 23:00:00 (hora estándar de las Azores)
+domingo%S 8 de safar de 1433 AH, 0:00:00 (tiempo universal coordinado)
+domingo%S 1 de enero de 2012, 0:00:00 (tiempo universal coordinado)
+==DONE==
diff --git a/ext/intl/tests/dateformat_get_set_calendar_variant4.phpt b/ext/intl/tests/dateformat_get_set_calendar_variant4.phpt
index dc9db09740..884f46980d 100644
--- a/ext/intl/tests/dateformat_get_set_calendar_variant4.phpt
+++ b/ext/intl/tests/dateformat_get_set_calendar_variant4.phpt
@@ -4,6 +4,7 @@ IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject()
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '57.1') >= 0) die('skip for ICU <= 57.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
diff --git a/ext/intl/tests/dateformat_get_set_calendar_variant5.phpt b/ext/intl/tests/dateformat_get_set_calendar_variant5.phpt
new file mode 100644
index 0000000000..de16dc89b3
--- /dev/null
+++ b/ext/intl/tests/dateformat_get_set_calendar_variant5.phpt
@@ -0,0 +1,56 @@
+--TEST--
+IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject()
+--SKIPIF--
+<?php
+if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '57.1') < 0) die('skip for ICU >= 58.1'); ?>
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", 'Atlantic/Azores');
+
+$ts = strtotime('2012-01-01 00:00:00 UTC');
+
+function d(IntlDateFormatter $df) {
+global $ts;
+echo $df->format($ts), "\n";
+var_dump($df->getCalendar(),
+$df->getCalendarObject()->getType(),
+$df->getCalendarObject()->getTimeZone()->getId());
+echo "\n";
+}
+
+$df = new IntlDateFormatter('fr@calendar=islamic', 0, 0, 'Europe/Minsk');
+d($df);
+
+
+//changing the calendar with a cal type should not change tz
+$df->setCalendar(IntlDateFormatter::TRADITIONAL);
+d($df);
+
+//but changing with an actual calendar should
+$cal = IntlCalendar::createInstance("UTC");
+$df->setCalendar($cal);
+d($df);
+
+?>
+==DONE==
+--EXPECT--
+dimanche 1 janvier 2012 ap. J.-C. à 03:00:00 heure de Kaliningrad
+int(1)
+string(9) "gregorian"
+string(12) "Europe/Minsk"
+
+dimanche 8 safar 1433 AH à 03:00:00 heure de Kaliningrad
+int(0)
+string(7) "islamic"
+string(12) "Europe/Minsk"
+
+dimanche 1 janvier 2012 ap. J.-C. à 00:00:00 Temps universel coordonné
+bool(false)
+string(9) "gregorian"
+string(3) "UTC"
+
+==DONE==
diff --git a/ext/intl/tests/uconverter_oop_callback.phpt b/ext/intl/tests/uconverter_oop_callback.phpt
index 47daf43305..9e79b543b2 100644
--- a/ext/intl/tests/uconverter_oop_callback.phpt
+++ b/ext/intl/tests/uconverter_oop_callback.phpt
@@ -2,6 +2,7 @@
UConverter::convert() w/ Callback Reasons
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if (version_compare(INTL_ICU_VERSION, '57.1') >= 0) die('skip for ICU <= 57.1'); ?>
--FILE--
<?php
class MyConverter extends UConverter {
diff --git a/ext/intl/tests/uconverter_oop_callback2.phpt b/ext/intl/tests/uconverter_oop_callback2.phpt
new file mode 100644
index 0000000000..dba70be460
--- /dev/null
+++ b/ext/intl/tests/uconverter_oop_callback2.phpt
@@ -0,0 +1,57 @@
+--TEST--
+UConverter::convert() w/ Callback Reasons
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+<?php if (version_compare(INTL_ICU_VERSION, '57.1') < 0) die('skip for ICU >= 58.1'); ?>
+--FILE--
+<?php
+class MyConverter extends UConverter {
+ /**
+ * Called during conversion from source encoding to internal UChar representation
+ */
+ public function toUCallback($reason, $source, $codeUnits, &$error) {
+ echo "toUCallback(", UConverter::reasonText($reason), ", ...)\n";
+ return parent::toUCallback($reason, $source, $codeUnits, $error);
+ }
+
+ /**
+ * Called during conversion from internal UChar to destination encoding
+ */
+ public function fromUCallback($reason, $source, $codePoint, &$error) {
+ echo "fromUCallback(", UConverter::reasonText($reason), ", ...)\n";
+ return parent::fromUCallback($reason, $source, $codePoint, $error);
+ }
+
+}
+
+$c = new MyConverter('ascii', 'utf-8');
+foreach(array("regular", "irregul\xC1\xA1r", "\xC2\xA1unsupported!") as $word) {
+ $c->convert($word);
+}
+--EXPECT--
+toUCallback(REASON_RESET, ...)
+toUCallback(REASON_RESET, ...)
+fromUCallback(REASON_RESET, ...)
+fromUCallback(REASON_RESET, ...)
+toUCallback(REASON_RESET, ...)
+toUCallback(REASON_ILLEGAL, ...)
+toUCallback(REASON_RESET, ...)
+toUCallback(REASON_ILLEGAL, ...)
+fromUCallback(REASON_RESET, ...)
+fromUCallback(REASON_UNASSIGNED, ...)
+fromUCallback(REASON_RESET, ...)
+fromUCallback(REASON_UNASSIGNED, ...)
+toUCallback(REASON_RESET, ...)
+toUCallback(REASON_RESET, ...)
+fromUCallback(REASON_RESET, ...)
+fromUCallback(REASON_UNASSIGNED, ...)
+fromUCallback(REASON_RESET, ...)
+fromUCallback(REASON_UNASSIGNED, ...)
+toUCallback(REASON_CLOSE, ...)
+fromUCallback(REASON_CLOSE, ...)
+toUCallback(REASON_CLOSE, ...)
+fromUCallback(REASON_CLOSE, ...)
+toUCallback(REASON_ILLEGAL, ...)
+toUCallback(REASON_ILLEGAL, ...)
+fromUCallback(REASON_UNASSIGNED, ...)
+fromUCallback(REASON_UNASSIGNED, ...)