diff options
Diffstat (limited to 'ext/intl/tests')
217 files changed, 7374 insertions, 103 deletions
diff --git a/ext/intl/tests/badargs.phpt b/ext/intl/tests/badargs.phpt index 9232bbf0c1..b8f48b371e 100644 --- a/ext/intl/tests/badargs.phpt +++ b/ext/intl/tests/badargs.phpt @@ -13,7 +13,10 @@ foreach($funcs as $func) { if($rfunc->getNumberOfRequiredParameters() == 0) { continue; } - $res = $func($arg); + + try { + $res = $func($arg); + } catch (Exception $e) { continue; } if($res != false) { echo "$func: "; var_dump($res); diff --git a/ext/intl/tests/breakiter___construct.phpt b/ext/intl/tests/breakiter___construct.phpt new file mode 100644 index 0000000000..a818075a30 --- /dev/null +++ b/ext/intl/tests/breakiter___construct.phpt @@ -0,0 +1,14 @@ +--TEST-- +IntlBreakIterator::__construct() should not be callable +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +new IntlBreakIterator(); +--EXPECTF-- + +Fatal error: Call to private IntlBreakIterator::__construct() from invalid context in %s on line %d diff --git a/ext/intl/tests/breakiter___construct_error.phpt b/ext/intl/tests/breakiter___construct_error.phpt new file mode 100644 index 0000000000..770f1403c7 --- /dev/null +++ b/ext/intl/tests/breakiter___construct_error.phpt @@ -0,0 +1,38 @@ +--TEST-- +IntlRuleBasedBreakIterator::__construct(): arg errors +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip ICU >= 4.8 only'; ?> +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +//missing ; at the end: +var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+')); +var_dump(new IntlRuleBasedBreakIterator()); +var_dump(new IntlRuleBasedBreakIterator(1,2,3)); +var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;', array())); +var_dump(new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;', true)); + +--EXPECTF-- + +Warning: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create RuleBasedBreakIterator from rules (parse error on line 1, offset 31) in %s on line %d +NULL + +Warning: IntlRuleBasedBreakIterator::__construct() expects at least 1 parameter, 0 given in %s on line %d + +Warning: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: bad arguments in %s on line %d +NULL + +Warning: IntlRuleBasedBreakIterator::__construct() expects at most 2 parameters, 3 given in %s on line %d + +Warning: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: bad arguments in %s on line %d +NULL + +Warning: IntlRuleBasedBreakIterator::__construct() expects parameter 2 to be boolean, array given in %s on line %d + +Warning: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: bad arguments in %s on line %d +NULL + +Warning: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create instance from compiled rules in %s on line %d +NULL diff --git a/ext/intl/tests/breakiter_clone_basic.phpt b/ext/intl/tests/breakiter_clone_basic.phpt new file mode 100644 index 0000000000..d838f81217 --- /dev/null +++ b/ext/intl/tests/breakiter_clone_basic.phpt @@ -0,0 +1,27 @@ +--TEST-- +IntlBreakIterator: clone handler +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$bi = new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;'); +$bi_clone = clone $bi; +var_dump(get_class($bi), get_class($bi_clone)); +var_dump($bi == $bi_clone); + +$bi->setText('foobar'); +$bi_clone = clone $bi; +var_dump(get_class($bi), get_class($bi_clone)); +var_dump($bi == $bi_clone); + +--EXPECT-- +string(26) "IntlRuleBasedBreakIterator" +string(26) "IntlRuleBasedBreakIterator" +bool(true) +string(26) "IntlRuleBasedBreakIterator" +string(26) "IntlRuleBasedBreakIterator" +bool(true) diff --git a/ext/intl/tests/breakiter_createCodePointInstance_basic.phpt b/ext/intl/tests/breakiter_createCodePointInstance_basic.phpt new file mode 100644 index 0000000000..a43e82760c --- /dev/null +++ b/ext/intl/tests/breakiter_createCodePointInstance_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +IntlBreakIterator::createCodePointInstance(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); + +$text = 'ตัวà¸à¸¢à¹ˆà¸²à¸‡à¸‚้à¸à¸„วาม'; + +$codepoint_it = IntlBreakIterator::createCodePointInstance(); +var_dump(get_class($codepoint_it)); +$codepoint_it->setText($text); + +print_r(iterator_to_array($codepoint_it)); + +?> +==DONE== +--EXPECT-- +string(26) "IntlCodePointBreakIterator" +Array +( + [0] => 0 + [1] => 3 + [2] => 6 + [3] => 9 + [4] => 12 + [5] => 15 + [6] => 18 + [7] => 21 + [8] => 24 + [9] => 27 + [10] => 30 + [11] => 33 + [12] => 36 + [13] => 39 + [14] => 42 + [15] => 45 +) +==DONE== diff --git a/ext/intl/tests/breakiter_createCodePointInstance_error.phpt b/ext/intl/tests/breakiter_createCodePointInstance_error.phpt new file mode 100644 index 0000000000..90228e128f --- /dev/null +++ b/ext/intl/tests/breakiter_createCodePointInstance_error.phpt @@ -0,0 +1,18 @@ +--TEST-- +IntlBreakIterator::createCodePointInstance(): bad arguments +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(IntlBreakIterator::createCodePointInstance(array())); +--EXPECTF-- + +Warning: IntlBreakIterator::createCodePointInstance() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlBreakIterator::createCodePointInstance(): breakiter_create_code_point_instance: bad arguments in %s on line %d +NULL + diff --git a/ext/intl/tests/breakiter_current_basic.phpt b/ext/intl/tests/breakiter_current_basic.phpt new file mode 100644 index 0000000000..2ce6da7697 --- /dev/null +++ b/ext/intl/tests/breakiter_current_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +IntlBreakIterator::current(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); + +$bi = IntlBreakIterator::createWordInstance('pt'); +var_dump($bi->current()); +$bi->setText('foo bar trans zoo bee'); + +var_dump($bi->first()); +var_dump($bi->current()); +var_dump($bi->next()); +var_dump($bi->current()); +?> +==DONE== +--EXPECT-- +int(0) +int(0) +int(0) +int(3) +int(3) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/breakiter_factories_basic.phpt b/ext/intl/tests/breakiter_factories_basic.phpt new file mode 100644 index 0000000000..dcfcedef0c --- /dev/null +++ b/ext/intl/tests/breakiter_factories_basic.phpt @@ -0,0 +1,46 @@ +--TEST-- +IntlBreakIterator factories: basic tests +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "ja"); + +$m = array('createWordInstance', 'createLineInstance', 'createCharacterInstance', + 'createSentenceInstance', 'createTitleInstance'); + +$t = 'Frase 1... Frase 2'. + +$o1 = $o2 = null; +foreach ($m as $method) { + echo "===== $method =====\n"; + $o1 = call_user_func(array('IntlBreakIterator', $method), 'ja'); + var_dump($o1 == $o2); + $o2 = call_user_func(array('IntlBreakIterator', $method), NULL); + var_dump($o1 == $o2); + echo "\n"; +} +--EXPECT-- +===== createWordInstance ===== +bool(false) +bool(true) + +===== createLineInstance ===== +bool(false) +bool(true) + +===== createCharacterInstance ===== +bool(false) +bool(true) + +===== createSentenceInstance ===== +bool(false) +bool(true) + +===== createTitleInstance ===== +bool(false) +bool(true) + diff --git a/ext/intl/tests/breakiter_factories_error.phpt b/ext/intl/tests/breakiter_factories_error.phpt new file mode 100644 index 0000000000..c35339f7a0 --- /dev/null +++ b/ext/intl/tests/breakiter_factories_error.phpt @@ -0,0 +1,43 @@ +--TEST-- +IntlBreakIterator factory methods: argument errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(IntlBreakIterator::createWordInstance(array())); +var_dump(IntlBreakIterator::createSentenceInstance(NULL, 2)); +var_dump(IntlBreakIterator::createCharacterInstance(NULL, 2)); +var_dump(IntlBreakIterator::createTitleInstance(NULL, 2)); +var_dump(IntlBreakIterator::createLineInstance(NULL, 2)); + + +--EXPECTF-- + +Warning: IntlBreakIterator::createWordInstance() expects parameter 1 to be string, array given in %s on line %d + +Warning: IntlBreakIterator::createWordInstance(): breakiter_create_word_instance: bad arguments in %s on line %d +NULL + +Warning: IntlBreakIterator::createSentenceInstance() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::createSentenceInstance(): breakiter_create_sentence_instance: bad arguments in %s on line %d +NULL + +Warning: IntlBreakIterator::createCharacterInstance() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::createCharacterInstance(): breakiter_create_character_instance: bad arguments in %s on line %d +NULL + +Warning: IntlBreakIterator::createTitleInstance() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::createTitleInstance(): breakiter_create_title_instance: bad arguments in %s on line %d +NULL + +Warning: IntlBreakIterator::createLineInstance() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::createLineInstance(): breakiter_create_line_instance: bad arguments in %s on line %d +NULL diff --git a/ext/intl/tests/breakiter_first_basic.phpt b/ext/intl/tests/breakiter_first_basic.phpt new file mode 100644 index 0000000000..364d5f2fa6 --- /dev/null +++ b/ext/intl/tests/breakiter_first_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +IntlBreakIterator::first(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$bi = IntlBreakIterator::createWordInstance('pt'); +$bi->setText('foo bar trans'); + +var_dump($bi->current()); +var_dump($bi->next()); +var_dump($bi->first()); +var_dump($bi->current()); +--EXPECT-- +int(0) +int(3) +int(0) +int(0) diff --git a/ext/intl/tests/breakiter_first_last_previous_current_error.phpt b/ext/intl/tests/breakiter_first_last_previous_current_error.phpt new file mode 100644 index 0000000000..2ab681228e --- /dev/null +++ b/ext/intl/tests/breakiter_first_last_previous_current_error.phpt @@ -0,0 +1,39 @@ +--TEST-- +IntlBreakIterator::first()/last()/previous()/current(): arg errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$bi = new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;'); +$bi->setText("\x80sdfé\x90d888 dfsa9"); + +var_dump($bi->first(1)); +var_dump($bi->last(1)); +var_dump($bi->previous(1)); +var_dump($bi->current(1)); + +--EXPECTF-- + +Warning: IntlBreakIterator::first() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlBreakIterator::first(): breakiter_first: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::last() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlBreakIterator::last(): breakiter_last: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::previous() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlBreakIterator::previous(): breakiter_previous: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::current() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlBreakIterator::current(): breakiter_current: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/breakiter_following_basic.phpt b/ext/intl/tests/breakiter_following_basic.phpt new file mode 100644 index 0000000000..30798d99a3 --- /dev/null +++ b/ext/intl/tests/breakiter_following_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlBreakIterator::following(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--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->following(5)); +var_dump($bi->following(50)); +var_dump($bi->following(-1)); +?> +==DONE== +--EXPECT-- +int(7) +int(-1) +int(0) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/breakiter_following_preceding_isBoundary_error.phpt b/ext/intl/tests/breakiter_following_preceding_isBoundary_error.phpt new file mode 100644 index 0000000000..5550ccf0a0 --- /dev/null +++ b/ext/intl/tests/breakiter_following_preceding_isBoundary_error.phpt @@ -0,0 +1,51 @@ +--TEST-- +IntlBreakIterator::following()/preceding()/isBoundary(): arg errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$bi = new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;'); +$bi->setText("\x80sdfé\x90d888 dfsa9"); + +var_dump($bi->following(1, 2)); +var_dump($bi->following(array())); +var_dump($bi->preceding(1, 2)); +var_dump($bi->preceding(array())); +var_dump($bi->isBoundary(1, 2)); +var_dump($bi->isBoundary(array())); + +--EXPECTF-- + +Warning: IntlBreakIterator::following() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::following(): breakiter_following: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::following() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlBreakIterator::following(): breakiter_following: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::preceding() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::preceding(): breakiter_preceding: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::preceding() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlBreakIterator::preceding(): breakiter_preceding: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::isBoundary() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::isBoundary(): breakiter_is_boundary: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::isBoundary() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlBreakIterator::isBoundary(): breakiter_is_boundary: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/breakiter_getLocale_basic.phpt b/ext/intl/tests/breakiter_getLocale_basic.phpt new file mode 100644 index 0000000000..b0112cc847 --- /dev/null +++ b/ext/intl/tests/breakiter_getLocale_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +IntlBreakIterator::getLocale(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); + +$bi = IntlBreakIterator::createSentenceInstance('pt'); + +var_dump($bi->getLocale(0)); +var_dump($bi->getLocale(1)); +?> +==DONE== +--EXPECT-- +string(4) "root" +string(4) "root" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/breakiter_getLocale_error.phpt b/ext/intl/tests/breakiter_getLocale_error.phpt new file mode 100644 index 0000000000..9acd08ab63 --- /dev/null +++ b/ext/intl/tests/breakiter_getLocale_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlBreakIterator::getLocale(): arg errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$bi = new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;'); +$bi->setText("\x80sdfé\x90d888 dfsa9"); + +var_dump($bi->getLocale(1, 2)); +var_dump($bi->getLocale(array())); +var_dump($bi->getLocale()); + +--EXPECTF-- + +Warning: IntlBreakIterator::getLocale() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::getLocale(): breakiter_get_locale: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::getLocale() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlBreakIterator::getLocale(): breakiter_get_locale: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::getLocale() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlBreakIterator::getLocale(): breakiter_get_locale: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/breakiter_getPartsIterator_basic.phpt b/ext/intl/tests/breakiter_getPartsIterator_basic.phpt new file mode 100644 index 0000000000..36ad80d5fb --- /dev/null +++ b/ext/intl/tests/breakiter_getPartsIterator_basic.phpt @@ -0,0 +1,37 @@ +--TEST-- +IntlBreakIterator::getPartsIterator(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--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(0) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/breakiter_getPartsIterator_error.phpt b/ext/intl/tests/breakiter_getPartsIterator_error.phpt new file mode 100644 index 0000000000..9737618033 --- /dev/null +++ b/ext/intl/tests/breakiter_getPartsIterator_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlBreakIterator::getPartsIterator(): bad args +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); + +$it = IntlBreakIterator::createWordInstance(NULL); +var_dump($it->getPartsIterator(array())); +var_dump($it->getPartsIterator(1, 2)); +var_dump($it->getPartsIterator(-1)); + +?> +==DONE== +--EXPECTF-- + +Warning: IntlBreakIterator::getPartsIterator() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlBreakIterator::getPartsIterator(): breakiter_get_parts_iterator: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::getPartsIterator() expects at most 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::getPartsIterator(): breakiter_get_parts_iterator: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::getPartsIterator(): breakiter_get_parts_iterator: bad key type in %s on line %d +bool(false) +==DONE== diff --git a/ext/intl/tests/breakiter_getPartsIterator_var1.phpt b/ext/intl/tests/breakiter_getPartsIterator_var1.phpt new file mode 100644 index 0000000000..7bbd27ea45 --- /dev/null +++ b/ext/intl/tests/breakiter_getPartsIterator_var1.phpt @@ -0,0 +1,60 @@ +--TEST-- +IntlBreakIterator::getPartsIterator(): argument variations +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); + +$text = 'foo bar tao'; + +$it = IntlBreakIterator::createWordInstance(NULL); +$it->setText($text); + +var_dump(iterator_to_array($it->getPartsIterator(IntlPartsIterator::KEY_SEQUENTIAL))); +var_dump(iterator_to_array($it->getPartsIterator(IntlPartsIterator::KEY_LEFT))); +var_dump(iterator_to_array($it->getPartsIterator(IntlPartsIterator::KEY_RIGHT))); + +?> +==DONE== +--EXPECT-- +array(5) { + [0]=> + string(3) "foo" + [1]=> + string(1) " " + [2]=> + string(3) "bar" + [3]=> + string(1) " " + [4]=> + string(3) "tao" +} +array(5) { + [0]=> + string(3) "foo" + [4]=> + string(1) " " + [5]=> + string(3) "bar" + [8]=> + string(1) " " + [9]=> + string(3) "tao" +} +array(5) { + [3]=> + string(3) "foo" + [5]=> + string(1) " " + [8]=> + string(3) "bar" + [9]=> + string(1) " " + [12]=> + string(3) "tao" +} +==DONE== diff --git a/ext/intl/tests/breakiter_getText_basic.phpt b/ext/intl/tests/breakiter_getText_basic.phpt new file mode 100644 index 0000000000..0e5a26c16a --- /dev/null +++ b/ext/intl/tests/breakiter_getText_basic.phpt @@ -0,0 +1,17 @@ +--TEST-- +IntlBreakIterator::getText(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$bi = IntlBreakIterator::createWordInstance('pt'); +var_dump($bi->getText()); +$bi->setText('foo bar'); +var_dump($bi->getText()); +--EXPECTF-- +NULL +string(7) "foo bar" diff --git a/ext/intl/tests/breakiter_getText_error.phpt b/ext/intl/tests/breakiter_getText_error.phpt new file mode 100644 index 0000000000..91e9919c15 --- /dev/null +++ b/ext/intl/tests/breakiter_getText_error.phpt @@ -0,0 +1,19 @@ +--TEST-- +IntlBreakIterator::getText(): arg errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$bi = new IntlRuleBasedBreakIterator('[\p{Letter}]+;'); +var_dump($bi->getText(array())); + +--EXPECTF-- + +Warning: IntlBreakIterator::getText() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlBreakIterator::getText(): breakiter_get_text: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/breakiter_isBoundary_basic.phpt b/ext/intl/tests/breakiter_isBoundary_basic.phpt new file mode 100644 index 0000000000..1f416630a0 --- /dev/null +++ b/ext/intl/tests/breakiter_isBoundary_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +IntlBreakIterator::isBoundary(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--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->isBoundary(0)); +var_dump($bi->isBoundary(7)); +var_dump($bi->isBoundary(-1)); +var_dump($bi->isBoundary(1)); +var_dump($bi->isBoundary(50)); +?> +==DONE== +--EXPECT-- +bool(true) +bool(true) +bool(false) +bool(false) +bool(false) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/breakiter_last_basic.phpt b/ext/intl/tests/breakiter_last_basic.phpt new file mode 100644 index 0000000000..cf816c3670 --- /dev/null +++ b/ext/intl/tests/breakiter_last_basic.phpt @@ -0,0 +1,20 @@ +--TEST-- +IntlBreakIterator::last(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$bi = IntlBreakIterator::createWordInstance('pt'); +$bi->setText('foo bar trans'); + +var_dump($bi->current()); +var_dump($bi->last()); +var_dump($bi->current()); +--EXPECTF-- +int(0) +int(13) +int(13) diff --git a/ext/intl/tests/breakiter_next_basic.phpt b/ext/intl/tests/breakiter_next_basic.phpt new file mode 100644 index 0000000000..4deb4144e3 --- /dev/null +++ b/ext/intl/tests/breakiter_next_basic.phpt @@ -0,0 +1,30 @@ +--TEST-- +IntlBreakIterator::next(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--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->first()); +var_dump($bi->next()); +var_dump($bi->next(2)); +var_dump($bi->next(-1)); +var_dump($bi->next(0)); +var_dump($bi->next(NULL)); +?> +==DONE== +--EXPECT-- +int(0) +int(3) +int(7) +int(4) +int(4) +int(7) +==DONE== diff --git a/ext/intl/tests/breakiter_next_error.phpt b/ext/intl/tests/breakiter_next_error.phpt new file mode 100644 index 0000000000..ed718bc2a5 --- /dev/null +++ b/ext/intl/tests/breakiter_next_error.phpt @@ -0,0 +1,27 @@ +--TEST-- +IntlBreakIterator::next(): arg errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$bi = new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+;'); +$bi->setText("\x80sdfé\x90d888 dfsa9"); + +var_dump($bi->next(1, 2)); +var_dump($bi->next(array())); + +--EXPECTF-- + +Warning: IntlBreakIterator::next() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::next(): breakiter_next: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::next() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlBreakIterator::next(): breakiter_next: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/breakiter_preceding_basic.phpt b/ext/intl/tests/breakiter_preceding_basic.phpt new file mode 100644 index 0000000000..6fa8dd7fa7 --- /dev/null +++ b/ext/intl/tests/breakiter_preceding_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlBreakIterator::preceding(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--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(0) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/breakiter_previous_basic.phpt b/ext/intl/tests/breakiter_previous_basic.phpt new file mode 100644 index 0000000000..c3343af57c --- /dev/null +++ b/ext/intl/tests/breakiter_previous_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +IntlBreakIterator::previous(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--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'); + +var_dump($bi->last()); +var_dump($bi->previous()); +?> +==DONE== +--EXPECT-- +int(13) +int(8) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/breakiter_setText_basic.phpt b/ext/intl/tests/breakiter_setText_basic.phpt new file mode 100644 index 0000000000..a5e4f86b65 --- /dev/null +++ b/ext/intl/tests/breakiter_setText_basic.phpt @@ -0,0 +1,36 @@ +--TEST-- +IntlBreakIterator::setText(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +class A { +function __tostring() { return 'aaa'; } +} + +$bi = IntlBreakIterator::createWordInstance('pt'); +var_dump($bi->setText('foo bar')); +var_dump($bi->getText()); +var_dump($bi->setText(1)); +var_dump($bi->getText()); +var_dump($bi->setText(new A)); +var_dump($bi->getText()); + +/* setText resets the pointer */ +var_dump($bi->next()); +var_dump($bi->setText('foo bar')); +var_dump($bi->current()); +--EXPECT-- +bool(true) +string(7) "foo bar" +bool(true) +string(1) "1" +bool(true) +string(3) "aaa" +int(3) +bool(true) +int(0) diff --git a/ext/intl/tests/breakiter_setText_error.phpt b/ext/intl/tests/breakiter_setText_error.phpt new file mode 100644 index 0000000000..a7a73a08d8 --- /dev/null +++ b/ext/intl/tests/breakiter_setText_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +IntlBreakIterator::setText(): arg errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$bi = new IntlRuleBasedBreakIterator('[\p{Letter}]+;'); +var_dump($bi->setText()); +var_dump($bi->setText(array())); +var_dump($bi->setText(1,2)); + +class A { +function __destruct() { var_dump('destructed'); throw new Exception('e'); } +function __tostring() { return 'foo'; } +} + +try { +var_dump($bi->setText(new A)); +} catch (Exception $e) { +var_dump($e->getMessage()); +} + +--EXPECTF-- + +Warning: IntlBreakIterator::setText() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlBreakIterator::setText(): breakiter_set_text: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::setText() expects parameter 1 to be string, array given in %s on line %d + +Warning: IntlBreakIterator::setText(): breakiter_set_text: bad arguments in %s on line %d +bool(false) + +Warning: IntlBreakIterator::setText() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlBreakIterator::setText(): breakiter_set_text: bad arguments in %s on line %d +bool(false) +string(10) "destructed" +string(1) "e" diff --git a/ext/intl/tests/bug50590.phpt b/ext/intl/tests/bug50590.phpt index c39c333b23..4784d37877 100644 --- a/ext/intl/tests/bug50590.phpt +++ b/ext/intl/tests/bug50590.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #50590 (IntlDateFormatter::parse result is limited to the integer range) +--INI-- +date.timezone=Atlantic/Azores --SKIPIF-- <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> --FILE-- diff --git a/ext/intl/tests/bug58756_MessageFormatter.phpt b/ext/intl/tests/bug58756_MessageFormatter.phpt new file mode 100644 index 0000000000..bbe96b7045 --- /dev/null +++ b/ext/intl/tests/bug58756_MessageFormatter.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #58756: w.r.t MessageFormatter +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +//ini_set("intl.default_locale", "nl"); + +$time = 1247013673; + +ini_set('date.timezone', 'America/New_York'); + +$msgf = new MessageFormatter('en_US', '{0,date,full} {0,time,h:m:s a V}'); + +echo "date: " . date('l, F j, Y g:i:s A T', $time) . "\n"; +echo "msgf: " . $msgf->format(array($time)) . "\n"; + +//NOT FIXED: +/*$msgf = new MessageFormatter('en_US', +'{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}'); + +echo "msgf2: ", $msgf->format(array($time, 'date')), " ", + $msgf->format(array($time, 'time')), "\n"; +*/ + +?> +==DONE== +--EXPECT-- +date: Tuesday, July 7, 2009 8:41:13 PM EDT +msgf: Tuesday, July 7, 2009 8:41:13 PM EDT +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/bug62017.phpt b/ext/intl/tests/bug62017.phpt index 13c4fe5df0..50aeae4806 100644 --- a/ext/intl/tests/bug62017.phpt +++ b/ext/intl/tests/bug62017.phpt @@ -14,7 +14,7 @@ var_dump( new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon", IntlDateFormatter::GREGORIAN, "\x80")); --EXPECTF-- -Warning: datefmt_create(): datefmt_create: error converting timezone_str to UTF-16 in %s on line %d +Warning: datefmt_create(): datefmt_create: Time zone identifier given is not a valid UTF-8 string in %s on line %d NULL Warning: IntlDateFormatter::__construct(): datefmt_create: error converting pattern to UTF-16 in %s on line %d diff --git a/ext/intl/tests/bug62081.phpt b/ext/intl/tests/bug62081.phpt index 7d9e2cec47..44ad4beec7 100644 --- a/ext/intl/tests/bug62081.phpt +++ b/ext/intl/tests/bug62081.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #62081: IntlDateFormatter leaks memory if called twice +--INI-- +date.timezone=Atlantic/Azores --SKIPIF-- <?php if (!extension_loaded('intl')) @@ -7,8 +9,8 @@ if (!extension_loaded('intl')) --FILE-- <?php ini_set('intl.error_level', E_WARNING); -$x = new IntlDateFormatter(1,1,1,1,1); -var_dump($x->__construct(1,1,1,1,1)); +$x = new IntlDateFormatter('en', 1, 1); +var_dump($x->__construct('en', 1, 1)); --EXPECTF-- Warning: IntlDateFormatter::__construct(): datefmt_create: cannot call constructor twice in %s on line %d NULL diff --git a/ext/intl/tests/bug62915.phpt b/ext/intl/tests/bug62915.phpt new file mode 100644 index 0000000000..e541d72d63 --- /dev/null +++ b/ext/intl/tests/bug62915.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #62915: incomplete cloning of IntlTimeZone objects +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php + +class foo extends IntlTimeZone { + public $foo = 'test'; + + public function __construct() { } +} + +$x = new foo; + +try { + $z = clone $x; +} catch (Exception $e) { + var_dump($e->getMessage()); +} +--EXPECT-- +string(39) "Cannot clone unconstructed IntlTimeZone" diff --git a/ext/intl/tests/calendar_add_basic.phpt b/ext/intl/tests/calendar_add_basic.phpt new file mode 100644 index 0000000000..b0e44d5895 --- /dev/null +++ b/ext/intl/tests/calendar_add_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlCalendar::add() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$time = strtotime('2012-02-29 00:00:00 +0000'); +$time2 = strtotime('2012-03-01 05:06:07 +0000'); + +$intlcal = IntlCalendar::createInstance('UTC'); +$intlcal->setTime($time * 1000); +$intlcal->add(IntlCalendar::FIELD_DAY_OF_MONTH, 1); +$intlcal->add(IntlCalendar::FIELD_HOUR, 5); +$intlcal->add(IntlCalendar::FIELD_MINUTE, 6); +intlcal_add($intlcal, IntlCalendar::FIELD_SECOND, 7); + +var_dump( + (float)$time2*1000, + $intlcal->getTime()); + +?> +==DONE== +--EXPECT-- +float(1330578367000) +float(1330578367000) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_add_error.phpt b/ext/intl/tests/calendar_add_error.phpt new file mode 100644 index 0000000000..2e5fadb4ec --- /dev/null +++ b/ext/intl/tests/calendar_add_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +IntlCalendar::add(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->add(1, 2, 3)); +var_dump($c->add(-1, 2)); +var_dump($c->add(1)); + +var_dump(intlcal_add($c, 1, 2, 3)); +var_dump(intlcal_add(1, 2, 3)); +--EXPECTF-- + +Warning: IntlCalendar::add() expects exactly 2 parameters, 3 given in %s on line %d + +Warning: IntlCalendar::add(): intlcal_add: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::add(): intlcal_add: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::add() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::add(): intlcal_add: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_add() expects exactly 3 parameters, 4 given in %s on line %d + +Warning: intlcal_add(): intlcal_add: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_add() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_before_after_error.phpt b/ext/intl/tests/calendar_before_after_error.phpt new file mode 100644 index 0000000000..10011ef852 --- /dev/null +++ b/ext/intl/tests/calendar_before_after_error.phpt @@ -0,0 +1,57 @@ +--TEST-- +IntlCalendar::before()/after(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +function eh($errno, $errstr) { +echo "error: $errno, $errstr\n"; +} +set_error_handler('eh'); + +var_dump($c->after()); +var_dump($c->before()); + +var_dump($c->after(1)); +var_dump($c->before(1)); + +var_dump($c->after($c, 1)); +var_dump($c->before($c, 1)); + +var_dump(intlcal_after($c)); +var_dump(intlcal_before($c)); +--EXPECT-- +error: 2, IntlCalendar::after() expects exactly 1 parameter, 0 given +error: 2, IntlCalendar::after(): intlcal_before/after: bad arguments +bool(false) +error: 2, IntlCalendar::before() expects exactly 1 parameter, 0 given +error: 2, IntlCalendar::before(): intlcal_before/after: bad arguments +bool(false) +error: 4096, Argument 1 passed to IntlCalendar::after() must be an instance of IntlCalendar, integer given +error: 2, IntlCalendar::after() expects parameter 1 to be IntlCalendar, integer given +error: 2, IntlCalendar::after(): intlcal_before/after: bad arguments +bool(false) +error: 4096, Argument 1 passed to IntlCalendar::before() must be an instance of IntlCalendar, integer given +error: 2, IntlCalendar::before() expects parameter 1 to be IntlCalendar, integer given +error: 2, IntlCalendar::before(): intlcal_before/after: bad arguments +bool(false) +error: 2, IntlCalendar::after() expects exactly 1 parameter, 2 given +error: 2, IntlCalendar::after(): intlcal_before/after: bad arguments +bool(false) +error: 2, IntlCalendar::before() expects exactly 1 parameter, 2 given +error: 2, IntlCalendar::before(): intlcal_before/after: bad arguments +bool(false) +error: 2, intlcal_after() expects exactly 2 parameters, 1 given +error: 2, intlcal_after(): intlcal_before/after: bad arguments +bool(false) +error: 2, intlcal_before() expects exactly 2 parameters, 1 given +error: 2, intlcal_before(): intlcal_before/after: bad arguments +bool(false) diff --git a/ext/intl/tests/calendar_clear_basic.phpt b/ext/intl/tests/calendar_clear_basic.phpt new file mode 100644 index 0000000000..f7e4371d92 --- /dev/null +++ b/ext/intl/tests/calendar_clear_basic.phpt @@ -0,0 +1,40 @@ +--TEST-- +IntlCalendar::clear() basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('UTC'); +var_dump($intlcal->clear()); +var_dump( + $intlcal->get(IntlCalendar::FIELD_YEAR), + $intlcal->get(IntlCalendar::FIELD_MONTH), + $intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH), + $intlcal->get(IntlCalendar::FIELD_HOUR), + $intlcal->get(IntlCalendar::FIELD_MINUTE), + $intlcal->get(IntlCalendar::FIELD_SECOND), + $intlcal->get(IntlCalendar::FIELD_MILLISECOND) +); + +$intlcal2 = IntlCalendar::createInstance('Europe/Amsterdam'); +intlcal_clear($intlcal2, null); +var_dump($intlcal2->getTime()); + +?> +==DONE== +--EXPECT-- +bool(true) +int(1970) +int(0) +int(1) +int(0) +int(0) +int(0) +int(0) +float(-3600000) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_clear_error.phpt b/ext/intl/tests/calendar_clear_error.phpt new file mode 100644 index 0000000000..9bde7e2c8d --- /dev/null +++ b/ext/intl/tests/calendar_clear_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +IntlCalendar::clear(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->clear(1, 2)); +var_dump($c->clear(-1)); + +var_dump(intlcal_clear($c, -1)); +var_dump(intlcal_clear(1, 2)); +--EXPECTF-- + +Warning: IntlCalendar::clear(): intlcal_clear: too many arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::clear(): intlcal_clear: invalid field in %s on line %d +bool(false) + +Warning: intlcal_clear(): intlcal_clear: invalid field in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_clear() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_clear_variation1.phpt b/ext/intl/tests/calendar_clear_variation1.phpt new file mode 100644 index 0000000000..6adbcaa353 --- /dev/null +++ b/ext/intl/tests/calendar_clear_variation1.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlCalendar::clear() 1 arg variation +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('UTC'); +$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000); +//print_R($intlcal); +var_dump($intlcal->isSet(IntlCalendar::FIELD_MONTH)); +var_dump($intlcal->clear(IntlCalendar::FIELD_MONTH)); +var_dump($intlcal->isSet(IntlCalendar::FIELD_MONTH)); +//print_R($intlcal); +var_dump( + $intlcal->getTime(), + strtotime('2012-01-29 05:06:07 +0000') * 1000. +); +?> +==DONE== +--EXPECT-- +bool(true) +bool(true) +bool(false) +float(1327813567000) +float(1327813567000) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_createInstance_basic.phpt b/ext/intl/tests/calendar_createInstance_basic.phpt new file mode 100644 index 0000000000..e062030fec --- /dev/null +++ b/ext/intl/tests/calendar_createInstance_basic.phpt @@ -0,0 +1,42 @@ +--TEST-- +IntlCalendar::createInstance() basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +date_default_timezone_set('Europe/Amsterdam'); + +$cal = IntlCalendar::createInstance(); +print_R($cal->getTimeZone()); +print_R($cal->getLocale(Locale::ACTUAL_LOCALE)); +echo "\n"; +print_R($cal->getType()); +echo "\n"; + +$timeMillis = $cal->getTime(); +$time = time(); + +var_dump(abs($timeMillis - $time * 1000) < 1000); + +?> +==DONE== + +--EXPECTF-- +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Amsterdam + [rawOffset] => 3600000 + [currentOffset] => %d +) +nl +gregorian +bool(true) +==DONE== diff --git a/ext/intl/tests/calendar_createInstance_error.phpt b/ext/intl/tests/calendar_createInstance_error.phpt new file mode 100644 index 0000000000..bf655bee79 --- /dev/null +++ b/ext/intl/tests/calendar_createInstance_error.phpt @@ -0,0 +1,38 @@ +--TEST-- +IntlCalendar::createInstance: bad arguments +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +class X extends IntlTimeZone { +function __construct() {} +} + +var_dump(IntlCalendar::createInstance(1, 2, 3)); +var_dump(intlcal_create_instance(1, 2, 3)); +var_dump(intlcal_create_instance(new X, NULL)); +var_dump(intlcal_create_instance(NULL, array())); + +--EXPECTF-- + +Warning: IntlCalendar::createInstance() expects at most 2 parameters, 3 given in %s on line %d + +Warning: IntlCalendar::createInstance(): intlcal_create_calendar: bad arguments in %s on line %d +NULL + +Warning: intlcal_create_instance() expects at most 2 parameters, 3 given in %s on line %d + +Warning: intlcal_create_instance(): intlcal_create_calendar: bad arguments in %s on line %d +NULL + +Warning: intlcal_create_instance(): intlcal_create_instance: passed IntlTimeZone is not properly constructed in %s on line %d +NULL + +Warning: intlcal_create_instance() expects parameter 2 to be string, array given in %s on line %d + +Warning: intlcal_create_instance(): intlcal_create_calendar: bad arguments in %s on line %d +NULL diff --git a/ext/intl/tests/calendar_createInstance_variation1.phpt b/ext/intl/tests/calendar_createInstance_variation1.phpt new file mode 100644 index 0000000000..138f2a2afd --- /dev/null +++ b/ext/intl/tests/calendar_createInstance_variation1.phpt @@ -0,0 +1,84 @@ +--TEST-- +IntlCalendar::createInstance() argument variations +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +date_default_timezone_set('Europe/Amsterdam'); + +$cal = intlcal_create_instance('Europe/Amsterdam'); +print_R($cal->getTimeZone()); +print_R($cal->getLocale(Locale::ACTUAL_LOCALE)); +echo "\n"; + +$cal = intlcal_create_instance('Europe/Lisbon', null); +print_R($cal->getTimeZone()); +print_R($cal->getLocale(Locale::ACTUAL_LOCALE)); +echo "\n"; + +$cal = intlcal_create_instance(IntlTimeZone::createTimeZone('Europe/Lisbon')); +print_R($cal->getTimeZone()); +print_R($cal->getLocale(Locale::ACTUAL_LOCALE)); +echo "\n"; + +$cal = intlcal_create_instance(null, "pt"); +print_R($cal->getTimeZone()); +print_R($cal->getLocale(Locale::ACTUAL_LOCALE)); +echo "\n"; + +$cal = intlcal_create_instance("Europe/Lisbon", "pt"); +print_R($cal->getTimeZone()); +print_R($cal->getLocale(Locale::ACTUAL_LOCALE)); +echo "\n"; + +?> +==DONE== +--EXPECTF-- +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Amsterdam + [rawOffset] => 3600000 + [currentOffset] => %d +) +nl +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Lisbon + [rawOffset] => 0 + [currentOffset] => %d +) +nl +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Lisbon + [rawOffset] => 0 + [currentOffset] => %d +) +nl +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Amsterdam + [rawOffset] => 3600000 + [currentOffset] => %d +) +pt +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Lisbon + [rawOffset] => 0 + [currentOffset] => %d +) +pt +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_equals_before_after_basic.phpt b/ext/intl/tests/calendar_equals_before_after_basic.phpt new file mode 100644 index 0000000000..50543ad0b4 --- /dev/null +++ b/ext/intl/tests/calendar_equals_before_after_basic.phpt @@ -0,0 +1,59 @@ +--TEST-- +IntlCalendar::equals(), ::before() and ::after() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal1 = new IntlGregorianCalendar(2012, 1, 29, 16, 59, 59); +$intlcal2 = IntlCalendar::createInstance(null, '@calendar=japanese'); +$intlcal3 = new IntlGregorianCalendar(2012, 1, 29, 17, 00, 00); +$intlcal2->setTime($intlcal1->getTime()); + +var_dump($intlcal2->getType()); + +var_dump("1 eq 1", $intlcal1->equals($intlcal1)); + +var_dump("1 eq 2", $intlcal1->equals($intlcal2)); +var_dump("1 before 2", $intlcal1->before($intlcal2)); +var_dump("1 after 2", $intlcal1->after($intlcal2)); + +var_dump("1 eq 3", $intlcal1->equals($intlcal3)); +var_dump("1 before 3", $intlcal1->before($intlcal3)); +var_dump("1 after 3", $intlcal1->after($intlcal3)); + +var_dump("3 eq 2", intlcal_equals($intlcal3, $intlcal2)); +var_dump("3 before 2", intlcal_before($intlcal3, $intlcal2)); +var_dump("3 after 2", intlcal_after($intlcal3, $intlcal2)); + +?> +==DONE== +--EXPECT-- +string(8) "japanese" +string(6) "1 eq 1" +bool(true) +string(6) "1 eq 2" +bool(true) +string(10) "1 before 2" +bool(false) +string(9) "1 after 2" +bool(false) +string(6) "1 eq 3" +bool(false) +string(10) "1 before 3" +bool(true) +string(9) "1 after 3" +bool(false) +string(6) "3 eq 2" +bool(false) +string(10) "3 before 2" +bool(false) +string(9) "3 after 2" +bool(true) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_equals_error.phpt b/ext/intl/tests/calendar_equals_error.phpt new file mode 100644 index 0000000000..a947b42bfe --- /dev/null +++ b/ext/intl/tests/calendar_equals_error.phpt @@ -0,0 +1,46 @@ +--TEST-- +IntlCalendar::equals(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +function eh($errno, $errstr) { +echo "error: $errno, $errstr\n"; +} +set_error_handler('eh'); + +var_dump($c->equals()); +var_dump($c->equals(new stdclass)); +var_dump($c->equals(1, 2)); + +var_dump(intlcal_equals($c, array())); +var_dump(intlcal_equals(1, $c)); + +--EXPECT-- +error: 2, IntlCalendar::equals() expects exactly 1 parameter, 0 given +error: 2, IntlCalendar::equals(): intlcal_equals: bad arguments +bool(false) +error: 4096, Argument 1 passed to IntlCalendar::equals() must be an instance of IntlCalendar, instance of stdClass given +error: 2, IntlCalendar::equals() expects parameter 1 to be IntlCalendar, object given +error: 2, IntlCalendar::equals(): intlcal_equals: bad arguments +bool(false) +error: 4096, Argument 1 passed to IntlCalendar::equals() must be an instance of IntlCalendar, integer given +error: 2, IntlCalendar::equals() expects exactly 1 parameter, 2 given +error: 2, IntlCalendar::equals(): intlcal_equals: bad arguments +bool(false) +error: 4096, Argument 2 passed to intlcal_equals() must be an instance of IntlCalendar, array given +error: 2, intlcal_equals() expects parameter 2 to be IntlCalendar, array given +error: 2, intlcal_equals(): intlcal_equals: bad arguments +bool(false) +error: 4096, Argument 1 passed to intlcal_equals() must be an instance of IntlCalendar, integer given +error: 2, intlcal_equals() expects parameter 1 to be IntlCalendar, integer given +error: 2, intlcal_equals(): intlcal_equals: bad arguments +bool(false) diff --git a/ext/intl/tests/calendar_fieldDifference_basic.phpt b/ext/intl/tests/calendar_fieldDifference_basic.phpt new file mode 100644 index 0000000000..3432420df4 --- /dev/null +++ b/ext/intl/tests/calendar_fieldDifference_basic.phpt @@ -0,0 +1,35 @@ +--TEST-- +IntlCalendar::fieldDifference() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('UTC'); +$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000); +var_dump( + $intlcal->fieldDifference( + strtotime('2012-02-29 06:06:08 +0000') * 1000, + IntlCalendar::FIELD_SECOND), + $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY)); + + +$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000); +var_dump( + intlcal_field_difference( + $intlcal, + strtotime('2012-02-29 06:07:08 +0000') * 1000, + IntlCalendar::FIELD_MINUTE)); +?> +==DONE== +--EXPECT-- +int(3601) +int(6) +int(61) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_fieldDifference_error.phpt b/ext/intl/tests/calendar_fieldDifference_error.phpt new file mode 100644 index 0000000000..ef7e4fc8dc --- /dev/null +++ b/ext/intl/tests/calendar_fieldDifference_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +IntlCalendar::fieldDifference(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->fieldDifference($c, 2, 3)); +var_dump($c->fieldDifference(INF, 2)); +var_dump($c->fieldDifference(1)); + +var_dump(intlcal_field_difference($c, 0, 1, 2)); +var_dump(intlcal_field_difference(1, 0, 1)); + +--EXPECTF-- + +Warning: IntlCalendar::fieldDifference() expects exactly 2 parameters, 3 given in %s on line %d + +Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in %s on line %d +bool(false) + +Warning: IntlCalendar::fieldDifference() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_field_difference() expects exactly 3 parameters, 4 given in %s on line %d + +Warning: intlcal_field_difference(): intlcal_field_difference: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_field_difference() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_fromDateTime_basic.phpt b/ext/intl/tests/calendar_fromDateTime_basic.phpt new file mode 100644 index 0000000000..1863b7815c --- /dev/null +++ b/ext/intl/tests/calendar_fromDateTime_basic.phpt @@ -0,0 +1,52 @@ +--TEST-- +IntlCalendar::fromDateTime(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl_NL"); +date_default_timezone_set('Europe/Lisbon'); + +$cal = IntlCalendar::fromDateTime('2012-01-01 00:00:00 Europe/Rome'); +var_dump( + $cal->getTime(), + strtotime('2012-01-01 00:00:00 Europe/Rome') * 1000., + $cal->getTimeZone()->getID(), + $cal->getLocale(1) +); +echo "\n"; + +$cal = IntlCalendar::fromDateTime(new DateTime('2012-01-01 00:00:00 PST'), "pt_PT"); +var_dump( + $cal->getTime(), + strtotime('2012-01-01 00:00:00 PST') * 1000., + $cal->getTimeZone()->getID(), + $cal->getLocale(1) +); + +echo "\n"; + +$cal = intlcal_from_date_time(new DateTime('2012-01-01 00:00:00 +03:40')); +var_dump( + $cal->getTime(), + strtotime('2012-01-01 00:00:00 +03:40') * 1000., + $cal->getTimeZone()->getID() +); + +--EXPECTF-- +float(1325372400000) +float(1325372400000) +string(11) "Europe/Rome" +string(5) "nl_NL" + +float(1325404800000) +float(1325404800000) +string(3) "PST" +string(5) "pt_PT" + +float(1325362800000) +float(1325362800000) +string(%d) "GMT+03%S40" diff --git a/ext/intl/tests/calendar_fromDateTime_error.phpt b/ext/intl/tests/calendar_fromDateTime_error.phpt new file mode 100644 index 0000000000..2fbf7196f9 --- /dev/null +++ b/ext/intl/tests/calendar_fromDateTime_error.phpt @@ -0,0 +1,59 @@ +--TEST-- +IntlCalendar::fromDateTime(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); +date_default_timezone_set('Europe/Lisbon'); + +var_dump(IntlCalendar::fromDateTime()); +var_dump(IntlCalendar::fromDateTime(0,1,2)); + +try { +IntlCalendar::fromDateTime("foobar"); +} catch (Exception $e) { + echo "threw exception, OK"; +} +class A extends DateTime { +function __construct() {} +} + +var_dump(IntlCalendar::fromDateTime(new A)); + +$date = new DateTime('2012-01-01 00:00:00 +24:00'); +var_dump(IntlCalendar::fromDateTime($date)); + +$date = new DateTime('2012-01-01 00:00:00 WEST'); +var_dump(IntlCalendar::fromDateTime($date)); + +var_dump(intlcal_from_date_time()); + +--EXPECTF-- + +Warning: IntlCalendar::fromDateTime() expects at least 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: bad arguments in %s on line %d +NULL + +Warning: IntlCalendar::fromDateTime() expects at most 2 parameters, 3 given in %s on line %d + +Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: bad arguments in %s on line %d +NULL +threw exception, OK +Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: DateTime object is unconstructed in %s on line %d +NULL + +Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: object has an time zone offset that's too large in %s on line %d +NULL + +Warning: IntlCalendar::fromDateTime(): intlcal_from_date_time: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d +NULL + +Warning: intlcal_from_date_time() expects at least 1 parameter, 0 given in %s on line %d + +Warning: intlcal_from_date_time(): intlcal_from_date_time: bad arguments in %s on line %d +NULL diff --git a/ext/intl/tests/calendar_getAvailableLocales_basic.phpt b/ext/intl/tests/calendar_getAvailableLocales_basic.phpt new file mode 100644 index 0000000000..5d5b79c020 --- /dev/null +++ b/ext/intl/tests/calendar_getAvailableLocales_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlCalendar::getAvailableLocales() basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$locales = IntlCalendar::getAvailableLocales(); +var_dump(count($locales) > 100); + +$locales = intlcal_get_available_locales(); +var_dump(in_array('pt', $locales)); + +?> +==DONE== +--EXPECT-- +bool(true) +bool(true) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_getAvailableLocales_error.phpt b/ext/intl/tests/calendar_getAvailableLocales_error.phpt new file mode 100644 index 0000000000..e9edc468e5 --- /dev/null +++ b/ext/intl/tests/calendar_getAvailableLocales_error.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlCalendar::getAvailableLocales(): bad arguments +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(intlcal_get_available_locales(1)); +var_dump(IntlCalendar::getAvailableLocales(2)); + +--EXPECTF-- + +Warning: intlcal_get_available_locales() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: intlcal_get_available_locales(): intlcal_get_available_locales: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getAvailableLocales() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getAvailableLocales(): intlcal_get_available_locales: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/calendar_getDayOfWeekType_basic.phpt b/ext/intl/tests/calendar_getDayOfWeekType_basic.phpt new file mode 100644 index 0000000000..d5319f1471 --- /dev/null +++ b/ext/intl/tests/calendar_getDayOfWeekType_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlCalendar::getDayOfWeekType() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.4') < 0) + die('skip for ICU 4.4+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('UTC'); +$intlcal->setTime(strtotime('2012-02-29 00:00:00 +0000') * 1000); +var_dump( + intlcal_get_day_of_week_type($intlcal, IntlCalendar::DOW_SUNDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_MONDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_TUESDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_FRIDAY), + $intlcal->getDayOfWeekType(IntlCalendar::DOW_SATURDAY) +); + +?> +==DONE== +--EXPECT-- +int(3) +int(0) +int(0) +int(0) +int(1) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_getDayOfWeekType_error.phpt b/ext/intl/tests/calendar_getDayOfWeekType_error.phpt new file mode 100644 index 0000000000..3926655615 --- /dev/null +++ b/ext/intl/tests/calendar_getDayOfWeekType_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +IntlCalendar::getDayOfWeekOfType(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.4') < 0) + die('skip for ICU 4.4+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->getDayOfWeekType(1, 2)); +var_dump($c->getDayOfWeekType(0)); +var_dump($c->getDayOfWeekType()); + +var_dump(intlcal_get_day_of_week_type($c, "foo")); +var_dump(intlcal_get_day_of_week_type(1, 1)); + +--EXPECTF-- + +Warning: IntlCalendar::getDayOfWeekType() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::getDayOfWeekType(): intlcal_get_day_of_week_type: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getDayOfWeekType(): intlcal_get_day_of_week_type: invalid day of week in %s on line %d +bool(false) + +Warning: IntlCalendar::getDayOfWeekType() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getDayOfWeekType(): intlcal_get_day_of_week_type: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_day_of_week_type() expects parameter 2 to be long, string given in %s on line %d + +Warning: intlcal_get_day_of_week_type(): intlcal_get_day_of_week_type: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_day_of_week_type() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getErrorCode_error.phpt b/ext/intl/tests/calendar_getErrorCode_error.phpt new file mode 100644 index 0000000000..13aab81923 --- /dev/null +++ b/ext/intl/tests/calendar_getErrorCode_error.phpt @@ -0,0 +1,26 @@ +--TEST-- +IntlCalendar::getErrorCode(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->getErrorCode(array())); + +var_dump(intlcal_get_error_code(null)); + +--EXPECTF-- + +Warning: IntlCalendar::getErrorCode() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getErrorCode(): intlcal_get_error_code: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_error_code() must be an instance of IntlCalendar, null given in %s on line %d diff --git a/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt b/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt new file mode 100644 index 0000000000..71c053492f --- /dev/null +++ b/ext/intl/tests/calendar_getErrorCode_getErrorMessage_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +IntlCalendar::getErrorCode(), ::getErrorMessage() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = new IntlGregorianCalendar(2012, 1, 29); +var_dump( + $intlcal->getErrorCode(), + intlcal_get_error_code($intlcal), + $intlcal->getErrorMessage(), + intlcal_get_error_message($intlcal) +); +$intlcal->add(IntlCalendar::FIELD_SECOND, 2147483647); +$intlcal->fieldDifference(-PHP_INT_MAX, IntlCalendar::FIELD_SECOND); + +var_dump( + $intlcal->getErrorCode(), + intlcal_get_error_code($intlcal), + $intlcal->getErrorMessage(), + intlcal_get_error_message($intlcal) +); +?> +==DONE== +--EXPECTF-- +int(0) +int(0) +string(12) "U_ZERO_ERROR" +string(12) "U_ZERO_ERROR" + +Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in %s on line %d +int(1) +int(1) +string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR" +string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR" +==DONE== diff --git a/ext/intl/tests/calendar_getErrorMessage_error.phpt b/ext/intl/tests/calendar_getErrorMessage_error.phpt new file mode 100644 index 0000000000..6081833904 --- /dev/null +++ b/ext/intl/tests/calendar_getErrorMessage_error.phpt @@ -0,0 +1,26 @@ +--TEST-- +IntlCalendar::getErrorMessage(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->getErrorMessage(array())); + +var_dump(intlcal_get_error_message(null)); + +--EXPECTF-- + +Warning: IntlCalendar::getErrorMessage() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getErrorMessage(): intlcal_get_error_message: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_error_message() must be an instance of IntlCalendar, null given in %s on line %d diff --git a/ext/intl/tests/calendar_getFirstDayOfWeek_basic.phpt b/ext/intl/tests/calendar_getFirstDayOfWeek_basic.phpt new file mode 100644 index 0000000000..82a0bc85cc --- /dev/null +++ b/ext/intl/tests/calendar_getFirstDayOfWeek_basic.phpt @@ -0,0 +1,20 @@ +--TEST-- +IntlCalendar::getFirstDayOfWeek() basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('UTC'); +var_dump($intlcal->getFirstDayOfWeek()); +var_dump(intlcal_get_first_day_of_week($intlcal)); +?> +==DONE== +--EXPECT-- +int(2) +int(2) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_getFirstDayOfWeek_error.phpt b/ext/intl/tests/calendar_getFirstDayOfWeek_error.phpt new file mode 100644 index 0000000000..e13b5138a7 --- /dev/null +++ b/ext/intl/tests/calendar_getFirstDayOfWeek_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlCalendar::getFirstDayOfWeek(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->getFirstDayOfWeek(1)); + +var_dump(intlcal_get_first_day_of_week($c, 1)); +var_dump(intlcal_get_first_day_of_week(1)); + +--EXPECTF-- + +Warning: IntlCalendar::getFirstDayOfWeek() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getFirstDayOfWeek(): intlcal_get_first_day_of_week: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_first_day_of_week() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_get_first_day_of_week(): intlcal_get_first_day_of_week: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_first_day_of_week() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getKeywordValuesForLocale_basic.phpt b/ext/intl/tests/calendar_getKeywordValuesForLocale_basic.phpt new file mode 100644 index 0000000000..dedfcea8fe --- /dev/null +++ b/ext/intl/tests/calendar_getKeywordValuesForLocale_basic.phpt @@ -0,0 +1,36 @@ +--TEST-- +IntlCalendar::getKeywordValuesForLocale() basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.2') < 0) + die('skip for ICU 4.2+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +print_r( +iterator_to_array( +IntlCalendar::getKeywordValuesForLocale('calendar', 'pt', true) +)); +echo "\n"; + +$var = iterator_to_array( +intlcal_get_keyword_values_for_locale('calendar', 'pt', false) +); +var_dump(count($var) > 8); +var_dump(in_array('japanese', $var)); + +?> +==DONE== +--EXPECT-- +Array +( + [0] => gregorian +) + +bool(true) +bool(true) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_getKeywordValuesForLocale_error.phpt b/ext/intl/tests/calendar_getKeywordValuesForLocale_error.phpt new file mode 100644 index 0000000000..2aa8002bd1 --- /dev/null +++ b/ext/intl/tests/calendar_getKeywordValuesForLocale_error.phpt @@ -0,0 +1,26 @@ +--TEST-- +IntlCalendar::getKeywordValuesForLocale(): bad arguments +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.2') < 0) + die('skip for ICU 4.2+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(intlcal_get_keyword_values_for_locale(1, 2)); +var_dump(IntlCalendar::getKeywordValuesForLocale(1, 2, array())); + +--EXPECTF-- + +Warning: intlcal_get_keyword_values_for_locale() expects exactly 3 parameters, 2 given in %s on line %d + +Warning: intlcal_get_keyword_values_for_locale(): intlcal_get_keyword_values_for_locale: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getKeywordValuesForLocale() expects parameter 3 to be boolean, array given in %s on line %d + +Warning: IntlCalendar::getKeywordValuesForLocale(): intlcal_get_keyword_values_for_locale: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/calendar_getLocale_basic.phpt b/ext/intl/tests/calendar_getLocale_basic.phpt new file mode 100644 index 0000000000..63f846f9a8 --- /dev/null +++ b/ext/intl/tests/calendar_getLocale_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +IntlCalendar::getLocale() basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('UTC'); +var_dump($intlcal->getLocale(Locale::ACTUAL_LOCALE)); +var_dump(intlcal_get_locale($intlcal, Locale::VALID_LOCALE)); +?> +==DONE== +--EXPECT-- +string(2) "nl" +string(5) "nl_NL" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_getLocale_error.phpt b/ext/intl/tests/calendar_getLocale_error.phpt new file mode 100644 index 0000000000..42970a9e7f --- /dev/null +++ b/ext/intl/tests/calendar_getLocale_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +IntlCalendar::getLocale(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->getLocale()); +var_dump($c->getLocale(2)); +var_dump($c->getLocale(2, 3)); + +var_dump(intlcal_get_locale($c)); +var_dump(intlcal_get_locale(1)); + +--EXPECTF-- + +Warning: IntlCalendar::getLocale() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getLocale(): intlcal_get_locale: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getLocale(): intlcal_get_locale: invalid locale type in %s on line %d +bool(false) + +Warning: IntlCalendar::getLocale() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::getLocale(): intlcal_get_locale: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_locale() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: intlcal_get_locale(): intlcal_get_locale: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_locale() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_basic.phpt b/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_basic.phpt new file mode 100644 index 0000000000..eeaa3104a8 --- /dev/null +++ b/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +IntlCalendar::getMinimalDaysInFirstWeek() basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('UTC'); +var_dump($intlcal->getMinimalDaysInFirstWeek()); +var_dump(intlcal_get_minimal_days_in_first_week($intlcal)); +?> +==DONE== +--EXPECT-- +int(4) +int(4) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_error.phpt b/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_error.phpt new file mode 100644 index 0000000000..8e1971dc2b --- /dev/null +++ b/ext/intl/tests/calendar_getMinimalDaysInFirstWeek_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlCalendar::getMinimalDaysInFirstWeek(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->getMinimalDaysInFirstWeek(1)); + +var_dump(intlcal_get_minimal_days_in_first_week($c, 1)); +var_dump(intlcal_get_minimal_days_in_first_week(1)); + +--EXPECTF-- + +Warning: IntlCalendar::getMinimalDaysInFirstWeek() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getMinimalDaysInFirstWeek(): intlcal_get_minimal_days_in_first_week: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_minimal_days_in_first_week() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_get_minimal_days_in_first_week(): intlcal_get_minimal_days_in_first_week: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_minimal_days_in_first_week() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getNow_basic.phpt b/ext/intl/tests/calendar_getNow_basic.phpt new file mode 100644 index 0000000000..18325dfa60 --- /dev/null +++ b/ext/intl/tests/calendar_getNow_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlCalendar::getNow() basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$now = IntlCalendar::getNow(); +$proc_now = intlcal_get_now(); +$time = time(); +var_dump(abs($now - $proc_now) < 500); +var_dump(abs($time * 1000 - $proc_now) < 1000); + +?> +==DONE== +--EXPECT-- +bool(true) +bool(true) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_getNow_error.phpt b/ext/intl/tests/calendar_getNow_error.phpt new file mode 100644 index 0000000000..31991bb591 --- /dev/null +++ b/ext/intl/tests/calendar_getNow_error.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlCalendar::getNow(): bad arguments +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(intlcal_get_now(1)); +var_dump(IntlCalendar::getNow(2)); + +--EXPECTF-- + +Warning: intlcal_get_now() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: intlcal_get_now(): intlcal_get_now: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getNow() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getNow(): intlcal_get_now: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/calendar_getSkipped_RepeatedWallTimeOption_error.phpt b/ext/intl/tests/calendar_getSkipped_RepeatedWallTimeOption_error.phpt new file mode 100644 index 0000000000..e07135586c --- /dev/null +++ b/ext/intl/tests/calendar_getSkipped_RepeatedWallTimeOption_error.phpt @@ -0,0 +1,47 @@ +--TEST-- +IntlCalendar::getSkipped/RepeatedWallTimeOption(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '49') < 0) + die('skip for ICU 49+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->getSkippedWallTimeOption(1)); +var_dump($c->getRepeatedWallTimeOption(1)); + +var_dump(intlcal_get_skipped_wall_time_option($c, 1)); +var_dump(intlcal_get_repeated_wall_time_option($c, 1)); + +var_dump(intlcal_get_skipped_wall_time_option(1)); + +--EXPECTF-- + +Warning: IntlCalendar::getSkippedWallTimeOption() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getSkippedWallTimeOption(): intlcal_get_skipped_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getRepeatedWallTimeOption() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getRepeatedWallTimeOption(): intlcal_get_repeated_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_skipped_wall_time_option() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_get_skipped_wall_time_option(): intlcal_get_skipped_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_repeated_wall_time_option() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_get_repeated_wall_time_option(): intlcal_get_repeated_wall_time_option: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_skipped_wall_time_option() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getTimeZone_basic.phpt b/ext/intl/tests/calendar_getTimeZone_basic.phpt new file mode 100644 index 0000000000..fd9aff1f99 --- /dev/null +++ b/ext/intl/tests/calendar_getTimeZone_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlCalendar::getTimeZone() basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('GMT+00:01'); +print_r($intlcal->getTimeZone()); +print_r(intlcal_get_time_zone($intlcal)); +?> +==DONE== +--EXPECT-- +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT+00:01 + [rawOffset] => 60000 + [currentOffset] => 60000 +) +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT+00:01 + [rawOffset] => 60000 + [currentOffset] => 60000 +) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_getTimeZone_error.phpt b/ext/intl/tests/calendar_getTimeZone_error.phpt new file mode 100644 index 0000000000..470701cd91 --- /dev/null +++ b/ext/intl/tests/calendar_getTimeZone_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlCalendar::getTimeZone(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->getTimeZone(1)); + +var_dump(intlcal_get_time_zone($c, 1)); +var_dump(intlcal_get_time_zone(1)); + +--EXPECTF-- + +Warning: IntlCalendar::getTimeZone() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getTimeZone(): intlcal_get_time_zone: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_time_zone() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_get_time_zone(): intlcal_get_time_zone: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_time_zone() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getTime_basic.phpt b/ext/intl/tests/calendar_getTime_basic.phpt new file mode 100644 index 0000000000..659c71c961 --- /dev/null +++ b/ext/intl/tests/calendar_getTime_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +IntlCalendar::getTime() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('UTC'); +$intlcal->clear(); +$intlcal->set(IntlCalendar::FIELD_YEAR, 2012); +$intlcal->set(IntlCalendar::FIELD_MONTH, 1 /* Feb */); +$intlcal->set(IntlCalendar::FIELD_DAY_OF_MONTH, 29); + +$time = strtotime('2012-02-29 00:00:00 +0000'); + +var_dump((float)$time*1000, $intlcal->getTime()); + +?> +==DONE== +--EXPECT-- +float(1330473600000) +float(1330473600000) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_getTime_error.phpt b/ext/intl/tests/calendar_getTime_error.phpt new file mode 100644 index 0000000000..5d27e21101 --- /dev/null +++ b/ext/intl/tests/calendar_getTime_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +IntlCalendar::getTime(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->getTime(1)); + +var_dump(intlcal_get_time($c, 1)); +var_dump(intlcal_get_time(1)); +--EXPECTF-- + +Warning: IntlCalendar::getTime() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getTime(): intlcal_get_time: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_time() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_get_time(): intlcal_get_time: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_time() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getType_basic.phpt b/ext/intl/tests/calendar_getType_basic.phpt new file mode 100644 index 0000000000..ba32dd0526 --- /dev/null +++ b/ext/intl/tests/calendar_getType_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlCalendar::getType() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance(); +VAR_DUMP($intlcal->getType()); +$intlcal = IntlCalendar::createInstance(null, "nl_NL@calendar=hebrew"); +VAR_DUMP(intlcal_get_type($intlcal)); +?> +==DONE== +--EXPECT-- +string(9) "gregorian" +string(6) "hebrew" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_getType_error.phpt b/ext/intl/tests/calendar_getType_error.phpt new file mode 100644 index 0000000000..668ebeafb4 --- /dev/null +++ b/ext/intl/tests/calendar_getType_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlCalendar::getType(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->getType(1)); + +var_dump(intlcal_get_type($c, 1)); +var_dump(intlcal_get_type(1)); + +--EXPECTF-- + +Warning: IntlCalendar::getType() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::getType(): intlcal_get_type: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_get_type() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_get_type(): intlcal_get_type: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_type() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getWeekendTransition_basic.phpt b/ext/intl/tests/calendar_getWeekendTransition_basic.phpt new file mode 100644 index 0000000000..e725743006 --- /dev/null +++ b/ext/intl/tests/calendar_getWeekendTransition_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlCalendar::getWeekendTransition() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.4') < 0) + die('skip for ICU 4.4+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance(); +var_dump($intlcal->getWeekendTransition(IntlCalendar::DOW_SUNDAY)); +var_dump(intlcal_get_weekend_transition($intlcal, IntlCalendar::DOW_SUNDAY)); +?> +==DONE== +--EXPECT-- +int(86400000) +int(86400000) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_getWeekendTransition_error.phpt b/ext/intl/tests/calendar_getWeekendTransition_error.phpt new file mode 100644 index 0000000000..f7c9cc7ed1 --- /dev/null +++ b/ext/intl/tests/calendar_getWeekendTransition_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +IntlCalendar::getWeekendTransition(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.4') < 0) + die('skip for ICU 4.4+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->getWeekendTransition()); +var_dump($c->getWeekendTransition(1, 2)); +var_dump($c->getWeekendTransition(0)); + +var_dump(intlcal_get_weekend_transition($c)); +var_dump(intlcal_get_weekend_transition(1, 1)); + +--EXPECTF-- + +Warning: IntlCalendar::getWeekendTransition() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getWeekendTransition(): intlcal_get_weekend_transition: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getWeekendTransition() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::getWeekendTransition(): intlcal_get_weekend_transition: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getWeekendTransition(): intlcal_get_weekend_transition: invalid day of week in %s on line %d +bool(false) + +Warning: intlcal_get_weekend_transition() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: intlcal_get_weekend_transition(): intlcal_get_weekend_transition: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_get_weekend_transition() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_getXMaximum_basic.phpt b/ext/intl/tests/calendar_getXMaximum_basic.phpt new file mode 100644 index 0000000000..9b840212d9 --- /dev/null +++ b/ext/intl/tests/calendar_getXMaximum_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlCalendar::getMaximum(), ::getActualMaximum(), ::getLeastMaximum() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('UTC'); +$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000); +var_dump( + $intlcal->getLeastMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_least_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), + $intlcal->getActualMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_actual_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), + $intlcal->getMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_maximum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH) +); + +?> +==DONE== +--EXPECT-- +int(28) +int(28) +int(29) +int(29) +int(31) +int(31) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_getXMinimum_basic.phpt b/ext/intl/tests/calendar_getXMinimum_basic.phpt new file mode 100644 index 0000000000..83fd163809 --- /dev/null +++ b/ext/intl/tests/calendar_getXMinimum_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlCalendar::getMinimum(), ::getActualMinimum(), ::getGreatestMinimum() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('UTC'); +$intlcal->setTime(strtotime('2012-02-29 05:06:07 +0000') * 1000); +var_dump( + $intlcal->getGreatestMinimum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_greatest_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), + $intlcal->getActualMinimum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_actual_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH), + $intlcal->getMinimum(IntlCalendar::FIELD_DAY_OF_MONTH), + intlcal_get_minimum($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH) +); + +?> +==DONE== +--EXPECT-- +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_get_Least_Greatest_Minimum_Maximum_error.phpt b/ext/intl/tests/calendar_get_Least_Greatest_Minimum_Maximum_error.phpt new file mode 100644 index 0000000000..acd9b58c1d --- /dev/null +++ b/ext/intl/tests/calendar_get_Least_Greatest_Minimum_Maximum_error.phpt @@ -0,0 +1,100 @@ +--TEST-- +IntlCalendar::get/Least/Greatest/Minimum/Maximum(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->getLeastMaximum()); +var_dump($c->getMaximum()); +var_dump($c->getGreatestMinimum()); +var_dump($c->getMinimum()); + +var_dump($c->getLeastMaximum(-1)); +var_dump($c->getMaximum(-1)); +var_dump($c->getGreatestMinimum(-1)); +var_dump($c->getMinimum(-1)); + +var_dump(intlcal_get_least_maximum($c, -1)); +var_dump(intlcal_get_maximum($c, -1)); +var_dump(intlcal_get_greatest_minimum($c, -1)); +var_dump(intlcal_get_minimum($c, -1)); + +function eh($errno, $errstr) { +echo "error: $errno, $errstr\n"; +} +set_error_handler('eh'); + +var_dump(intlcal_get_least_maximum(1, 1)); +var_dump(intlcal_get_maximum(1, 1)); +var_dump(intlcal_get_greatest_minimum(1, -1)); +var_dump(intlcal_get_minimum(1, -1)); + +--EXPECTF-- + +Warning: IntlCalendar::getLeastMaximum() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getLeastMaximum(): intlcal_get_least_maximum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getMaximum() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getMaximum(): intlcal_get_maximum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getGreatestMinimum() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getGreatestMinimum(): intlcal_get_greatest_minimum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getMinimum() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getMinimum(): intlcal_get_minimum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getLeastMaximum(): intlcal_get_least_maximum: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::getMaximum(): intlcal_get_maximum: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::getGreatestMinimum(): intlcal_get_greatest_minimum: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::getMinimum(): intlcal_get_minimum: invalid field in %s on line %d +bool(false) + +Warning: intlcal_get_least_maximum(): intlcal_get_least_maximum: invalid field in %s on line %d +bool(false) + +Warning: intlcal_get_maximum(): intlcal_get_maximum: invalid field in %s on line %d +bool(false) + +Warning: intlcal_get_greatest_minimum(): intlcal_get_greatest_minimum: invalid field in %s on line %d +bool(false) + +Warning: intlcal_get_minimum(): intlcal_get_minimum: invalid field in %s on line %d +bool(false) +error: 4096, Argument 1 passed to intlcal_get_least_maximum() must be an instance of IntlCalendar, integer given +error: 2, intlcal_get_least_maximum() expects parameter 1 to be IntlCalendar, integer given +error: 2, intlcal_get_least_maximum(): intlcal_get_least_maximum: bad arguments +bool(false) +error: 4096, Argument 1 passed to intlcal_get_maximum() must be an instance of IntlCalendar, integer given +error: 2, intlcal_get_maximum() expects parameter 1 to be IntlCalendar, integer given +error: 2, intlcal_get_maximum(): intlcal_get_maximum: bad arguments +bool(false) +error: 4096, Argument 1 passed to intlcal_get_greatest_minimum() must be an instance of IntlCalendar, integer given +error: 2, intlcal_get_greatest_minimum() expects parameter 1 to be IntlCalendar, integer given +error: 2, intlcal_get_greatest_minimum(): intlcal_get_greatest_minimum: bad arguments +bool(false) +error: 4096, Argument 1 passed to intlcal_get_minimum() must be an instance of IntlCalendar, integer given +error: 2, intlcal_get_minimum() expects parameter 1 to be IntlCalendar, integer given +error: 2, intlcal_get_minimum(): intlcal_get_minimum: bad arguments +bool(false) diff --git a/ext/intl/tests/calendar_get_basic.phpt b/ext/intl/tests/calendar_get_basic.phpt new file mode 100644 index 0000000000..c617639610 --- /dev/null +++ b/ext/intl/tests/calendar_get_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlCalendar::get() basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('UTC'); +$intlcal->set(IntlCalendar::FIELD_DAY_OF_MONTH, 4); + +var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); +var_dump(intlcal_get($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH)); + +?> +==DONE== +--EXPECT-- +int(4) +int(4) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error.phpt b/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error.phpt new file mode 100644 index 0000000000..f6ccb128ee --- /dev/null +++ b/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error.phpt @@ -0,0 +1,84 @@ +--TEST-- +IntlCalendar::get/getActualMaximum/getActualMinimum(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->get()); +var_dump($c->getActualMaximum()); +var_dump($c->getActualMinimum()); + +var_dump($c->get(-1)); +var_dump($c->getActualMaximum(-1)); +var_dump($c->getActualMinimum(-1)); + +var_dump($c->get("s")); +var_dump($c->getActualMaximum("s")); +var_dump($c->getActualMinimum("s")); + +var_dump($c->get(1, 2)); +var_dump($c->getActualMaximum(1, 2)); +var_dump($c->getActualMinimum(1, 2)); +--EXPECTF-- + +Warning: IntlCalendar::get() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::get(): intlcal_get: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMaximum() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMinimum() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::get(): intlcal_get: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::get() expects parameter 1 to be long, string given in %s on line %d + +Warning: IntlCalendar::get(): intlcal_get: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMaximum() expects parameter 1 to be long, string given in %s on line %d + +Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMinimum() expects parameter 1 to be long, string given in %s on line %d + +Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::get() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::get(): intlcal_get: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMaximum() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::getActualMaximum(): intlcal_get_actual_maximum: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::getActualMinimum() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::getActualMinimum(): intlcal_get_actual_minimum: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error2.phpt b/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error2.phpt new file mode 100644 index 0000000000..a8d1a4aa2f --- /dev/null +++ b/ext/intl/tests/calendar_get_getActualMaximum_Minumum_error2.phpt @@ -0,0 +1,71 @@ +--TEST-- +IntlCalendar::get/getActualMaximum/getActualMinimum(): bad arguments (procedural) +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +function eh($errno, $errstr) { +echo "error: $errno, $errstr\n"; +} +set_error_handler('eh'); + +var_dump(intlcal_get($c)); +var_dump(intlcal_get_actual_maximum($c)); +var_dump(intlcal_get_actual_minimum($c)); + +var_dump(intlcal_get($c, -1)); +var_dump(intlcal_get_actual_maximum($c, -1)); +var_dump(intlcal_get_actual_minimum($c, -1)); + +var_dump(intlcal_get($c, "s")); +var_dump(intlcal_get_actual_maximum($c, "s")); +var_dump(intlcal_get_actual_minimum($c, "s")); + +var_dump(intlcal_get(1)); +var_dump(intlcal_get_actual_maximum(1)); +var_dump(intlcal_get_actual_minimum(1)); +--EXPECT-- +error: 2, intlcal_get() expects exactly 2 parameters, 1 given +error: 2, intlcal_get(): intlcal_get: bad arguments +bool(false) +error: 2, intlcal_get_actual_maximum() expects exactly 2 parameters, 1 given +error: 2, intlcal_get_actual_maximum(): intlcal_get_actual_maximum: bad arguments +bool(false) +error: 2, intlcal_get_actual_minimum() expects exactly 2 parameters, 1 given +error: 2, intlcal_get_actual_minimum(): intlcal_get_actual_minimum: bad arguments +bool(false) +error: 2, intlcal_get(): intlcal_get: invalid field +bool(false) +error: 2, intlcal_get_actual_maximum(): intlcal_get_actual_maximum: invalid field +bool(false) +error: 2, intlcal_get_actual_minimum(): intlcal_get_actual_minimum: invalid field +bool(false) +error: 2, intlcal_get() expects parameter 2 to be long, string given +error: 2, intlcal_get(): intlcal_get: bad arguments +bool(false) +error: 2, intlcal_get_actual_maximum() expects parameter 2 to be long, string given +error: 2, intlcal_get_actual_maximum(): intlcal_get_actual_maximum: bad arguments +bool(false) +error: 2, intlcal_get_actual_minimum() expects parameter 2 to be long, string given +error: 2, intlcal_get_actual_minimum(): intlcal_get_actual_minimum: bad arguments +bool(false) +error: 4096, Argument 1 passed to intlcal_get() must be an instance of IntlCalendar, integer given +error: 2, intlcal_get() expects exactly 2 parameters, 1 given +error: 2, intlcal_get(): intlcal_get: bad arguments +bool(false) +error: 4096, Argument 1 passed to intlcal_get_actual_maximum() must be an instance of IntlCalendar, integer given +error: 2, intlcal_get_actual_maximum() expects exactly 2 parameters, 1 given +error: 2, intlcal_get_actual_maximum(): intlcal_get_actual_maximum: bad arguments +bool(false) +error: 4096, Argument 1 passed to intlcal_get_actual_minimum() must be an instance of IntlCalendar, integer given +error: 2, intlcal_get_actual_minimum() expects exactly 2 parameters, 1 given +error: 2, intlcal_get_actual_minimum(): intlcal_get_actual_minimum: bad arguments +bool(false) diff --git a/ext/intl/tests/calendar_get_setRepeatedWallTimeOption_basic.phpt b/ext/intl/tests/calendar_get_setRepeatedWallTimeOption_basic.phpt new file mode 100644 index 0000000000..52765433fe --- /dev/null +++ b/ext/intl/tests/calendar_get_setRepeatedWallTimeOption_basic.phpt @@ -0,0 +1,49 @@ +--TEST-- +IntlCalendar::get/setRepeatedWallTimeOption(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '49') < 0) + die('skip for ICU 49+'); +--FILE-- + +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +date_default_timezone_set('Europe/Amsterdam'); + +//28 October 2012, transition from DST +$intlcal = new IntlGregorianCalendar(2012, 9, 28, 0, 0, 0); +var_dump($intlcal->setRepeatedWallTimeOption(IntlCalendar::WALLTIME_LAST)); +var_dump($intlcal->getRepeatedWallTimeOption()); +$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2); +$intlcal->set(IntlCalendar::FIELD_MINUTE, 30); +var_dump( + strtotime('2012-10-28 02:30:00 +0100'), + (int)($intlcal->getTime() /1000) +); + +var_dump(intlcal_set_repeated_wall_time_option($intlcal, IntlCalendar::WALLTIME_FIRST)); +var_dump(intlcal_get_repeated_wall_time_option($intlcal)); +$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2); +$intlcal->set(IntlCalendar::FIELD_MINUTE, 30); +var_dump( + strtotime('2012-10-28 02:30:00 +0200'), + (int)($intlcal->getTime() /1000) +); + +?> +==DONE== +--EXPECT-- + +bool(true) +int(0) +int(1351387800) +int(1351387800) +bool(true) +int(1) +int(1351384200) +int(1351384200) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_get_setSkippedWallTimeOption_basic.phpt b/ext/intl/tests/calendar_get_setSkippedWallTimeOption_basic.phpt new file mode 100644 index 0000000000..bbbf031c88 --- /dev/null +++ b/ext/intl/tests/calendar_get_setSkippedWallTimeOption_basic.phpt @@ -0,0 +1,67 @@ +--TEST-- +IntlCalendar::get/setSkippedWallTimeOption(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '49') < 0) + die('skip for ICU 49+'); +--FILE-- + +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +date_default_timezone_set('Europe/Amsterdam'); + +//25 March 2012, transition to DST +$intlcal = new IntlGregorianCalendar(2012, 2, 25, 0, 0, 0); +var_dump($intlcal->getSkippedWallTimeOption()); +$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2); +$intlcal->set(IntlCalendar::FIELD_MINUTE, 30); +echo "Should be 3h30\n"; +var_dump( + $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY), + $intlcal->get(IntlCalendar::FIELD_MINUTE) +); + +var_dump($intlcal->setSkippedWallTimeOption(IntlCalendar::WALLTIME_FIRST)); +var_dump(intlcal_get_skipped_wall_time_option($intlcal)); +$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2); +$intlcal->set(IntlCalendar::FIELD_MINUTE, 30); +echo "Should be 1h30\n"; +var_dump( + $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY), + $intlcal->get(IntlCalendar::FIELD_MINUTE) +); + +var_dump(intlcal_set_skipped_wall_time_option($intlcal, IntlCalendar::WALLTIME_NEXT_VALID)); +var_dump($intlcal->getSkippedWallTimeOption()); +$intlcal->set(IntlCalendar::FIELD_HOUR_OF_DAY, 2); +$intlcal->set(IntlCalendar::FIELD_MINUTE, 30); +echo "Should be 3h00\n"; +var_dump( + $intlcal->get(IntlCalendar::FIELD_HOUR_OF_DAY), + $intlcal->get(IntlCalendar::FIELD_MINUTE) +); + + +?> +==DONE== +--EXPECT-- + +int(0) +Should be 3h30 +int(3) +int(30) +bool(true) +int(1) +Should be 1h30 +int(1) +int(30) +bool(true) +int(2) +Should be 3h00 +int(3) +int(0) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_inDaylightTime_basic.phpt b/ext/intl/tests/calendar_inDaylightTime_basic.phpt new file mode 100644 index 0000000000..dff8ef50d3 --- /dev/null +++ b/ext/intl/tests/calendar_inDaylightTime_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlCalendar::inDaylightTime() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('Europe/Amsterdam'); +$intlcal->setTime(strtotime('2012-01-01') * 1000); +var_dump($intlcal->inDaylightTime()); +$intlcal->setTime(strtotime('2012-04-01') * 1000); +var_dump(intlcal_in_daylight_time($intlcal)); +?> +==DONE== +--EXPECT-- +bool(false) +bool(true) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_inDaylightTime_error.phpt b/ext/intl/tests/calendar_inDaylightTime_error.phpt new file mode 100644 index 0000000000..9af9aa5048 --- /dev/null +++ b/ext/intl/tests/calendar_inDaylightTime_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlCalendar::inDaylightTime(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->inDaylightTime(1)); + +var_dump(intlcal_in_daylight_time($c, 1)); +var_dump(intlcal_in_daylight_time(1)); + +--EXPECTF-- + +Warning: IntlCalendar::inDaylightTime() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::inDaylightTime(): intlcal_in_daylight_time: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_in_daylight_time() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_in_daylight_time(): intlcal_in_daylight_time: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_in_daylight_time() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_isEquivalentTo_basic.phpt b/ext/intl/tests/calendar_isEquivalentTo_basic.phpt new file mode 100644 index 0000000000..f71fd8ad5b --- /dev/null +++ b/ext/intl/tests/calendar_isEquivalentTo_basic.phpt @@ -0,0 +1,40 @@ +--TEST-- +IntlCalendar::isEquivalentTo() basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal1 = IntlCalendar::createInstance('Europe/Amsterdam'); +$intlcal2 = IntlCalendar::createInstance('Europe/Lisbon'); +$intlcal3 = IntlCalendar::createInstance('Europe/Amsterdam', "nl_NL@calendar=islamic"); +$intlcal4 = IntlCalendar::createInstance('Europe/Amsterdam'); +$intlcal4->roll(IntlCalendar::FIELD_MONTH, true); + +var_dump( + "1 - 1", + $intlcal1->isEquivalentTo($intlcal1), + "1 - 2", + $intlcal1->isEquivalentTo($intlcal2), + "1 - 3", + $intlcal1->isEquivalentTo($intlcal3), + "1 - 4", + $intlcal1->isEquivalentTo($intlcal4) +); + +?> +==DONE== +--EXPECT-- +string(5) "1 - 1" +bool(true) +string(5) "1 - 2" +bool(false) +string(5) "1 - 3" +bool(false) +string(5) "1 - 4" +bool(true) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_isEquivalentTo_error.phpt b/ext/intl/tests/calendar_isEquivalentTo_error.phpt new file mode 100644 index 0000000000..4fa7da5eb6 --- /dev/null +++ b/ext/intl/tests/calendar_isEquivalentTo_error.phpt @@ -0,0 +1,50 @@ +--TEST-- +IntlCalendar::isEquivalentTo(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +function eh($errno, $errstr) { +echo "error: $errno, $errstr\n"; +} +set_error_handler('eh'); + +var_dump($c->isEquivalentTo(0)); +var_dump($c->isEquivalentTo($c, 1)); +var_dump($c->isEquivalentTo(1)); + +var_dump(intlcal_is_equivalent_to($c)); +var_dump(intlcal_is_equivalent_to($c, 1)); +var_dump(intlcal_is_equivalent_to(1, $c)); + +--EXPECT-- +error: 4096, Argument 1 passed to IntlCalendar::isEquivalentTo() must be an instance of IntlCalendar, integer given +error: 2, IntlCalendar::isEquivalentTo() expects parameter 1 to be IntlCalendar, integer given +error: 2, IntlCalendar::isEquivalentTo(): intlcal_is_equivalent_to: bad arguments +bool(false) +error: 2, IntlCalendar::isEquivalentTo() expects exactly 1 parameter, 2 given +error: 2, IntlCalendar::isEquivalentTo(): intlcal_is_equivalent_to: bad arguments +bool(false) +error: 4096, Argument 1 passed to IntlCalendar::isEquivalentTo() must be an instance of IntlCalendar, integer given +error: 2, IntlCalendar::isEquivalentTo() expects parameter 1 to be IntlCalendar, integer given +error: 2, IntlCalendar::isEquivalentTo(): intlcal_is_equivalent_to: bad arguments +bool(false) +error: 2, intlcal_is_equivalent_to() expects exactly 2 parameters, 1 given +error: 2, intlcal_is_equivalent_to(): intlcal_is_equivalent_to: bad arguments +bool(false) +error: 4096, Argument 2 passed to intlcal_is_equivalent_to() must be an instance of IntlCalendar, integer given +error: 2, intlcal_is_equivalent_to() expects parameter 2 to be IntlCalendar, integer given +error: 2, intlcal_is_equivalent_to(): intlcal_is_equivalent_to: bad arguments +bool(false) +error: 4096, Argument 1 passed to intlcal_is_equivalent_to() must be an instance of IntlCalendar, integer given +error: 2, intlcal_is_equivalent_to() expects parameter 1 to be IntlCalendar, integer given +error: 2, intlcal_is_equivalent_to(): intlcal_is_equivalent_to: bad arguments +bool(false) diff --git a/ext/intl/tests/calendar_isLenient_error.phpt b/ext/intl/tests/calendar_isLenient_error.phpt new file mode 100644 index 0000000000..7ddde1ae02 --- /dev/null +++ b/ext/intl/tests/calendar_isLenient_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlCalendar::isLenient(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->isLenient(1)); + +var_dump(intlcal_is_lenient($c, 1)); +var_dump(intlcal_is_lenient(1)); + +--EXPECTF-- + +Warning: IntlCalendar::isLenient() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::isLenient(): intlcal_is_lenient: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_is_lenient() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_is_lenient(): intlcal_is_lenient: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_is_lenient() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_isSet_basic.phpt b/ext/intl/tests/calendar_isSet_basic.phpt new file mode 100644 index 0000000000..8ef01448d5 --- /dev/null +++ b/ext/intl/tests/calendar_isSet_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlCalendar::isSet() basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('UTC'); +var_dump($intlcal->isSet(IntlCalendar::FIELD_MINUTE)); +$intlcal->clear(IntlCalendar::FIELD_MINUTE); +var_dump($intlcal->isSet(IntlCalendar::FIELD_MINUTE)); +$intlcal->set(IntlCalendar::FIELD_MINUTE, 0); +var_dump(intlcal_is_set($intlcal, IntlCalendar::FIELD_MINUTE)); +?> +==DONE== +--EXPECT-- +bool(true) +bool(false) +bool(true) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_isSet_error.phpt b/ext/intl/tests/calendar_isSet_error.phpt new file mode 100644 index 0000000000..f238d776b2 --- /dev/null +++ b/ext/intl/tests/calendar_isSet_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +IntlCalendar::isSet(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->isSet()); +var_dump($c->isSet(1, 2)); +var_dump($c->isSet(-1)); + +var_dump(intlcal_is_set($c)); +var_dump(intlcal_is_set(1, 2)); + +--EXPECTF-- + +Warning: IntlCalendar::isSet() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::isSet(): intlcal_is_set: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::isSet() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::isSet(): intlcal_is_set: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::isSet(): intlcal_is_set: invalid field in %s on line %d +bool(false) + +Warning: intlcal_is_set() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: intlcal_is_set(): intlcal_is_set: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_is_set() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_isWeekend_basic.phpt b/ext/intl/tests/calendar_isWeekend_basic.phpt new file mode 100644 index 0000000000..d6452c71f7 --- /dev/null +++ b/ext/intl/tests/calendar_isWeekend_basic.phpt @@ -0,0 +1,26 @@ +--TEST-- +IntlCalendar::isWeekend basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.4') < 0) + die('skip for ICU 4.4+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('UTC'); +var_dump($intlcal->isWeekend(strtotime('2012-02-29 12:00:00 +0000') * 1000)); +var_dump(intlcal_is_weekend($intlcal, strtotime('2012-02-29 12:00:00 +0000') * 1000)); +var_dump($intlcal->isWeekend(strtotime('2012-03-11 12:00:00 +0000') * 1000)); +?> +==DONE== +--EXPECT-- +bool(false) +bool(false) +bool(true) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_isWeekend_error.phpt b/ext/intl/tests/calendar_isWeekend_error.phpt new file mode 100644 index 0000000000..7939a66a14 --- /dev/null +++ b/ext/intl/tests/calendar_isWeekend_error.phpt @@ -0,0 +1,38 @@ +--TEST-- +IntlCalendar::isWeekend(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.4') < 0) + die('skip for ICU 4.4+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->isWeekend(1, 2)); +var_dump($c->isWeekend("jhhk")); + +var_dump(intlcal_is_weekend($c, "jj")); +var_dump(intlcal_is_weekend(1)); + +--EXPECTF-- + +Warning: IntlCalendar::isWeekend(): intlcal_is_weekend: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::isWeekend() expects parameter 1 to be double, string given in %s on line %d + +Warning: IntlCalendar::isWeekend(): intlcal_is_weekend: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_is_weekend() expects parameter 2 to be double, string given in %s on line %d + +Warning: intlcal_is_weekend(): intlcal_is_weekend: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_is_weekend() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_is_set_lenient_basic.phpt b/ext/intl/tests/calendar_is_set_lenient_basic.phpt new file mode 100644 index 0000000000..64f537f9bc --- /dev/null +++ b/ext/intl/tests/calendar_is_set_lenient_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +IntlCalendar::isLenient(), ::setLenient() basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal1 = IntlCalendar::createInstance('UTC'); +var_dump($intlcal1->isLenient()); +var_dump(intlcal_is_lenient($intlcal1)); +var_dump($intlcal1->setLenient(false)); +var_dump($intlcal1->isLenient()); +var_dump(intlcal_set_lenient($intlcal1, true)); +var_dump($intlcal1->isLenient()); +?> +==DONE== +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(false) +bool(true) +bool(true) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_roll_basic.phpt b/ext/intl/tests/calendar_roll_basic.phpt new file mode 100644 index 0000000000..971c36217b --- /dev/null +++ b/ext/intl/tests/calendar_roll_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlCalendar::roll() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = new IntlGregorianCalendar(2012, 1, 28); +var_dump($intlcal->roll(IntlCalendar::FIELD_DAY_OF_MONTH, 2)); +var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb) +var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //1 + +$intlcal = new IntlGregorianCalendar(2012, 1, 28); +var_dump(intlcal_roll($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH, 2)); +var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb) +var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //1 + + +?> +==DONE== +--EXPECT-- +bool(true) +int(1) +int(1) +bool(true) +int(1) +int(1) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_roll_error.phpt b/ext/intl/tests/calendar_roll_error.phpt new file mode 100644 index 0000000000..a567394699 --- /dev/null +++ b/ext/intl/tests/calendar_roll_error.phpt @@ -0,0 +1,37 @@ +--TEST-- +IntlCalendar::roll(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->roll(1, 2, 3)); +var_dump($c->roll(-1, 2)); +var_dump($c->roll(1)); + +var_dump(intlcal_roll($c, 1, 2, 3)); +var_dump(intlcal_roll(1, 2, 3)); +--EXPECTF-- + +Warning: IntlCalendar::roll(): intlcal_set: too many arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::roll(): intlcal_roll: invalid field in %s on line %d +bool(false) + +Warning: IntlCalendar::roll() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::roll(): intlcal_roll: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_roll(): intlcal_set: too many arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_roll() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_roll_variation1.phpt b/ext/intl/tests/calendar_roll_variation1.phpt new file mode 100644 index 0000000000..9fb8d75e5a --- /dev/null +++ b/ext/intl/tests/calendar_roll_variation1.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlCalendar::roll() bool argument variation +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = new IntlGregorianCalendar(2012, 1, 28); +var_dump($intlcal->roll(IntlCalendar::FIELD_DAY_OF_MONTH, true)); +var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb) +var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //29 + +var_dump(intlcal_roll($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH, false)); +var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb) +var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //28 + +?> +==DONE== +--EXPECT-- +bool(true) +int(1) +int(29) +bool(true) +int(1) +int(28) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt b/ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt new file mode 100644 index 0000000000..79b38104e4 --- /dev/null +++ b/ext/intl/tests/calendar_setFirstDayOfWeek_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +IntlCalendar::setFirstDayOfWeek() basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('UTC'); +var_dump( + IntlCalendar::DOW_TUESDAY, + $intlcal->setFirstDayOfWeek(IntlCalendar::DOW_TUESDAY), + $intlcal->getFirstDayOfWeek(), + intlcal_set_first_day_of_week($intlcal, IntlCalendar::DOW_WEDNESDAY), + $intlcal->getFirstDayOfWeek() +); +?> +==DONE== +--EXPECT-- +int(3) +bool(true) +int(3) +bool(true) +int(4) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_setFirstDayOfWeek_error.phpt b/ext/intl/tests/calendar_setFirstDayOfWeek_error.phpt new file mode 100644 index 0000000000..98237e56fa --- /dev/null +++ b/ext/intl/tests/calendar_setFirstDayOfWeek_error.phpt @@ -0,0 +1,40 @@ +--TEST-- +IntlCalendar::setFirstDayOfWeek(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->setFirstDayOfWeek()); +var_dump($c->setFirstDayOfWeek(1, 2)); +var_dump($c->setFirstDayOfWeek(0)); + +var_dump(intlcal_set_first_day_of_week($c, 0)); +var_dump(intlcal_set_first_day_of_week(1, 2)); + +--EXPECTF-- + +Warning: IntlCalendar::setFirstDayOfWeek() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::setFirstDayOfWeek(): intlcal_set_first_day_of_week: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setFirstDayOfWeek() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::setFirstDayOfWeek(): intlcal_set_first_day_of_week: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setFirstDayOfWeek(): intlcal_set_first_day_of_week: invalid day of week in %s on line %d +bool(false) + +Warning: intlcal_set_first_day_of_week(): intlcal_set_first_day_of_week: invalid day of week in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_set_first_day_of_week() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_setLenient_error.phpt b/ext/intl/tests/calendar_setLenient_error.phpt new file mode 100644 index 0000000000..2b1d7b016d --- /dev/null +++ b/ext/intl/tests/calendar_setLenient_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +IntlCalendar::setLenient(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->setLenient()); +var_dump($c->setLenient(array())); +var_dump($c->setLenient(1, 2)); + +var_dump(intlcal_set_lenient($c, array())); +var_dump(intlcal_set_lenient(1, false)); + +--EXPECTF-- + +Warning: IntlCalendar::setLenient() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::setLenient(): intlcal_set_lenient: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setLenient() expects parameter 1 to be boolean, array given in %s on line %d + +Warning: IntlCalendar::setLenient(): intlcal_set_lenient: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setLenient() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::setLenient(): intlcal_set_lenient: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_set_lenient() expects parameter 2 to be boolean, array given in %s on line %d + +Warning: intlcal_set_lenient(): intlcal_set_lenient: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_set_lenient() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_setSkipped_RepeatedWallTimeOption_error.phpt b/ext/intl/tests/calendar_setSkipped_RepeatedWallTimeOption_error.phpt new file mode 100644 index 0000000000..dab55d2b29 --- /dev/null +++ b/ext/intl/tests/calendar_setSkipped_RepeatedWallTimeOption_error.phpt @@ -0,0 +1,82 @@ +--TEST-- +IntlCalendar::setSkipped/RepeatedWallTimeOption(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '49') < 0) + die('skip for ICU 49+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->setSkippedWallTimeOption()); +var_dump($c->setRepeatedWallTimeOption()); + +var_dump($c->setSkippedWallTimeOption(1, 2)); +var_dump($c->setRepeatedWallTimeOption(1, 2)); + +var_dump($c->setSkippedWallTimeOption(array())); +var_dump($c->setRepeatedWallTimeOption(array())); + +var_dump($c->setSkippedWallTimeOption(3)); +var_dump($c->setRepeatedWallTimeOption(2)); + +var_dump(intlcal_set_skipped_wall_time_option($c)); +var_dump(intlcal_set_repeated_wall_time_option($c)); + +var_dump(intlcal_set_repeated_wall_time_option(1, 1)); + +--EXPECTF-- + +Warning: IntlCalendar::setSkippedWallTimeOption() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setRepeatedWallTimeOption() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setSkippedWallTimeOption() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setRepeatedWallTimeOption() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setSkippedWallTimeOption() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setRepeatedWallTimeOption() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setSkippedWallTimeOption(): intlcal_set_skipped_wall_time_option: invalid option in %s on line %d +bool(false) + +Warning: IntlCalendar::setRepeatedWallTimeOption(): intlcal_set_repeated_wall_time_option: invalid option in %s on line %d +bool(false) + +Warning: intlcal_set_skipped_wall_time_option() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: intlcal_set_skipped_wall_time_option(): intlcal_set_skipped_wall_time_option: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_set_repeated_wall_time_option() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: intlcal_set_repeated_wall_time_option(): intlcal_set_repeated_wall_time_option: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_set_repeated_wall_time_option() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_setTimeZone_basic.phpt b/ext/intl/tests/calendar_setTimeZone_basic.phpt new file mode 100644 index 0000000000..525840ddd6 --- /dev/null +++ b/ext/intl/tests/calendar_setTimeZone_basic.phpt @@ -0,0 +1,39 @@ +--TEST-- +IntlCalendar::setTimeZone() basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('Europe/Amsterdam'); +print_r($intlcal->getTimeZone()->getID()); +echo "\n"; +var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET)); + +$intlcal->setTimeZone(IntlTimeZone::getGMT()); +print_r($intlcal->getTimeZone()->getID()); +echo "\n"; +var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET)); + +intlcal_set_time_zone($intlcal, + IntlTimeZone::createTimeZone('GMT+05:30')); +print_r($intlcal->getTimeZone()->getID()); +echo "\n"; +var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET)); + +?> +==DONE== +--EXPECT-- +Europe/Amsterdam +int(3600000) +GMT +int(0) +GMT+05:30 +int(19800000) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_setTimeZone_error.phpt b/ext/intl/tests/calendar_setTimeZone_error.phpt new file mode 100644 index 0000000000..ebe4d119ea --- /dev/null +++ b/ext/intl/tests/calendar_setTimeZone_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +IntlCalendar::setTimeZone(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +$gmt = IntlTimeZone::getGMT(); + +function eh($errno, $errstr) { +echo "error: $errno, $errstr\n"; +} +set_error_handler('eh'); + +var_dump($c->setTimeZone($gmt, 2)); +var_dump($c->setTimeZone()); + +var_dump(intlcal_set_time_zone($c, 1, 2)); +var_dump(intlcal_set_time_zone(1, $gmt)); + +--EXPECT-- +error: 2, IntlCalendar::setTimeZone() expects exactly 1 parameter, 2 given +error: 2, IntlCalendar::setTimeZone(): intlcal_set_time_zone: bad arguments +bool(false) +error: 2, IntlCalendar::setTimeZone() expects exactly 1 parameter, 0 given +error: 2, IntlCalendar::setTimeZone(): intlcal_set_time_zone: bad arguments +bool(false) +error: 2, intlcal_set_time_zone() expects exactly 2 parameters, 3 given +error: 2, intlcal_set_time_zone(): intlcal_set_time_zone: bad arguments +bool(false) +error: 4096, Argument 1 passed to intlcal_set_time_zone() must be an instance of IntlCalendar, integer given +error: 2, intlcal_set_time_zone() expects parameter 1 to be IntlCalendar, integer given +error: 2, intlcal_set_time_zone(): intlcal_set_time_zone: bad arguments +bool(false) diff --git a/ext/intl/tests/calendar_setTimeZone_error2.phpt b/ext/intl/tests/calendar_setTimeZone_error2.phpt new file mode 100644 index 0000000000..aa1eaba209 --- /dev/null +++ b/ext/intl/tests/calendar_setTimeZone_error2.phpt @@ -0,0 +1,29 @@ +--TEST-- +IntlCalendar::setTimeZone(): valid time zones for DateTime but not ICU +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); +date_default_timezone_set('Europe/Amsterdam'); + +$intlcal = new IntlGregorianCalendar(); + +$pstdate = new DateTime('2012-01-01 00:00:00 WEST'); +$intlcal->setTimeZone($pstdate->getTimeZone()); +var_dump($intlcal->getTimeZone()->getID()); + +$pstdate = new DateTime('2012-01-01 00:00:00 +24:00'); +$intlcal->setTimeZone($pstdate->getTimeZone()); +var_dump($intlcal->getTimeZone()->getID()); + +--EXPECTF-- + +Warning: IntlCalendar::setTimeZone(): intlcal_set_time_zone: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d +string(16) "Europe/Amsterdam" + +Warning: IntlCalendar::setTimeZone(): intlcal_set_time_zone: object has an time zone offset that's too large in %s on line %d +string(16) "Europe/Amsterdam" diff --git a/ext/intl/tests/calendar_setTimeZone_variation1.phpt b/ext/intl/tests/calendar_setTimeZone_variation1.phpt new file mode 100644 index 0000000000..b1cbb74edf --- /dev/null +++ b/ext/intl/tests/calendar_setTimeZone_variation1.phpt @@ -0,0 +1,30 @@ +--TEST-- +IntlCalendar::setTimeZone() variation with NULL arg +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('Europe/Amsterdam'); +print_r($intlcal->getTimeZone()->getID()); +echo "\n"; +var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET)); + +/* passing NULL has no effect */ +$intlcal->setTimeZone(null); +print_r($intlcal->getTimeZone()->getID()); +echo "\n"; +var_dump($intlcal->get(IntlCalendar::FIELD_ZONE_OFFSET)); + +?> +==DONE== +--EXPECT-- +Europe/Amsterdam +int(3600000) +Europe/Amsterdam +int(3600000) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_setTimeZone_variation2.phpt b/ext/intl/tests/calendar_setTimeZone_variation2.phpt new file mode 100644 index 0000000000..7f4a7ffa37 --- /dev/null +++ b/ext/intl/tests/calendar_setTimeZone_variation2.phpt @@ -0,0 +1,30 @@ +--TEST-- +IntlCalendar::setTimeZone(): different ways to specify time zone +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); +date_default_timezone_set('Europe/Amsterdam'); + +$intlcal = new IntlGregorianCalendar(); +$intlcal->setTimeZone('Europe/Paris'); +var_dump($intlcal->getTimeZone()->getID()); +$intlcal->setTimeZone(new DateTimeZone('Europe/Madrid')); +var_dump($intlcal->getTimeZone()->getID()); + +$pstdate = new DateTime('2012-01-01 00:00:00 PST'); +$intlcal->setTimeZone($pstdate->getTimeZone()); +var_dump($intlcal->getTimeZone()->getID()); + +$offsetdate = new DateTime('2012-01-01 00:00:00 -02:30'); +$intlcal->setTimeZone($offsetdate->getTimeZone()); +var_dump($intlcal->getTimeZone()->getID()); +--EXPECTF-- +string(12) "Europe/Paris" +string(13) "Europe/Madrid" +string(3) "PST" +string(%d) "GMT-02%S30" diff --git a/ext/intl/tests/calendar_setTime_basic.phpt b/ext/intl/tests/calendar_setTime_basic.phpt new file mode 100644 index 0000000000..f7f213c0d8 --- /dev/null +++ b/ext/intl/tests/calendar_setTime_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlCalendar::setTime() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$time = strtotime('2012-02-29 00:00:00 +0000'); + +$intlcal = IntlCalendar::createInstance('UTC'); +$intlcal->setTime($time * 1000); + +var_dump( + (float)$time*1000, + $intlcal->getTime()); + +$intlcal = IntlCalendar::createInstance('UTC'); +intlcal_set_time($intlcal,$time * 1000); +var_dump(intlcal_get_time($intlcal)); + +?> +==DONE== +--EXPECT-- +float(1330473600000) +float(1330473600000) +float(1330473600000) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_setTime_error.phpt b/ext/intl/tests/calendar_setTime_error.phpt new file mode 100644 index 0000000000..71c5b0a1bd --- /dev/null +++ b/ext/intl/tests/calendar_setTime_error.phpt @@ -0,0 +1,37 @@ +--TEST-- +IntlCalendar::setTime(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->setTime(1, 2)); +var_dump($c->setTime("jjj")); + +var_dump(intlcal_set_time($c, 1, 2)); +var_dump(intlcal_set_time(1)); +--EXPECTF-- + +Warning: IntlCalendar::setTime() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlCalendar::setTime(): intlcal_set_time: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::setTime() expects parameter 1 to be double, string given in %s on line %d + +Warning: IntlCalendar::setTime(): intlcal_set_time: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_set_time() expects exactly 2 parameters, 3 given in %s on line %d + +Warning: intlcal_set_time(): intlcal_set_time: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_set_time() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_set_basic.phpt b/ext/intl/tests/calendar_set_basic.phpt new file mode 100644 index 0000000000..8eccb32da6 --- /dev/null +++ b/ext/intl/tests/calendar_set_basic.phpt @@ -0,0 +1,27 @@ +--TEST-- +IntlCalendar::set() basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance(); +var_dump($intlcal->set(IntlCalendar::FIELD_DAY_OF_MONTH, 2)); +var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); +var_dump(intlcal_set($intlcal, IntlCalendar::FIELD_DAY_OF_MONTH, 3)); +var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); + +?> +==DONE== +--EXPECT-- +bool(true) +int(2) +bool(true) +int(3) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_set_error.phpt b/ext/intl/tests/calendar_set_error.phpt new file mode 100644 index 0000000000..669b1888e0 --- /dev/null +++ b/ext/intl/tests/calendar_set_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +IntlCalendar::set(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +var_dump($c->set(1)); +var_dump($c->set(1, 2, 3, 4)); +var_dump($c->set(1, 2, 3, 4, 5, 6, 7)); +var_dump($c->set(-1, 2)); + +var_dump(intlcal_set($c, -1, 2)); +var_dump(intlcal_set(1, 2, 3)); +--EXPECTF-- + +Warning: IntlCalendar::set() expects at least 2 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::set(): intlcal_set: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::set(): intlcal_set: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::set(): intlcal_set: too many arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::set(): intlcal_set: invalid field in %s on line %d +bool(false) + +Warning: intlcal_set(): intlcal_set: invalid field in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlcal_set() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/calendar_set_variation1.phpt b/ext/intl/tests/calendar_set_variation1.phpt new file mode 100644 index 0000000000..8ea016ed61 --- /dev/null +++ b/ext/intl/tests/calendar_set_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +IntlCalendar::set() argument variations +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$intlcal = IntlCalendar::createInstance('UTC'); +$intlcal->clear(); +var_dump($intlcal->set(2012, 1, 29)); +var_dump($intlcal->getTime(), + strtotime('2012-02-29 00:00:00 +0000') * 1000.); + +//two minutes to midnight! +var_dump($intlcal->set(2012, 1, 29, 23, 58)); +var_dump($intlcal->getTime(), + strtotime('2012-02-29 23:58:00 +0000') * 1000.); + +var_dump($intlcal->set(2012, 1, 29, 23, 58, 31)); +var_dump($intlcal->getTime(), + strtotime('2012-02-29 23:58:31 +0000') * 1000.); + +?> +==DONE== +--EXPECT-- +bool(true) +float(1330473600000) +float(1330473600000) +bool(true) +float(1330559880000) +float(1330559880000) +bool(true) +float(1330559911000) +float(1330559911000) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_toDateTime_basic.phpt b/ext/intl/tests/calendar_toDateTime_basic.phpt new file mode 100644 index 0000000000..d38487dabf --- /dev/null +++ b/ext/intl/tests/calendar_toDateTime_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlCalendar::toDateTime(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +//ini_set("intl.default_locale", "nl"); +ini_set('date.timezone', 'Europe/Lisbon'); + +$cal = new IntlGregorianCalendar(2012,04,17,17,35,36); + +$dt = $cal->toDateTime(); + +var_dump($dt->format("c"), $dt->getTimeZone()->getName()); +?> +==DONE== +--EXPECT-- +string(25) "2012-05-17T17:35:36+01:00" +string(13) "Europe/Lisbon" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/calendar_toDateTime_error.phpt b/ext/intl/tests/calendar_toDateTime_error.phpt new file mode 100644 index 0000000000..961a9c86a6 --- /dev/null +++ b/ext/intl/tests/calendar_toDateTime_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +IntlCalendar::toDateTime(): bad arguments +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set('date.timezone', 'Europe/Lisbon'); + +$cal = new IntlGregorianCalendar(); +var_dump($cal->toDateTime(3)); + +var_dump(intlcal_to_date_time($cal, 3)); + +$cal = new IntlGregorianCalendar("Etc/Unknown"); +try { +var_dump($cal->toDateTime()); +} catch (Exception $e) { +var_dump("exception: {$e->getMessage()}"); +} + +var_dump(intlcal_to_date_time(3)); + +--EXPECTF-- + +Warning: IntlCalendar::toDateTime() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: bad arguments in %s on line %d +bool(false) + +Warning: intlcal_to_date_time() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlcal_to_date_time(): intlcal_to_date_time: bad arguments in %s on line %d +bool(false) + +Warning: IntlCalendar::toDateTime(): intlcal_to_date_time: DateTimeZone constructor threw exception in %s on line %d +string(77) "exception: DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)" + +Catchable fatal error: Argument 1 passed to intlcal_to_date_time() must be an instance of IntlCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/cpbi_clone_equality.phpt b/ext/intl/tests/cpbi_clone_equality.phpt new file mode 100644 index 0000000000..c62b452747 --- /dev/null +++ b/ext/intl/tests/cpbi_clone_equality.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlCodePointBreakIterator: clone and equality +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); + +$text = 'ตัวà¸à¸¢à¹ˆà¸²à¸‡à¸‚้à¸à¸„วาม'; +$text2 = 'foo'; + +$it = IntlBreakIterator::createCodePointInstance(); +$it->setText($text); + +$it_clone = clone $it; +var_dump($it == $it_clone); + +$it->setText($text2 ); +var_dump($it == $it_clone); + +$it_clone->setText($text2); +var_dump($it == $it_clone); + +?> +==DONE== +--EXPECT-- +bool(true) +bool(false) +bool(true) +==DONE== diff --git a/ext/intl/tests/cpbi_getLastCodePoint_basic.phpt b/ext/intl/tests/cpbi_getLastCodePoint_basic.phpt new file mode 100644 index 0000000000..74a07a6292 --- /dev/null +++ b/ext/intl/tests/cpbi_getLastCodePoint_basic.phpt @@ -0,0 +1,82 @@ +--TEST-- +IntlCodepointBreakIterator::getLastCodePoint(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); + +$text = 'ตัวà¸à¸¢à¹ˆà¸²à¸‡à¸‚้à¸à¸„วาม'; + +$codepoint_it = IntlBreakIterator::createCodePointInstance(); +$codepoint_it->setText($text); + +var_dump($codepoint_it->getLastCodePoint()); +//first() and last() don't read codepoint and set the last code point var to -1 +//The pointer is after the last read codepoint if moving forward and +//before the last read codepoint is moving backwards +$p = $codepoint_it->first(); +while ($p != IntlBreakIterator::DONE) { + $c = $codepoint_it->getLastCodePoint(); + if ($c > 0) + var_dump(sprintf('U+%04X', $codepoint_it->getLastCodePoint())); + else + var_dump($c); + //it's a post-increment operation as to the codepoint, i.e., it gives the codepoint + //starting at the initial position and only then moves the pointer forward + $p = $codepoint_it->next(); +} + +echo "Now backwards\n"; +$p = $codepoint_it->last(); +while ($p != IntlBreakIterator::DONE) { + $c = $codepoint_it->getLastCodePoint(); + if ($c > 0) + var_dump(sprintf('U+%04X', $codepoint_it->getLastCodePoint())); + else + var_dump($c); + $p = $codepoint_it->previous(); +} + + +?> +==DONE== +--EXPECT-- +int(-1) +int(-1) +string(6) "U+0E15" +string(6) "U+0E31" +string(6) "U+0E27" +string(6) "U+0E2D" +string(6) "U+0E22" +string(6) "U+0E48" +string(6) "U+0E32" +string(6) "U+0E07" +string(6) "U+0E02" +string(6) "U+0E49" +string(6) "U+0E2D" +string(6) "U+0E04" +string(6) "U+0E27" +string(6) "U+0E32" +string(6) "U+0E21" +Now backwards +int(-1) +string(6) "U+0E21" +string(6) "U+0E32" +string(6) "U+0E27" +string(6) "U+0E04" +string(6) "U+0E2D" +string(6) "U+0E49" +string(6) "U+0E02" +string(6) "U+0E07" +string(6) "U+0E32" +string(6) "U+0E48" +string(6) "U+0E22" +string(6) "U+0E2D" +string(6) "U+0E27" +string(6) "U+0E31" +string(6) "U+0E15" +==DONE== diff --git a/ext/intl/tests/cpbi_getLastCodePoint_error.phpt b/ext/intl/tests/cpbi_getLastCodePoint_error.phpt new file mode 100644 index 0000000000..78bd216629 --- /dev/null +++ b/ext/intl/tests/cpbi_getLastCodePoint_error.phpt @@ -0,0 +1,19 @@ +--TEST-- +IntlBreakIterator::getLastCodePoint(): bad args +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$it = IntlBreakIterator::createCodePointInstance(); +var_dump($it->getLastCodePoint(array())); +--EXPECTF-- + +Warning: IntlCodePointBreakIterator::getLastCodePoint() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlCodePointBreakIterator::getLastCodePoint(): cpbi_get_last_code_point: bad arguments in %s on line %d +bool(false) + diff --git a/ext/intl/tests/cpbi_parts_iterator.phpt b/ext/intl/tests/cpbi_parts_iterator.phpt new file mode 100644 index 0000000000..4754c12371 --- /dev/null +++ b/ext/intl/tests/cpbi_parts_iterator.phpt @@ -0,0 +1,40 @@ +--TEST-- +IntlCodepointBreakIterator's part iterator +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); + +$text = 'ตัวà¸à¸¢à¹ˆà¸²à¸‡à¸‚้à¸à¸„วาม'; + +$it = IntlBreakIterator::createCodePointInstance()->getPartsIterator(); +$it->getBreakIterator()->setText($text); + +foreach ($it as $k => $v) { + echo "$k. $v (" . sprintf("U+%04X", $it->getBreakIterator()->getLastCodePoint()) . + ") at {$it->getBreakIterator()->current()}\r\n"; +} + +?> +==DONE== +--EXPECT-- +0. ต (U+0E15) at 3 +1. ั (U+0E31) at 6 +2. ว (U+0E27) at 9 +3. ภ(U+0E2D) at 12 +4. ย (U+0E22) at 15 +5. ่ (U+0E48) at 18 +6. า (U+0E32) at 21 +7. ง (U+0E07) at 24 +8. ข (U+0E02) at 27 +9. ้ (U+0E49) at 30 +10. ภ(U+0E2D) at 33 +11. ค (U+0E04) at 36 +12. ว (U+0E27) at 39 +13. า (U+0E32) at 42 +14. ม (U+0E21) at 45 +==DONE== diff --git a/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt new file mode 100644 index 0000000000..cfd9338717 --- /dev/null +++ b/ext/intl/tests/dateformat___construct_bad_tz_cal.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlDateFormatter::__construct(): bad timezone or calendar +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); +ini_set("date.timezone", 'Atlantic/Azores'); + +var_dump(new IntlDateFormatter(NULL, 0, 0, 'bad timezone')); + +var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, 3)); + +var_dump(new IntlDateFormatter(NULL, 0, 0, NULL, new stdclass)); + + +?> +==DONE== +--EXPECTF-- + +Warning: IntlDateFormatter::__construct(): datefmt_create: no such time zone: 'bad timezone' in %s on line %d +NULL + +Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %s on line %d +NULL + +Warning: IntlDateFormatter::__construct(): datefmt_create: Invalid calendar argument; should be an integer or an IntlCalendar instance in %s on line %d +NULL +==DONE== diff --git a/ext/intl/tests/dateformat_calendars.phpt b/ext/intl/tests/dateformat_calendars.phpt index 27f380c718..6af02e51c1 100644 --- a/ext/intl/tests/dateformat_calendars.phpt +++ b/ext/intl/tests/dateformat_calendars.phpt @@ -41,5 +41,5 @@ string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12" string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12" string(42) "Sunday, Tevet 6, 5772 5:12:00 AM GMT+05:12" -Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN in %s on line %d +Warning: IntlDateFormatter::__construct(): datefmt_create: invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %s on line %d ==DONE== diff --git a/ext/intl/tests/dateformat_create_cal_arg.phpt b/ext/intl/tests/dateformat_create_cal_arg.phpt new file mode 100644 index 0000000000..53fb084af9 --- /dev/null +++ b/ext/intl/tests/dateformat_create_cal_arg.phpt @@ -0,0 +1,53 @@ +--TEST-- +IntlDateFormatter: several forms of the calendar arg +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--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 00:00:00 GMT +domingo%S 8 de Safar de 1433 00:00:00 GMT +domingo%S 1 de enero de 2012 01:00:00 Hora estĂ¡ndar de Europa Central +sĂ¡bado%S 31 de diciembre de 2011 d.C. 23:00:00 Hora %Sde las Azores +sĂ¡bado%S 7 de Safar de 1433 AH 23:00:00 Hora %Sde las Azores +domingo%S 8 de Safar de 1433 AH 00:00:00 GMT +domingo%S 1 de enero de 2012 00:00:00 GMT +==DONE== diff --git a/ext/intl/tests/dateformat_format.phpt b/ext/intl/tests/dateformat_format.phpt index e5548196d1..8664eea319 100644 --- a/ext/intl/tests/dateformat_format.phpt +++ b/ext/intl/tests/dateformat_format.phpt @@ -5,6 +5,8 @@ datefmt_format_code() --FILE-- <?php +//ini_set("intl.error_level", E_WARNING); + /* * Test for the datefmt_format function */ @@ -12,7 +14,7 @@ datefmt_format_code() function ut_main() { - $timezone = 'GMT-10'; + $timezone = 'GMT-10:00'; $locale_arr = array ( 'en_US' @@ -397,24 +399,24 @@ Formatted DateTime is : 20001230 05:04 PM Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: object must be an instance of DateTime: U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: object must be an instance of DateTime: U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: object must be an instance of DateTime: U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: object must be an instance of DateTime: U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------ Date is: stdClass::__set_state(array( )) ------------ -Error while formatting as: 'datefmt_format: object must be an instance of DateTime: U_ILLEGAL_ARGUMENT_ERROR' +Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted): U_ILLEGAL_ARGUMENT_ERROR' diff --git a/ext/intl/tests/dateformat_formatObject_calendar.phpt b/ext/intl/tests/dateformat_formatObject_calendar.phpt new file mode 100644 index 0000000000..0c61e4f2d0 --- /dev/null +++ b/ext/intl/tests/dateformat_formatObject_calendar.phpt @@ -0,0 +1,41 @@ +--TEST--
+IntlDateFormatter::formatObject(): IntlCalendar tests
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); +ini_set("date.timezone", "Europe/Lisbon"); + +$cal = IntlCalendar::fromDateTime('2012-01-01 00:00:00'); //Europe/Lisbon +echo IntlDateFormatter::formatObject($cal), "\n"; +echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n"; +echo IntlDateFormatter::formatObject($cal, null, "en-US"), "\n"; +echo IntlDateFormatter::formatObject($cal, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n"; +echo IntlDateFormatter::formatObject($cal, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n"; + +$cal = IntlCalendar::fromDateTime('2012-01-01 05:00:00+03:00'); +echo datefmt_format_object($cal, IntlDateFormatter::FULL), "\n"; + +$cal = IntlCalendar::createInstance(null,'en-US@calendar=islamic-civil'); +$cal->setTime(strtotime('2012-01-01 00:00:00')*1000.); +echo IntlDateFormatter::formatObject($cal), "\n"; +echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL, "en-US"), "\n"; + +?> +==DONE== +
+--EXPECTF--
+01/01/2012 00:00:00 +Domingo, 1 de Janeiro de 2012 0:00:00 Hora %Sda Europa Ocidental +Jan 1, 2012 12:00:00 AM +1/1/12 12:00:00 AM Western European %STime +Sun 2012-01-1 00,00,00.000 Portugal Time (Lisbon) +Domingo, 1 de Janeiro de 2012 5:00:00 GMT+03:00 +06/02/1433 00:00:00 +Sunday, Safar 6, 1433 12:00:00 AM Western European %STime +==DONE== +
diff --git a/ext/intl/tests/dateformat_formatObject_datetime.phpt b/ext/intl/tests/dateformat_formatObject_datetime.phpt new file mode 100644 index 0000000000..6427ad5a98 --- /dev/null +++ b/ext/intl/tests/dateformat_formatObject_datetime.phpt @@ -0,0 +1,34 @@ +--TEST--
+IntlDateFormatter::formatObject(): DateTime tests
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); +ini_set("date.timezone", "Europe/Lisbon"); + +$dt = new DateTime('2012-01-01 00:00:00'); //Europe/Lisbon +echo IntlDateFormatter::formatObject($dt), "\n"; +echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n"; +echo IntlDateFormatter::formatObject($dt, null, "en-US"), "\n"; +echo IntlDateFormatter::formatObject($dt, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n"; +echo IntlDateFormatter::formatObject($dt, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n"; + +$dt = new DateTime('2012-01-01 05:00:00+03:00'); +echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n"; + +?> +==DONE== +
+--EXPECTF--
+01/01/2012 00:00:00 +Domingo, 1 de Janeiro de 2012 0:00:00 Hora %Sda Europa Ocidental +Jan 1, 2012 12:00:00 AM +1/1/12 12:00:00 AM Western European %STime +Sun 2012-01-1 00,00,00.000 Portugal Time (Lisbon) +Domingo, 1 de Janeiro de 2012 5:00:00 GMT+03:00 +==DONE== +
diff --git a/ext/intl/tests/dateformat_formatObject_error.phpt b/ext/intl/tests/dateformat_formatObject_error.phpt new file mode 100644 index 0000000000..7aaf69e54e --- /dev/null +++ b/ext/intl/tests/dateformat_formatObject_error.phpt @@ -0,0 +1,74 @@ +--TEST--
+IntlDateFormatter::formatObject(): error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
+<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); +ini_set("date.timezone", "Europe/Lisbon"); + +var_dump(IntlDateFormatter::formatObject()); +var_dump(IntlDateFormatter::formatObject(1)); +var_dump(IntlDateFormatter::formatObject(new stdclass)); + +class A extends IntlCalendar {function __construct(){}} +var_dump(IntlDateFormatter::formatObject(new A)); +class B extends DateTime {function __construct(){}} +var_dump(IntlDateFormatter::formatObject(new B)); + +$cal = IntlCalendar::createInstance(); +var_dump(IntlDateFormatter::formatObject($cal, -2)); +var_dump(IntlDateFormatter::formatObject($cal, array())); +var_dump(IntlDateFormatter::formatObject($cal, array(1,2,3))); +var_dump(IntlDateFormatter::formatObject($cal, array(array(), 1))); +var_dump(IntlDateFormatter::formatObject($cal, array(1, -2))); +var_dump(IntlDateFormatter::formatObject($cal, "")); +var_dump(IntlDateFormatter::formatObject($cal, "YYYY", array())); + +?> +==DONE== +
+--EXPECTF--
+ +Warning: IntlDateFormatter::formatObject() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject() expects parameter 1 to be object, integer given in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the passed object must be an instance of either IntlCalendar or DateTime in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad IntlCalendar instance: not initialized properly in %s on line %d +bool(false) + +Warning: DateTime::getTimestamp(): The DateTime object has not been correctly initialized by its constructor in %s on line %d + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: error calling ::getTimeStamp() on the object in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the date/time format type is invalid in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; if array, it must have two elements in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; if array, it must have two elements in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; the date format (first element of the array) is not valid in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad format; the time format (second element of the array) is not valid in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the format is empty in %s on line %d +bool(false) + +Warning: IntlDateFormatter::formatObject() expects parameter 3 to be string, array given in %s on line %d +bool(false) +==DONE== +
diff --git a/ext/intl/tests/dateformat_format_parse.phpt b/ext/intl/tests/dateformat_format_parse.phpt index bd41d715b9..6bd3d8a8ff 100644 --- a/ext/intl/tests/dateformat_format_parse.phpt +++ b/ext/intl/tests/dateformat_format_parse.phpt @@ -12,7 +12,7 @@ datefmt_format_code() and datefmt_parse_code() function ut_main() { - $timezone = 'GMT+5'; + $timezone = 'GMT+05:00'; $locale_arr = array ( 'en_US' diff --git a/ext/intl/tests/dateformat_getCalendarObject_error.phpt b/ext/intl/tests/dateformat_getCalendarObject_error.phpt new file mode 100644 index 0000000000..d2ad66c829 --- /dev/null +++ b/ext/intl/tests/dateformat_getCalendarObject_error.phpt @@ -0,0 +1,43 @@ +--TEST-- +IntlDateFormatter::getCalendarObject(): bad args +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); +ini_set("date.timezone", 'Atlantic/Azores'); + +$df = new IntlDateFormatter(NULL, 0, 0); + +var_dump($df->getCalendarObject(9)); +var_dump(datefmt_get_calendar_object($df, 9)); +var_dump(datefmt_get_calendar_object($df, 9)); +var_dump(datefmt_get_calendar_object(new stdclass)); + +?> +==DONE== +--EXPECTF-- + +Warning: IntlDateFormatter::getCalendarObject() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlDateFormatter::getCalendarObject(): datefmt_get_calendar_object: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_calendar_object() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: datefmt_get_calendar_object(): datefmt_get_calendar_object: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_calendar_object() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: datefmt_get_calendar_object(): datefmt_get_calendar_object: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_calendar_object() expects parameter 1 to be IntlDateFormatter, object given in %s on line %d + +Warning: datefmt_get_calendar_object(): datefmt_get_calendar_object: unable to parse input params in %s on line %d +bool(false) +==DONE== diff --git a/ext/intl/tests/dateformat_getTimeZone_error.phpt b/ext/intl/tests/dateformat_getTimeZone_error.phpt new file mode 100644 index 0000000000..4ac5555d88 --- /dev/null +++ b/ext/intl/tests/dateformat_getTimeZone_error.phpt @@ -0,0 +1,43 @@ +--TEST-- +IntlDateFormatter::getTimeZone(): bad args +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); +ini_set("date.timezone", 'Atlantic/Azores'); + +$df = new IntlDateFormatter(NULL, 0, 0); + +var_dump($df->getTimeZone(9)); +var_dump(datefmt_get_timezone($df, 9)); +var_dump(datefmt_get_timezone($df, 9)); +var_dump(datefmt_get_timezone(new stdclass)); + +?> +==DONE== +--EXPECTF-- + +Warning: IntlDateFormatter::getTimeZone() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlDateFormatter::getTimeZone(): datefmt_get_timezone: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_timezone() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: datefmt_get_timezone(): datefmt_get_timezone: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_timezone() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: datefmt_get_timezone(): datefmt_get_timezone: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_get_timezone() expects parameter 1 to be IntlDateFormatter, object given in %s on line %d + +Warning: datefmt_get_timezone(): datefmt_get_timezone: unable to parse input params in %s on line %d +bool(false) +==DONE== diff --git a/ext/intl/tests/dateformat_get_set_calendar.phpt b/ext/intl/tests/dateformat_get_set_calendar.phpt index bfd4e578e1..dbb3e6cd23 100644 --- a/ext/intl/tests/dateformat_get_set_calendar.phpt +++ b/ext/intl/tests/dateformat_get_set_calendar.phpt @@ -1,60 +1,55 @@ --TEST-- -datefmt_get_calendar_code() datefmt_set_calendar_code() +IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject() --SKIPIF-- -<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); --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"; +} -/* - * Test for the datefmt_get_calendar and datefmt_set_calendar functions - */ - - -function ut_main() -{ - $calendar_arr = array ( - IntlDateFormatter::GREGORIAN, - IntlDateFormatter::TRADITIONAL, - 3 - ); - - $res_str = ''; - - $start_calendar = IntlDateFormatter::GREGORIAN; - $res_str .= "\nCreating IntlDateFormatter with calendar = $start_calendar"; - $fmt = ut_datefmt_create( "de-DE", IntlDateFormatter::SHORT, IntlDateFormatter::SHORT ,'America/Los_Angeles', IntlDateFormatter::GREGORIAN); - $calendar = ut_datefmt_get_calendar( $fmt); - $res_str .= "\nAfter call to get_calendar : calendar= $calendar"; - $res_str .= "\n-------------------"; - - foreach( $calendar_arr as $calendar_entry ) - { - $res_str .= "\nSetting IntlDateFormatter with calendar = $calendar_entry"; - ut_datefmt_set_calendar( $fmt, $calendar_entry); - $calendar = ut_datefmt_get_calendar( $fmt); - $res_str .= "\nAfter call to get_calendar : calendar= $calendar"; - $res_str .= "\n-------------------"; - } - - return $res_str; +$df = new IntlDateFormatter('fr@calendar=islamic', 0, 0, 'Europe/Minsk'); +d($df); -} -include_once( 'ut_common.inc' ); +//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); -// Run the test -ut_run(); ?> +==DONE== --EXPECT-- -Creating IntlDateFormatter with calendar = 1 -After call to get_calendar : calendar= 1 -------------------- -Setting IntlDateFormatter with calendar = 1 -After call to get_calendar : calendar= 1 -------------------- -Setting IntlDateFormatter with calendar = 0 -After call to get_calendar : calendar= 0 -------------------- -Setting IntlDateFormatter with calendar = 3 -After call to get_calendar : calendar= 0 --------------------
\ No newline at end of file +dimanche 1 janvier 2012 ap. J.-C. 03:00:00 UTC+03:00 +int(1) +string(9) "gregorian" +string(12) "Europe/Minsk" + +dimanche 8 Safar 1433 AH 03:00:00 UTC+03:00 +int(0) +string(7) "islamic" +string(12) "Europe/Minsk" + +dimanche 1 janvier 2012 ap. J.-C. 00:00:00 UTC +bool(false) +string(9) "gregorian" +string(3) "UTC" + +==DONE== diff --git a/ext/intl/tests/dateformat_get_set_timezone.phpt b/ext/intl/tests/dateformat_get_set_timezone.phpt new file mode 100644 index 0000000000..41aa35b9cf --- /dev/null +++ b/ext/intl/tests/dateformat_get_set_timezone.phpt @@ -0,0 +1,62 @@ +--TEST-- +IntlDateFormatter: get/setTimeZone() +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--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->getTimeZoneID(), +$df->getTimeZone()->getID()); +echo "\n"; +} + +$df = new IntlDateFormatter('pt_PT', 0, 0, 'Europe/Minsk'); +d($df); + +$df->setTimeZone(NULL); +d($df); + +$df->setTimeZone('Europe/Madrid'); +d($df); + +$df->setTimeZone(IntlTimeZone::createTimeZone('Europe/Paris')); +d($df); + +$df->setTimeZone(new DateTimeZone('Europe/Amsterdam')); +d($df); + +?> +==DONE== +--EXPECTF-- +Domingo, 1 de Janeiro de 2012 3:00:00 GMT+03:00 +string(12) "Europe/Minsk" +string(12) "Europe/Minsk" + +SĂ¡bado, 31 de Dezembro de 2011 23:00:00 Hor%s %Sdos Açores +string(15) "Atlantic/Azores" +string(15) "Atlantic/Azores" + +Domingo, 1 de Janeiro de 2012 1:00:00 Hor%s %Sda Europa Central +string(13) "Europe/Madrid" +string(13) "Europe/Madrid" + +Domingo, 1 de Janeiro de 2012 1:00:00 Hor%s %Sda Europa Central +string(12) "Europe/Paris" +string(12) "Europe/Paris" + +Domingo, 1 de Janeiro de 2012 1:00:00 Hor%s %Sda Europa Central +string(16) "Europe/Amsterdam" +string(16) "Europe/Amsterdam" + +==DONE== diff --git a/ext/intl/tests/dateformat_get_timezone_id.phpt b/ext/intl/tests/dateformat_get_timezone_id.phpt index 80cbdbbf0f..a9701c3868 100644 --- a/ext/intl/tests/dateformat_get_timezone_id.phpt +++ b/ext/intl/tests/dateformat_get_timezone_id.phpt @@ -1,5 +1,8 @@ --TEST-- datefmt_get_timezone_id_code() +--INI-- +date.timezone=Atlantic/Azores +intl.error_level=E_WARNING --SKIPIF-- <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> --FILE-- @@ -14,8 +17,8 @@ function ut_main() { $timezone_id_arr = array ( 'America/New_York', - 'America/Los_Angeles', - 'America/Dallas' + 'US/Pacific', + 'US/Central' ); $res_str = ''; @@ -42,8 +45,8 @@ ut_run(); Creating IntlDateFormatter with timezone_id = America/New_York After call to get_timezone_id : timezone_id= America/New_York -Creating IntlDateFormatter with timezone_id = America/Los_Angeles -After call to get_timezone_id : timezone_id= America/Los_Angeles +Creating IntlDateFormatter with timezone_id = US/Pacific +After call to get_timezone_id : timezone_id= US/Pacific -Creating IntlDateFormatter with timezone_id = America/Dallas -After call to get_timezone_id : timezone_id= America/Dallas +Creating IntlDateFormatter with timezone_id = US/Central +After call to get_timezone_id : timezone_id= US/Central diff --git a/ext/intl/tests/dateformat_setTimeZoneID_deprecation.phpt b/ext/intl/tests/dateformat_setTimeZoneID_deprecation.phpt new file mode 100644 index 0000000000..5ee5b94d24 --- /dev/null +++ b/ext/intl/tests/dateformat_setTimeZoneID_deprecation.phpt @@ -0,0 +1,22 @@ +--TEST-- +IntlDateFormatter: setTimeZoneID() deprecation +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); +ini_set("date.timezone", 'Atlantic/Azores'); + +$df = new IntlDateFormatter('pt_PT', 0, 0, 'Europe/Minsk'); + +$df->setTimeZoneId('Europe/Madrid'); + +?> +==DONE== +--EXPECTF-- + +Deprecated: IntlDateFormatter::setTimeZoneId(): Use datefmt_set_timezone() instead, which also accepts a plain time zone identifier and for which this function is now an alias in %s on line %d +==DONE== diff --git a/ext/intl/tests/dateformat_setTimeZone_error.phpt b/ext/intl/tests/dateformat_setTimeZone_error.phpt new file mode 100644 index 0000000000..bd37031325 --- /dev/null +++ b/ext/intl/tests/dateformat_setTimeZone_error.phpt @@ -0,0 +1,53 @@ +--TEST-- +IntlDateFormatter::setTimeZone() bad args +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); +ini_set("date.timezone", 'Atlantic/Azores'); + +$df = new IntlDateFormatter(NULL, 0, 0); + +var_dump($df->setTimeZone()); +var_dump(datefmt_set_timezone()); +var_dump($df->setTimeZone(array())); +var_dump($df->setTimeZone(1, 2)); +var_dump($df->setTimeZone('non existing timezone')); +var_dump(datefmt_set_timezone(new stdclass, 'UTC')); + +?> +==DONE== +--EXPECTF-- + +Warning: IntlDateFormatter::setTimeZone() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: unable to parse input params in %s on line %d +bool(false) + +Warning: datefmt_set_timezone() expects exactly 2 parameters, 0 given in %s on line %d + +Warning: datefmt_set_timezone(): datefmt_set_timezone: unable to parse input params in %s on line %d +bool(false) + +Notice: Array to string conversion in %s on line %d + +Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: no such time zone: 'Array' in %s on line %d +bool(false) + +Warning: IntlDateFormatter::setTimeZone() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: unable to parse input params in %s on line %d +bool(false) + +Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: no such time zone: 'non existing timezone' in %s on line %d +bool(false) + +Warning: datefmt_set_timezone() expects parameter 1 to be IntlDateFormatter, object given in %s on line %d + +Warning: datefmt_set_timezone(): datefmt_set_timezone: unable to parse input params in %s on line %d +bool(false) +==DONE== diff --git a/ext/intl/tests/dateformat_set_timezone_id2.phpt b/ext/intl/tests/dateformat_set_timezone_id2.phpt index 23aacda90a..ce9b89d1fd 100644 --- a/ext/intl/tests/dateformat_set_timezone_id2.phpt +++ b/ext/intl/tests/dateformat_set_timezone_id2.phpt @@ -1,11 +1,16 @@ --TEST-- datefmt_set_timezone_id_code() icu >= 4.8 +--INI-- +date.timezone=Atlantic/Azores --SKIPIF-- <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> <?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip'; ?> --FILE-- <?php +ini_set("intl.error_level", E_WARNING); +ini_set("error_reporting", ~E_DEPRECATED); + /* * Test for the datefmt_set_timezone_id function */ @@ -23,7 +28,7 @@ function ut_main() $res_str = ''; - $fmt = ut_datefmt_create( "en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/San_Francisco' , IntlDateFormatter::GREGORIAN ); + $fmt = ut_datefmt_create( "en_US", IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'US/Pacific' , IntlDateFormatter::GREGORIAN ); $timezone_id = ut_datefmt_get_timezone_id( $fmt ); $res_str .= "\nAfter creation of the dateformatter : timezone_id= $timezone_id\n"; @@ -52,8 +57,13 @@ include_once( 'ut_common.inc' ); // Run the test ut_run(); ?> ---EXPECT-- -After creation of the dateformatter : timezone_id= America/San_Francisco +--EXPECTF-- + +Warning: IntlDateFormatter::setTimeZoneId(): datefmt_set_timezone: no such time zone: 'CN' in %s on line %d + +Warning: datefmt_set_timezone_id(): datefmt_set_timezone: no such time zone: 'CN' in %s on line %d + +After creation of the dateformatter : timezone_id= US/Pacific ----------- Trying to set timezone_id= America/New_York After call to set_timezone_id : timezone_id= America/New_York @@ -71,6 +81,6 @@ Formatting timestamp=0 resulted in Wednesday, December 31, 1969 6:00:00 PM Cent Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM Central Standard Time ----------- Trying to set timezone_id= CN -After call to set_timezone_id : timezone_id= CN -Formatting timestamp=0 resulted in Thursday, January 1, 1970 12:00:00 AM GMT -Formatting timestamp=3600 resulted in Thursday, January 1, 1970 1:00:00 AM GMT +After call to set_timezone_id : timezone_id= America/Chicago +Formatting timestamp=0 resulted in Wednesday, December 31, 1969 6:00:00 PM Central Standard Time +Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM Central Standard Time diff --git a/ext/intl/tests/dateformat_timezone_arg_variations.phpt b/ext/intl/tests/dateformat_timezone_arg_variations.phpt new file mode 100644 index 0000000000..ccfb5e1964 --- /dev/null +++ b/ext/intl/tests/dateformat_timezone_arg_variations.phpt @@ -0,0 +1,45 @@ +--TEST-- +IntlDateFormatter: several forms of the timezone arg +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("date.timezone", 'Atlantic/Azores'); + +$ts = strtotime('2012-01-01 00:00:00 UTC'); + +//should use Atlantic/Azores +$df = new IntlDateFormatter('es_ES', 0, 0, NULL); +echo $df->format($ts), "\n"; + +$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam'); +echo $df->format($ts), "\n"; + +$df = new IntlDateFormatter('es_ES', 0, 0, new DateTimeZone('Europe/Lisbon')); +echo $df->format($ts), "\n"; + +$df = new IntlDateFormatter('es_ES', 0, 0, IntlTimeZone::createTimeZone('America/New_York')); +echo $df->format($ts), "\n"; + +//time zone has priority +$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', new IntlGregorianCalendar('Europe/Lisbon')); +echo $df->format($ts), "\n"; + +//calendar has priority +$df = new IntlDateFormatter('es_ES', 0, 0, NULL, new IntlGregorianCalendar('Europe/Lisbon')); +echo $df->format($ts), "\n"; + +$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', 0); +echo $df->format($ts), "\n"; + +--EXPECTF-- +sĂ¡bado%S 31 de diciembre de 2011 23:00:00 Hora%S de las Azores +domingo%S 1 de enero de 2012 01:00:00 Hora estĂ¡ndar de Europa Central +domingo%S 1 de enero de 2012 00:00:00 Hora%S de Europa Occidental +sĂ¡bado%S 31 de diciembre de 2011 19:00:00 Hora estĂ¡ndar oriental +domingo%S 1 de enero de 2012 01:00:00 Hora estĂ¡ndar de Europa Central +domingo%S 1 de enero de 2012 00:00:00 Hora%S de Europa Occidental +domingo%S 1 de enero de 2012 01:00:00 Hora estĂ¡ndar de Europa Central diff --git a/ext/intl/tests/gregoriancalendar___construct_basic.phpt b/ext/intl/tests/gregoriancalendar___construct_basic.phpt new file mode 100644 index 0000000000..bdbef6725b --- /dev/null +++ b/ext/intl/tests/gregoriancalendar___construct_basic.phpt @@ -0,0 +1,51 @@ +--TEST-- +IntlGregorianCalendar::__construct(): basic +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +date_default_timezone_set('Europe/Amsterdam'); + +$intlcal = intlgregcal_create_instance(); +var_dump($intlcal->getTimeZone()->getId()); +var_dump($intlcal->getLocale(1)); + +$intlcal = new IntlGregorianCalendar('Europe/Lisbon', NULL); +var_dump($intlcal->getTimeZone()->getId()); +var_dump($intlcal->getLocale(1)); + +$intlcal = new IntlGregorianCalendar(NULL, 'pt_PT'); +var_dump($intlcal->getTimeZone()->getId()); +var_dump($intlcal->getLocale(1)); + +$intlcal = new IntlGregorianCalendar('Europe/Lisbon', 'pt_PT'); +var_dump($intlcal->getTimeZone()->getId()); +var_dump($intlcal->getLocale(1)); + +$intlcal = new IntlGregorianCalendar('Europe/Paris', 'fr_CA', NULL, NULL, NULL, NULL); +var_dump($intlcal->getTimeZone()->getId()); +var_dump($intlcal->getLocale(1)); + +var_dump($intlcal->getType()); +?> +==DONE== +--EXPECT-- +string(16) "Europe/Amsterdam" +string(5) "nl_NL" +string(13) "Europe/Lisbon" +string(5) "nl_NL" +string(16) "Europe/Amsterdam" +string(5) "pt_PT" +string(13) "Europe/Lisbon" +string(5) "pt_PT" +string(12) "Europe/Paris" +string(5) "fr_CA" +string(9) "gregorian" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/gregoriancalendar___construct_error.phpt b/ext/intl/tests/gregoriancalendar___construct_error.phpt new file mode 100644 index 0000000000..0e85394a48 --- /dev/null +++ b/ext/intl/tests/gregoriancalendar___construct_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +IntlGregorianCalendar::__construct(): bad arguments +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(intlgregcal_create_instance(1,2,3,4,5,6,7)); +var_dump(intlgregcal_create_instance(1,2,3,4,5,6,7,8)); +var_dump(intlgregcal_create_instance(1,2,3,4)); +var_dump(new IntlGregorianCalendar(1,2,NULL,4)); +var_dump(new IntlGregorianCalendar(1,2,3,4,NULL,array())); + + +--EXPECTF-- + +Warning: intlgregcal_create_instance(): intlgregcal_create_instance: too many arguments in %s on line %d +NULL + +Warning: intlgregcal_create_instance(): intlgregcal_create_instance: too many arguments in %s on line %d +NULL + +Warning: intlgregcal_create_instance(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs) in %s on line %d +NULL + +Warning: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: no variant with 4 arguments (excluding trailing NULLs) in %s on line %d +NULL + +Warning: IntlGregorianCalendar::__construct() expects parameter 6 to be long, array given in %s on line %d + +Warning: IntlGregorianCalendar::__construct(): intlgregcal_create_instance: bad arguments in %s on line %d +NULL diff --git a/ext/intl/tests/gregoriancalendar___construct_variant1.phpt b/ext/intl/tests/gregoriancalendar___construct_variant1.phpt new file mode 100644 index 0000000000..63266b792e --- /dev/null +++ b/ext/intl/tests/gregoriancalendar___construct_variant1.phpt @@ -0,0 +1,30 @@ +--TEST-- +IntlGregorianCalendar::__construct(): argument variants +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +date_default_timezone_set('Europe/Amsterdam'); + +$intlcal = intlgregcal_create_instance(2012, 1, 29, 16, 0, NULL); +var_dump($intlcal->getTimeZone()->getId()); +var_dump($intlcal->getTime(), (float)strtotime('2012-02-29 16:00:00') * 1000); + +$intlcal = new IntlGregorianCalendar(2012, 1, 29, 16, 7, 8); +var_dump($intlcal->getTime(), (float)strtotime('2012-02-29 16:07:08') * 1000); + +var_dump($intlcal->getType()); +?> +==DONE== +--EXPECT-- +string(16) "Europe/Amsterdam" +float(1330527600000) +float(1330527600000) +float(1330528028000) +float(1330528028000) +string(9) "gregorian" +==DONE== diff --git a/ext/intl/tests/gregoriancalendar_getGregorianChange_error.phpt b/ext/intl/tests/gregoriancalendar_getGregorianChange_error.phpt new file mode 100644 index 0000000000..58d566223b --- /dev/null +++ b/ext/intl/tests/gregoriancalendar_getGregorianChange_error.phpt @@ -0,0 +1,30 @@ +--TEST-- +IntlGregorianCalendar::getGregorianChange(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); +var_dump($c->getGregorianChange(1)); + +var_dump(intlgregcal_get_gregorian_change($c, 1)); +var_dump(intlgregcal_get_gregorian_change(1)); +--EXPECTF-- + +Warning: IntlGregorianCalendar::getGregorianChange() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlGregorianCalendar::getGregorianChange(): intlgregcal_get_gregorian_change: bad arguments in %s on line %d +bool(false) + +Warning: intlgregcal_get_gregorian_change() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: intlgregcal_get_gregorian_change(): intlgregcal_get_gregorian_change: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlgregcal_get_gregorian_change() must be an instance of IntlGregorianCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/gregoriancalendar_get_setGregorianChange_basic.phpt b/ext/intl/tests/gregoriancalendar_get_setGregorianChange_basic.phpt new file mode 100644 index 0000000000..b08ad7981f --- /dev/null +++ b/ext/intl/tests/gregoriancalendar_get_setGregorianChange_basic.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlGregorianCalendar::get/setGregorianChange(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +date_default_timezone_set('Europe/Amsterdam'); + +$intlcal = new IntlGregorianCalendar(); + +var_dump($intlcal->getGregorianChange()); + +var_dump($intlcal->setGregorianChange(0)); +var_dump(intlgregcal_get_gregorian_change($intlcal)); + +var_dump(intlgregcal_set_gregorian_change($intlcal, 1)); +var_dump($intlcal->getGregorianChange()); + +?> +==DONE== +--EXPECT-- +float(-12219292800000) +bool(true) +float(0) +bool(true) +float(1) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/gregoriancalendar_isLeapYear_basic.phpt b/ext/intl/tests/gregoriancalendar_isLeapYear_basic.phpt new file mode 100644 index 0000000000..b37452fcba --- /dev/null +++ b/ext/intl/tests/gregoriancalendar_isLeapYear_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +IntlGregorianCalendar::isLeapYear(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +date_default_timezone_set('Europe/Amsterdam'); + +$intlcal = new IntlGregorianCalendar(); + +var_dump($intlcal->isLeapYear(2012)); +var_dump($intlcal->isLeapYear(1900)); + +var_dump(intlgregcal_is_leap_year($intlcal, 2012)); +var_dump(intlgregcal_is_leap_year($intlcal, 1900)); +?> +==DONE== +--EXPECT-- +bool(true) +bool(false) +bool(true) +bool(false) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/gregoriancalendar_isLeapYear_error.phpt b/ext/intl/tests/gregoriancalendar_isLeapYear_error.phpt new file mode 100644 index 0000000000..40a6c85396 --- /dev/null +++ b/ext/intl/tests/gregoriancalendar_isLeapYear_error.phpt @@ -0,0 +1,48 @@ +--TEST-- +IntlGregorianCalendar::isLeapYear(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); +var_dump($c->isLeapYear(2000, 2011)); +var_dump($c->isLeapYear()); +var_dump($c->isLeapYear("fgdf")); + +var_dump(intlgregcal_is_leap_year($c, 1, 2)); +var_dump(intlgregcal_is_leap_year($c)); +var_dump(intlgregcal_is_leap_year(1, 2)); +--EXPECTF-- + +Warning: IntlGregorianCalendar::isLeapYear() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlGregorianCalendar::isLeapYear(): intlgregcal_is_leap_year: bad arguments in %s on line %d +bool(false) + +Warning: IntlGregorianCalendar::isLeapYear() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlGregorianCalendar::isLeapYear(): intlgregcal_is_leap_year: bad arguments in %s on line %d +bool(false) + +Warning: IntlGregorianCalendar::isLeapYear() expects parameter 1 to be long, string given in %s on line %d + +Warning: IntlGregorianCalendar::isLeapYear(): intlgregcal_is_leap_year: bad arguments in %s on line %d +bool(false) + +Warning: intlgregcal_is_leap_year() expects exactly 2 parameters, 3 given in %s on line %d + +Warning: intlgregcal_is_leap_year(): intlgregcal_is_leap_year: bad arguments in %s on line %d +bool(false) + +Warning: intlgregcal_is_leap_year() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: intlgregcal_is_leap_year(): intlgregcal_is_leap_year: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlgregcal_is_leap_year() must be an instance of IntlGregorianCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/gregoriancalendar_setGregorianChange_error.phpt b/ext/intl/tests/gregoriancalendar_setGregorianChange_error.phpt new file mode 100644 index 0000000000..eac8deb61b --- /dev/null +++ b/ext/intl/tests/gregoriancalendar_setGregorianChange_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +IntlGregorianCalendar::setGregorianChange(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(); +var_dump($c->setGregorianChange()); +var_dump($c->setGregorianChange(1, 2)); +var_dump($c->setGregorianChange("sdfds")); + +var_dump(intlgregcal_set_gregorian_change($c)); +var_dump(intlgregcal_set_gregorian_change(1, 4.)); +--EXPECTF-- + +Warning: IntlGregorianCalendar::setGregorianChange() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlGregorianCalendar::setGregorianChange(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d +bool(false) + +Warning: IntlGregorianCalendar::setGregorianChange() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlGregorianCalendar::setGregorianChange(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d +bool(false) + +Warning: IntlGregorianCalendar::setGregorianChange() expects parameter 1 to be double, string given in %s on line %d + +Warning: IntlGregorianCalendar::setGregorianChange(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d +bool(false) + +Warning: intlgregcal_set_gregorian_change() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: intlgregcal_set_gregorian_change(): intlgregcal_set_gregorian_change: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intlgregcal_set_gregorian_change() must be an instance of IntlGregorianCalendar, integer given in %s on line %d diff --git a/ext/intl/tests/ini_use_exceptions_basic.phpt b/ext/intl/tests/ini_use_exceptions_basic.phpt new file mode 100644 index 0000000000..36ccbcb8a0 --- /dev/null +++ b/ext/intl/tests/ini_use_exceptions_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +intl.use_exceptions INI setting +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php +ini_set("intl.use_exceptions", true); +$t = transliterator_create('any-hex'); +try { + var_dump($t->transliterate('a', 3)); +} catch (IntlException $intlE) { + var_dump($intlE->getMessage()); +} +ini_set("intl.use_exceptions", false); +ini_set("intl.error_level", E_NOTICE); +var_dump($t->transliterate('a', 3)); +--EXPECTF-- +string(130) "transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1)" + +Notice: Transliterator::transliterate(): transliterator_transliterate: Neither "start" nor the "end" arguments can exceed the number of UTF-16 code units (in this case, 1) in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_datetime.phpt b/ext/intl/tests/msgfmt_format_datetime.phpt new file mode 100644 index 0000000000..07e7d68f14 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_datetime.phpt @@ -0,0 +1,28 @@ +--TEST-- +MessageFormatter::format(): DateTime accepted to format dates and times +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +//ini_set("intl.default_locale", "nl"); + +$fmt = <<<EOD +{0,date} {0,time} +EOD; + +$dt = new DateTime("2012-05-06 18:00:42", new DateTimeZone("Europe/Lisbon")); + +$mf = new MessageFormatter('en_US', $fmt); + +var_dump($mf->format(array($dt))); + +?> +==DONE== +--EXPECTF-- +string(%s) "May %d, 2012 %d:%d:42 %s" +==DONE== diff --git a/ext/intl/tests/msgfmt_format_error1.phpt b/ext/intl/tests/msgfmt_format_error1.phpt new file mode 100644 index 0000000000..684b05970a --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error1.phpt @@ -0,0 +1,19 @@ +--TEST-- +MessageFormatter::format() insufficient numeric arguments +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$fmt = <<<EOD +{0} {1} +EOD; + +$mf = new MessageFormatter('en_US', $fmt); +var_dump($mf->format(array(7))); + +--EXPECTF-- +string(5) "7 {1}" diff --git a/ext/intl/tests/msgfmt_format_error2.phpt b/ext/intl/tests/msgfmt_format_error2.phpt new file mode 100644 index 0000000000..85d1b1c83d --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error2.phpt @@ -0,0 +1,23 @@ +--TEST-- +MessageFormatter::format() inconsistent types in named argument +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$fmt = <<<EOD +{foo,number} {foo} +EOD; + +$mf = new MessageFormatter('en_US', $fmt); +var_dump($mf->format(array(7))); + +--EXPECTF-- + +Warning: MessageFormatter::format(): Inconsistent types declared for an argument in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_error3.phpt b/ext/intl/tests/msgfmt_format_error3.phpt new file mode 100644 index 0000000000..6dfbee3c90 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error3.phpt @@ -0,0 +1,23 @@ +--TEST-- +MessageFormatter::format() given negative arg key +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$fmt = <<<EOD +{foo,number,percent} +EOD; + +$mf = new MessageFormatter('en_US', $fmt); +var_dump($mf->format(array("foo" => 7, -1 => "bar"))); + +--EXPECTF-- + +Warning: MessageFormatter::format(): Found negative or too large array key in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_error4.phpt b/ext/intl/tests/msgfmt_format_error4.phpt new file mode 100644 index 0000000000..3b92b48b8b --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error4.phpt @@ -0,0 +1,28 @@ +--TEST-- +MessageFormatter::format() invalid UTF-8 for arg key or value +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$fmt = <<<EOD +{foo} +EOD; + +$mf = new MessageFormatter('en_US', $fmt); +var_dump($mf->format(array("foo" => 7, "\x80" => "bar"))); + +var_dump($mf->format(array("foo" => "\x80"))); + +--EXPECTF-- + +Warning: MessageFormatter::format(): Invalid UTF-8 data in argument key: '€' in %s on line %d +bool(false) + +Warning: MessageFormatter::format(): Invalid UTF-8 data in string argument: '€' in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_error5.phpt b/ext/intl/tests/msgfmt_format_error5.phpt new file mode 100644 index 0000000000..ebbd4550e8 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error5.phpt @@ -0,0 +1,26 @@ +--TEST-- +MessageFormatter::format() invalid date/time argument +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$fmt = <<<EOD +{foo,date} +EOD; + +$mf = new MessageFormatter('en_US', $fmt); +var_dump($mf->format(array("foo" => new stdclass()))); + +--EXPECTF-- +Warning: MessageFormatter::format(): msgfmt_format: invalid object type for date/time (only IntlCalendar and DateTime permitted) in %s on line %d + +Warning: MessageFormatter::format(): The argument for key 'foo' cannot be used as a date or time in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_error6.phpt b/ext/intl/tests/msgfmt_format_error6.phpt new file mode 100644 index 0000000000..b07d2ab774 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_error6.phpt @@ -0,0 +1,23 @@ +--TEST-- +MessageFormatter::format() invalid type for key not in pattern +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$fmt = <<<EOD +{foo} +EOD; + +$mf = new MessageFormatter('en_US', $fmt); +var_dump($mf->format(array("foo" => 'bar', 7 => fopen('php://memory', 'r+')))); + +--EXPECTF-- + +Warning: MessageFormatter::format(): No strategy to convert the value given for the argument with key '7' is available in %s on line %d +bool(false) diff --git a/ext/intl/tests/msgfmt_format_intlcalendar.phpt b/ext/intl/tests/msgfmt_format_intlcalendar.phpt new file mode 100644 index 0000000000..6ae78a9140 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_intlcalendar.phpt @@ -0,0 +1,30 @@ +--TEST-- +MessageFormat accepts IntlCalendar args +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +//ini_set("intl.default_locale", "nl"); +ini_set('date.timezone', 'Europe/Lisbon'); + +$cal = new IntlGregorianCalendar(2012,04,17,17,35,36); + +$msgf = new MessageFormatter('pt_PT', '{0,date,full} {0,time,h:m:s a V}'); +echo $msgf->format(array($cal)), "\n"; + +//NOT FIXED: +/*$msgf = new MessageFormatter('en_US', +'{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}'); + +echo "msgf2: ", $msgf->format(array($time, 'date')), " ", + $msgf->format(array($time, 'time')), "\n"; +*/ + +?> +==DONE== +--EXPECT-- +Quinta-feira, 17 de Maio de 2012 5:35:36 p.m. WEST +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/msgfmt_format_mixed_params.phpt b/ext/intl/tests/msgfmt_format_mixed_params.phpt new file mode 100644 index 0000000000..93412f49e2 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_mixed_params.phpt @@ -0,0 +1,25 @@ +--TEST-- +MessageFormatter::format(): mixed named and numeric parameters +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +//ini_set("intl.default_locale", "nl"); + +$mf = new MessageFormatter('en_US', + "{0,number} -- {foo,ordinal}"); + +var_dump($mf->format(array(2.3, "foo" => 1.3))); +var_dump($mf->format(array("foo" => 1.3, 0 => 2.3))); + +?> +==DONE== +--EXPECT-- +string(10) "2.3 -- 1st" +string(10) "2.3 -- 1st" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/msgfmt_format_simple_types_numeric_strings.phpt b/ext/intl/tests/msgfmt_format_simple_types_numeric_strings.phpt new file mode 100644 index 0000000000..299ae483a4 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_simple_types_numeric_strings.phpt @@ -0,0 +1,58 @@ +--TEST-- +MessageFormatter::format(): simple types handling with numeric strings +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +//ini_set("intl.default_locale", "nl"); + +$mf = new MessageFormatter('en_US'," + none {a} + number {b,number} + number integer {c,number,integer} + number currency {d,number,currency} + number percent {e,number,percent} + date {f,date} + time {g,time} + spellout {h,spellout} + ordinal {i,ordinal} + duration {j,duration} + "); + +$ex = "1336317965.5 str"; +var_dump($mf->format(array( +'a' => $ex, +'b' => $ex, +'c' => $ex, +'d' => $ex, +'e' => $ex, +'f' => " 1336317965.5", +'g' => " 1336317965.5", +'h' => $ex, +'i' => $ex, +'j' => $ex, +))); + +?> +==DONE== +--EXPECTF-- +string(%d) " + none 1336317965.5 str + number 1,336,317,965.5 + number integer 1,336,317,965 + number currency $1,336,317,965.50 + number percent 133,631,796,550% + date May %d, 2012 + time %d:%d:05 PM + spellout one billion three hundred thirty-six million three hundred seventeen thousand nine hundred sixty-five point five + ordinal 1,336,317,966th + duration 371,199:26:06 + " +==DONE== diff --git a/ext/intl/tests/msgfmt_format_subpatterns.phpt b/ext/intl/tests/msgfmt_format_subpatterns.phpt new file mode 100644 index 0000000000..9f11e3e255 --- /dev/null +++ b/ext/intl/tests/msgfmt_format_subpatterns.phpt @@ -0,0 +1,75 @@ +--TEST-- +msgfmt_format() with subpatterns +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php + +/* + * Format a number using misc locales/patterns. + */ + + +function ut_main() +{ + +$pattern=<<<_MSG_ +{0, select, + female {{1, plural, offset:1 + =0 {{2} does not give a party.} + =1 {{2} invites {3} to her party.} + =2 {{2} invites {3} and one other person to her party.} + other {{2} invites {3} as one of the # people invited to her party.}}} + male {{1, plural, offset:1 + =0 {{2} does not give a party.} + =1 {{2} invites {3} to his party.} + =2 {{2} invites {3} and one other person to his party.} + other {{2} invites {3} as one of the # other people invited to his party.}}} + other {{1, plural, offset:1 + =0 {{2} does not give a party.} + =1 {{2} invites {3} to their party.} + =2 {{2} invites {3} and one other person to their party.} + other {{2} invites {3} as one of the # other people invited to their party.}}}} +_MSG_; + + +$args = array( + array('female', 0, 'Alice', 'Bob'), + array('male', 1, 'Alice', 'Bob'), + array('none', 2, 'Alice', 'Bob'), + array('female', 27, 'Alice', 'Bob'), +); + +$str_res = ''; + + $fmt = ut_msgfmt_create( 'en_US', $pattern ); + if(!$fmt) { + $str_res .= dump(intl_get_error_message())."\n"; + return $str_res; + } + foreach ($args as $arg) { + $str_res .= dump( ut_msgfmt_format($fmt, $arg) ). "\n"; + $str_res .= dump( ut_msgfmt_format_message('en_US', $pattern, $arg) ) . "\n"; + } + return $str_res; +} + +include_once( 'ut_common.inc' ); + +// Run the test +ut_run(); + +?> +--EXPECT-- +'Alice does not give a party.' +'Alice does not give a party.' +'Alice invites Bob to his party.' +'Alice invites Bob to his party.' +'Alice invites Bob and one other person to their party.' +'Alice invites Bob and one other person to their party.' +'Alice invites Bob as one of the 26 people invited to her party.' +'Alice invites Bob as one of the 26 people invited to her party.' diff --git a/ext/intl/tests/msgfmt_format_subpatterns_named.phpt b/ext/intl/tests/msgfmt_format_subpatterns_named.phpt new file mode 100644 index 0000000000..f6af02561b --- /dev/null +++ b/ext/intl/tests/msgfmt_format_subpatterns_named.phpt @@ -0,0 +1,75 @@ +--TEST-- +msgfmt_format() with named subpatterns +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php + +/* + * Format a number using misc locales/patterns. + */ + + +function ut_main() +{ + +$pattern=<<<_MSG_ +{gender_of_host, select, + female {{num_guests, plural, offset:1 + =0 {{host} does not give a party.} + =1 {{host} invites {guest} to her party.} + =2 {{host} invites {guest} and one other person to her party.} + other {{host} invites {guest} as one of the # people invited to her party.}}} + male {{num_guests, plural, offset:1 + =0 {{host} does not give a party.} + =1 {{host} invites {guest} to his party.} + =2 {{host} invites {guest} and one other person to his party.} + other {{host} invites {guest} as one of the # people invited to his party.}}} + other {{num_guests, plural, offset:1 + =0 {{host} does not give a party.} + =1 {{host} invites {guest} to their party.} + =2 {{host} invites {guest} and one other person to their party.} + other {{host} invites {guest} as one of the # people invited to their party.}}}} +_MSG_; + + +$args = array( + array('gender_of_host' => 'female', 'num_guests' => 0, 'host' => 'Alice', 'guest' => 'Bob'), + array('gender_of_host' => 'male', 'num_guests' => 1, 'host' => 'Alice', 'guest' => 'Bob'), + array('gender_of_host' => 'none', 'num_guests' => 2, 'host' => 'Alice', 'guest' => 'Bob'), + array('gender_of_host' => 'female', 'num_guests' => 27, 'host' => 'Alice', 'guest' => 'Bob'), +); + +$str_res = ''; + + $fmt = ut_msgfmt_create( 'en_US', $pattern ); + if(!$fmt) { + $str_res .= dump(intl_get_error_message())."\n"; + return $str_res; + } + foreach ($args as $arg) { + $str_res .= dump( ut_msgfmt_format($fmt, $arg) ). "\n"; + $str_res .= dump( ut_msgfmt_format_message('en_US', $pattern, $arg) ) . "\n"; + } + return $str_res; +} + +include_once( 'ut_common.inc' ); + +// Run the test +ut_run(); + +?> +--EXPECT-- +'Alice does not give a party.' +'Alice does not give a party.' +'Alice invites Bob to his party.' +'Alice invites Bob to his party.' +'Alice invites Bob and one other person to their party.' +'Alice invites Bob and one other person to their party.' +'Alice invites Bob as one of the 26 people invited to her party.' +'Alice invites Bob as one of the 26 people invited to her party.' diff --git a/ext/intl/tests/msgfmt_get_error.phpt b/ext/intl/tests/msgfmt_get_error.phpt deleted file mode 100644 index 015c50d465..0000000000 --- a/ext/intl/tests/msgfmt_get_error.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -msgmfmt_get_error_message/code() ---SKIPIF-- -<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> ---FILE-- -<?php - -/* - * Error handling. - */ - - -function ut_main() -{ - $fmt = ut_msgfmt_create( "en_US", "{0, number} monkeys on {1, number} trees" ); - $num = ut_msgfmt_format( $fmt, array()); - if( $num === false ) - return $fmt->getErrorMessage() . " (" . $fmt->getErrorCode() . ")\n"; - else - return "Ooops, an error should have occured."; -} - -include_once( 'ut_common.inc' ); - -// Run the test -ut_run(); -?> ---EXPECT-- -msgfmt_format: not enough parameters: U_ILLEGAL_ARGUMENT_ERROR (1) diff --git a/ext/intl/tests/msgfmt_millisecond_dates.phpt b/ext/intl/tests/msgfmt_millisecond_dates.phpt new file mode 100644 index 0000000000..7dd051426b --- /dev/null +++ b/ext/intl/tests/msgfmt_millisecond_dates.phpt @@ -0,0 +1,29 @@ +--TEST-- +MessageFrormatter parses and formats dates with millisecond precision +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +date_default_timezone_set('Europe/Lisbon'); //ignored for now, see bug #58756 + +$d = 1336308097.123; +$mf = new MessageFormatter('en_US', + "On {0,time,yyyy-MM-dd G 'at' HH:mm:ss.SSS zzz} something odd happened"); + +var_dump($mf->format(array(1336310569.123))); + +$p = 'On 2012-05-06 AD at 15:22:49.123 GMT+02:00 something odd happened'; +var_dump($mf->parse($p)); + +?> +==DONE== +--EXPECTF-- +string(%d) "On 2012-05-0%d AD at %d:%d:49.123 %s something odd happened" +array(1) { + [0]=> + float(1336310569.123) +} +==DONE== diff --git a/ext/intl/tests/msgfmt_setPattern_cache.phpt b/ext/intl/tests/msgfmt_setPattern_cache.phpt new file mode 100644 index 0000000000..35ec463c2a --- /dev/null +++ b/ext/intl/tests/msgfmt_setPattern_cache.phpt @@ -0,0 +1,26 @@ +--TEST-- +MessageFormatter::setPattern() invalidates arg types cache +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +//ini_set("intl.default_locale", "nl"); + +$mf = new MessageFormatter('en_US', + "{0,number} -- {1,ordinal}"); + +var_dump($mf->format(array(1.3, 1.3))); +var_dump($mf->format(array(1.3, 1.3))); +$mf->setPattern("{0,ordinal} -- {1,number}"); +var_dump($mf->format(array(1.3, 1.3))); + +?> +==DONE== +--EXPECT-- +string(10) "1.3 -- 1st" +string(10) "1.3 -- 1st" +string(10) "1st -- 1.3" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/rbbiter___construct_basic.phpt b/ext/intl/tests/rbbiter___construct_basic.phpt new file mode 100644 index 0000000000..6fb584fdee --- /dev/null +++ b/ext/intl/tests/rbbiter___construct_basic.phpt @@ -0,0 +1,31 @@ +--TEST-- +IntlRuleBasedBreakIterator::__construct: basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); + +$rules = <<<RULES +\$LN = [[:letter:] [:number:]]; +\$S = [.;,:]; + +!!forward; +\$LN+ {1}; +\$S+ {42}; +!!reverse; +\$LN+ {1}; +\$S+ {42}; +!!safe_forward; +!!safe_reverse; +RULES; +$rbbi = new IntlRuleBasedBreakIterator($rules); +var_dump(get_class($rbbi)); +?> +==DONE== +--EXPECT-- +string(26) "IntlRuleBasedBreakIterator" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt b/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt new file mode 100644 index 0000000000..dce0714d4d --- /dev/null +++ b/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt @@ -0,0 +1,39 @@ +--TEST-- +IntlRuleBasedBreakIterator::getBinaryRules(): basic test +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +<?php if(version_compare(INTL_ICU_VERSION, '4.8') < 0) print 'skip ICU >= 4.8 only'; ?> +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); + +$rules = <<<RULES +\$LN = [[:letter:] [:number:]]; +\$S = [.;,:]; + +!!forward; +\$LN+ {1}; +\$S+ {42}; +!!reverse; +\$LN+ {1}; +\$S+ {42}; +!!safe_forward; +!!safe_reverse; +RULES; +$rbbi = new IntlRuleBasedBreakIterator($rules); +$rbbi->setText('sdfkjsdf88Ă¡.... ,;');; + +$br = $rbbi->getBinaryRules(); + +$rbbi2 = new IntlRuleBasedBreakIterator($br, true); + +var_dump($rbbi->getRules(), $rbbi2->getRules()); +var_dump($rbbi->getRules() == $rbbi2->getRules()); +?> +==DONE== +--EXPECT-- +string(128) "$LN = [[:letter:] [:number:]];$S = [.;,:];!!forward;$LN+ {1};$S+ {42};!!reverse;$LN+ {1};$S+ {42};!!safe_forward;!!safe_reverse;" +string(128) "$LN = [[:letter:] [:number:]];$S = [.;,:];!!forward;$LN+ {1};$S+ {42};!!reverse;$LN+ {1};$S+ {42};!!safe_forward;!!safe_reverse;" +bool(true) +==DONE== diff --git a/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt b/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt new file mode 100644 index 0000000000..a56f6bc488 --- /dev/null +++ b/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt @@ -0,0 +1,59 @@ +--TEST-- +IntlRuleBasedBreakIterator::getRuleStatusVec(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); + +$rules = <<<RULES +\$LN = [[:letter:] [:number:]]; +\$S = [.;,:]; + +!!forward; +\$LN+ {1}; +[^.]+ {4}; +\$S+ {42}; +!!reverse; +\$LN+ {1}; +[^.]+ {4}; +\$S+ {42}; +!!safe_forward; +!!safe_reverse; +RULES; +$rbbi = new IntlRuleBasedBreakIterator($rules); +$rbbi->setText('sdfkjsdf88Ă¡.... ,;');; + +do { + var_dump($rbbi->current(), $rbbi->getRuleStatusVec()); +} while ($rbbi->next() != IntlBreakIterator::DONE); + +?> +==DONE== +--EXPECT-- +int(0) +array(1) { + [0]=> + int(0) +} +int(12) +array(2) { + [0]=> + int(1) + [1]=> + int(4) +} +int(16) +array(1) { + [0]=> + int(42) +} +int(19) +array(1) { + [0]=> + int(4) +} +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/rbbiter_getRuleStatus_basic.phpt b/ext/intl/tests/rbbiter_getRuleStatus_basic.phpt new file mode 100644 index 0000000000..80eedbfba5 --- /dev/null +++ b/ext/intl/tests/rbbiter_getRuleStatus_basic.phpt @@ -0,0 +1,46 @@ +--TEST-- +IntlRuleBasedBreakIterator::getRuleStatus(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); + +$rules = <<<RULES +\$LN = [[:letter:] [:number:]]; +\$S = [.;,:]; + +!!forward; +\$LN+ {1}; +\$S+ {42}; +!!reverse; +\$LN+ {1}; +\$S+ {42}; +!!safe_forward; +!!safe_reverse; +RULES; +$rbbi = new IntlRuleBasedBreakIterator($rules); +$rbbi->setText('sdfkjsdf88Ă¡.... ,;'); + +do { + echo "pos : {$rbbi->current()}\n", + "rule status: {$rbbi->getRuleStatus()}\n"; +} while ($rbbi->next() != IntlBreakIterator::DONE); + +?> +==DONE== +--EXPECT-- +pos : 0 +rule status: 0 +pos : 12 +rule status: 1 +pos : 16 +rule status: 42 +pos : 17 +rule status: 0 +pos : 19 +rule status: 42 +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/rbbiter_getRules_basic.phpt b/ext/intl/tests/rbbiter_getRules_basic.phpt new file mode 100644 index 0000000000..2f7a40eb71 --- /dev/null +++ b/ext/intl/tests/rbbiter_getRules_basic.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlRuleBasedBreakIterator::getRules(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "pt_PT"); + +$rules = <<<RULES +\$LN = [[:letter:] [:number:]]; +\$S = [.;,:]; + +!!forward; +\$LN+ {1}; +\$S+ {42}; +!!reverse; +\$LN+ {1}; +\$S+ {42}; +!!safe_forward; +!!safe_reverse; +RULES; +$rbbi = new IntlRuleBasedBreakIterator($rules); +var_dump($rbbi->getRules()); + +?> +==DONE== +--EXPECT-- +string(128) "$LN = [[:letter:] [:number:]];$S = [.;,:];!!forward;$LN+ {1};$S+ {42};!!reverse;$LN+ {1};$S+ {42};!!safe_forward;!!safe_reverse;" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_clone_basic.phpt b/ext/intl/tests/timezone_clone_basic.phpt new file mode 100644 index 0000000000..a8ef83f864 --- /dev/null +++ b/ext/intl/tests/timezone_clone_basic.phpt @@ -0,0 +1,51 @@ +--TEST-- +IntlTimeZone clone handler: basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$tz1 = IntlTimeZone::createTimeZone('Europe/Amsterdam'); +print_r($tz1); +print_r(clone $tz1); + +//clone non-owned object +$gmt = IntlTimeZone::getGMT(); +print_r($gmt); +print_r(clone $gmt); + +?> +==DONE== +--EXPECTF-- +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Amsterdam + [rawOffset] => 3600000 + [currentOffset] => %d +) +IntlTimeZone Object +( + [valid] => 1 + [id] => Europe/Amsterdam + [rawOffset] => 3600000 + [currentOffset] => %d +) +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT + [rawOffset] => 0 + [currentOffset] => 0 +) +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT + [rawOffset] => 0 + [currentOffset] => 0 +) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_clone_error.phpt b/ext/intl/tests/timezone_clone_error.phpt new file mode 100644 index 0000000000..df501be3b4 --- /dev/null +++ b/ext/intl/tests/timezone_clone_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlTimeZone clone handler: error test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +class A extends IntlTimeZone { +function __construct() {} +} + +$tz = new A(); +var_dump($tz); +try { +var_dump(clone $tz); +} catch (Exception $e) { + var_dump(get_class($e), $e->getMessage()); +} + +?> +==DONE== +--EXPECT-- +object(A)#1 (1) { + ["valid"]=> + bool(false) +} +string(9) "Exception" +string(39) "Cannot clone unconstructed IntlTimeZone" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_countEquivalentIDs_basic.phpt b/ext/intl/tests/timezone_countEquivalentIDs_basic.phpt new file mode 100644 index 0000000000..ec3e4050ab --- /dev/null +++ b/ext/intl/tests/timezone_countEquivalentIDs_basic.phpt @@ -0,0 +1,20 @@ +--TEST-- +IntlTimeZone::countEquivalentIDs(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +$count = IntlTimeZone::countEquivalentIDs('Europe/Lisbon'); +var_dump($count >= 2); + +$count2 = intltz_count_equivalent_ids('Europe/Lisbon'); +var_dump($count2 == $count); +?> +==DONE== +--EXPECT-- +bool(true) +bool(true) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_countEquivalentIDs_error.phpt b/ext/intl/tests/timezone_countEquivalentIDs_error.phpt new file mode 100644 index 0000000000..4d8f4bc3e3 --- /dev/null +++ b/ext/intl/tests/timezone_countEquivalentIDs_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +IntlTimeZone::countEquivalentIDs(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(IntlTimeZone::countEquivalentIDs()); +var_dump(IntlTimeZone::countEquivalentIDs(array())); +var_dump(IntlTimeZone::countEquivalentIDs("foo\x80")); +var_dump(IntlTimeZone::countEquivalentIDs("foo bar", 7)); + + +--EXPECTF-- + +Warning: IntlTimeZone::countEquivalentIDs() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlTimeZone::countEquivalentIDs(): intltz_count_equivalent_ids: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::countEquivalentIDs() expects parameter 1 to be string, array given in %s on line %d + +Warning: IntlTimeZone::countEquivalentIDs(): intltz_count_equivalent_ids: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::countEquivalentIDs(): intltz_count_equivalent_ids: could not convert time zone id to UTF-16 in %s on line %d +bool(false) + +Warning: IntlTimeZone::countEquivalentIDs() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlTimeZone::countEquivalentIDs(): intltz_count_equivalent_ids: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/timezone_createDefault_basic.phpt b/ext/intl/tests/timezone_createDefault_basic.phpt new file mode 100644 index 0000000000..1988d3b9e5 --- /dev/null +++ b/ext/intl/tests/timezone_createDefault_basic.phpt @@ -0,0 +1,31 @@ +--TEST-- +IntlTimeZone::createDefault(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +$tz = IntlTimeZone::createDefault(); +print_r($tz); +$tz = intltz_create_default(); +print_r($tz); +?> +==DONE== +--EXPECTF-- +IntlTimeZone Object +( + [valid] => 1 + [id] => %s + [rawOffset] => %i + [currentOffset] => %i +) +IntlTimeZone Object +( + [valid] => 1 + [id] => %s + [rawOffset] => %i + [currentOffset] => %i +) +==DONE==
diff --git a/ext/intl/tests/timezone_createDefault_error.phpt b/ext/intl/tests/timezone_createDefault_error.phpt new file mode 100644 index 0000000000..0724898219 --- /dev/null +++ b/ext/intl/tests/timezone_createDefault_error.phpt @@ -0,0 +1,19 @@ +--TEST-- +IntlTimeZone::createDefault(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(IntlTimeZone::createDefault(4)); + + +--EXPECTF-- + +Warning: IntlTimeZone::createDefault() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::createDefault(): intltz_create_default: bad arguments in %s on line %d +NULL diff --git a/ext/intl/tests/timezone_createEnumeration_basic.phpt b/ext/intl/tests/timezone_createEnumeration_basic.phpt new file mode 100644 index 0000000000..2df32562b1 --- /dev/null +++ b/ext/intl/tests/timezone_createEnumeration_basic.phpt @@ -0,0 +1,26 @@ +--TEST-- +IntlTimeZone::createEnumeration(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +$tz = IntlTimeZone::createEnumeration(); +var_dump(get_class($tz)); +$count = count(iterator_to_array($tz)); +var_dump($count > 300); + +$tz = intltz_create_enumeration(); +var_dump(get_class($tz)); +$count2 = count(iterator_to_array($tz)); +var_dump($count == $count2); +?> +==DONE== +--EXPECT-- +string(12) "IntlIterator" +bool(true) +string(12) "IntlIterator" +bool(true) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_createEnumeration_error.phpt b/ext/intl/tests/timezone_createEnumeration_error.phpt new file mode 100644 index 0000000000..e1e7cb9333 --- /dev/null +++ b/ext/intl/tests/timezone_createEnumeration_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlTimeZone::createEnumeration(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(IntlTimeZone::createEnumeration(array())); +var_dump(IntlTimeZone::createEnumeration(1, 2)); + + +--EXPECTF-- + +Warning: IntlTimeZone::createEnumeration(): intltz_create_enumeration: invalid argument type in %s on line %d +bool(false) + +Warning: IntlTimeZone::createEnumeration() expects at most 1 parameter, 2 given in %s on line %d + +Warning: IntlTimeZone::createEnumeration(): intltz_create_enumeration: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/timezone_createEnumeration_variation1.phpt b/ext/intl/tests/timezone_createEnumeration_variation1.phpt new file mode 100644 index 0000000000..30fc43660e --- /dev/null +++ b/ext/intl/tests/timezone_createEnumeration_variation1.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlTimeZone::createEnumeration(): variant with offset +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +$tz = IntlTimeZone::createEnumeration(3600000); +var_dump(get_class($tz)); +$count = count(iterator_to_array($tz)); +var_dump($count > 20); + +$tz->rewind(); +var_dump(in_array('Europe/Amsterdam', iterator_to_array($tz))); + +?> +==DONE== +--EXPECT-- +string(12) "IntlIterator" +bool(true) +bool(true) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_createEnumeration_variation2.phpt b/ext/intl/tests/timezone_createEnumeration_variation2.phpt new file mode 100644 index 0000000000..ddf1a6ece1 --- /dev/null +++ b/ext/intl/tests/timezone_createEnumeration_variation2.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlTimeZone::createEnumeration(): variant with country +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +$tz = IntlTimeZone::createEnumeration('NL'); +var_dump(get_class($tz)); +$count = count(iterator_to_array($tz)); +var_dump($count >= 1); + +$tz->rewind(); +var_dump(in_array('Europe/Amsterdam', iterator_to_array($tz))); + +?> +==DONE== +--EXPECT-- +string(12) "IntlIterator" +bool(true) +bool(true) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_basic.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_basic.phpt new file mode 100644 index 0000000000..9ceffc5289 --- /dev/null +++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlTimeZone::createTimeZoneIDEnumeration(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +$enum = IntlTimeZone::createTimeZoneIDEnumeration( + IntlTimeZone::TYPE_ANY, + 'PT', + -3600000); +print_r(iterator_to_array($enum)); + +$enum = intltz_create_time_zone_id_enumeration( + IntlTimeZone::TYPE_ANY, + 'PT', + -3600000); +print_r(iterator_to_array($enum)); +?> +==DONE== +--EXPECT-- +Array +( + [0] => Atlantic/Azores +) +Array +( + [0] => Atlantic/Azores +) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error.phpt new file mode 100644 index 0000000000..2cc2ac48e7 --- /dev/null +++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +IntlTimeZone::createTimeZoneIDEnumeration(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(IntlTimeZone::createTimeZoneIDEnumeration()); +var_dump(IntlTimeZone::createTimeZoneIDEnumeration(array())); +var_dump(IntlTimeZone::createTimeZoneIDEnumeration(-1)); +var_dump(IntlTimeZone::createTimeZoneIDEnumeration(IntlTimeZone::TYPE_ANY, array())); +var_dump(IntlTimeZone::createTimeZoneIDEnumeration(IntlTimeZone::TYPE_ANY, "PT", "a80")); + +--EXPECTF-- + +Warning: IntlTimeZone::createTimeZoneIDEnumeration() expects at least 1 parameter, 0 given in %s on line %d + +Warning: IntlTimeZone::createTimeZoneIDEnumeration(): intltz_create_time_zone_id_enumeration: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::createTimeZoneIDEnumeration() expects parameter 1 to be long, array given in %s on line %d + +Warning: IntlTimeZone::createTimeZoneIDEnumeration(): intltz_create_time_zone_id_enumeration: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::createTimeZoneIDEnumeration(): intltz_create_time_zone_id_enumeration: bad zone type in %s on line %d +bool(false) + +Warning: IntlTimeZone::createTimeZoneIDEnumeration() expects parameter 2 to be string, array given in %s on line %d + +Warning: IntlTimeZone::createTimeZoneIDEnumeration(): intltz_create_time_zone_id_enumeration: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::createTimeZoneIDEnumeration() expects parameter 3 to be long, string given in %s on line %d + +Warning: IntlTimeZone::createTimeZoneIDEnumeration(): intltz_create_time_zone_id_enumeration: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant1.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant1.phpt new file mode 100644 index 0000000000..d57dfbf42f --- /dev/null +++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant1.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlTimeZone::createTimeZoneIDEnumeration(): variant without offset +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +$enum = IntlTimeZone::createTimeZoneIDEnumeration( + IntlTimeZone::TYPE_ANY, + 'PT'); +$values = iterator_to_array($enum); +var_dump(in_array('Europe/Lisbon', $values)); +var_dump(in_array('Atlantic/Azores', $values)); + +$enum = IntlTimeZone::createTimeZoneIDEnumeration( + IntlTimeZone::TYPE_ANY, + 'PT', + null); +$values2 = iterator_to_array($enum); +var_dump($values2 == $values); + +?> +==DONE== +--EXPECT-- +bool(true) +bool(true) +bool(true) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt new file mode 100644 index 0000000000..2afe171c58 --- /dev/null +++ b/ext/intl/tests/timezone_createTimeZoneIDEnumeration_variant2.phpt @@ -0,0 +1,52 @@ +--TEST-- +IntlTimeZone::createTimeZoneIDEnumeration(): variant without region +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +$enum = IntlTimeZone::createTimeZoneIDEnumeration( + IntlTimeZone::TYPE_ANY); +$countAny = count(iterator_to_array($enum)); +$enum = IntlTimeZone::createTimeZoneIDEnumeration( + IntlTimeZone::TYPE_CANONICAL); +$countCanonical = count(iterator_to_array($enum)); +$enum = IntlTimeZone::createTimeZoneIDEnumeration( + IntlTimeZone::TYPE_CANONICAL_LOCATION); +$countCanonicalLocation = count(iterator_to_array($enum)); + +var_dump($countAny > $countCanonical); +var_dump($countCanonical > $countCanonicalLocation); + +$enum = IntlTimeZone::createTimeZoneIDEnumeration( + IntlTimeZone::TYPE_ANY, null, null); +$countAny2 = count(iterator_to_array($enum)); +var_dump($countAny == $countAny2); + +$enum = IntlTimeZone::createTimeZoneIDEnumeration( + IntlTimeZone::TYPE_ANY, null, -3600000); +$values = iterator_to_array($enum); + +print_r( +array_values( +array_intersect($values, +array('Etc/GMT+1', 'Atlantic/Azores')) +)); + + +?> +==DONE== +--EXPECT-- +bool(true) +bool(true) +bool(true) +Array +( + [0] => Atlantic/Azores + [1] => Etc/GMT+1 +) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_createTimeZone_basic.phpt b/ext/intl/tests/timezone_createTimeZone_basic.phpt new file mode 100644 index 0000000000..e79f5b58ee --- /dev/null +++ b/ext/intl/tests/timezone_createTimeZone_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlTimeZone::createTimeZone(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +$tz = IntlTimeZone::createTimeZone('GMT+01:00'); +print_r($tz); +$tz = intltz_create_time_zone('GMT+01:00'); +print_r($tz); +?> +==DONE== +--EXPECT-- +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT+01:00 + [rawOffset] => 3600000 + [currentOffset] => 3600000 +) +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT+01:00 + [rawOffset] => 3600000 + [currentOffset] => 3600000 +) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_createTimeZone_error.phpt b/ext/intl/tests/timezone_createTimeZone_error.phpt new file mode 100644 index 0000000000..2be821a67e --- /dev/null +++ b/ext/intl/tests/timezone_createTimeZone_error.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlTimeZone::createTimeZone(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(IntlTimeZone::createTimeZone()); +var_dump(IntlTimeZone::createTimeZone(new stdClass)); +var_dump(IntlTimeZone::createTimeZone("foo bar", 4)); +var_dump(IntlTimeZone::createTimeZone("foo\x80")); + +--EXPECTF-- + +Warning: IntlTimeZone::createTimeZone() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlTimeZone::createTimeZone(): intltz_create_time_zone: bad arguments in %s on line %d +NULL + +Warning: IntlTimeZone::createTimeZone() expects parameter 1 to be string, object given in %s on line %d + +Warning: IntlTimeZone::createTimeZone(): intltz_create_time_zone: bad arguments in %s on line %d +NULL + +Warning: IntlTimeZone::createTimeZone() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlTimeZone::createTimeZone(): intltz_create_time_zone: bad arguments in %s on line %d +NULL + +Warning: IntlTimeZone::createTimeZone(): intltz_create_time_zone: could not convert time zone id to UTF-16 in %s on line %d +NULL diff --git a/ext/intl/tests/timezone_equals_basic.phpt b/ext/intl/tests/timezone_equals_basic.phpt new file mode 100644 index 0000000000..105ae8582f --- /dev/null +++ b/ext/intl/tests/timezone_equals_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlTimeZone equals handler: basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$tz1 = intltz_create_time_zone('Europe/Lisbon'); +$tz2 = intltz_create_time_zone('Europe/Lisbon'); +echo "Comparison to self:\n"; +var_dump($tz1 == $tz1); +echo "Comparison to equal instance:\n"; +var_dump($tz1 == $tz2); +echo "Comparison to equivalent instance:\n"; +var_dump($tz1 == intltz_create_time_zone('Portugal')); +echo "Comparison to GMT:\n"; +var_dump($tz1 == intltz_get_gmt()); + +?> +==DONE== +--EXPECT-- +Comparison to self: +bool(true) +Comparison to equal instance: +bool(true) +Comparison to equivalent instance: +bool(false) +Comparison to GMT: +bool(false) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_equals_error.phpt b/ext/intl/tests/timezone_equals_error.phpt new file mode 100644 index 0000000000..d8d027a761 --- /dev/null +++ b/ext/intl/tests/timezone_equals_error.phpt @@ -0,0 +1,43 @@ +--TEST-- +IntlTimeZone equals handler: error test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +class A extends IntlTimeZone { +function __construct() {} +} + +$tz = new A(); +$tz2 = intltz_get_gmt(); +var_dump($tz, $tz2); +try { +var_dump($tz == $tz2); +} catch (Exception $e) { + var_dump(get_class($e), $e->getMessage()); +} + +?> +==DONE== +--EXPECT-- +object(A)#1 (1) { + ["valid"]=> + bool(false) +} +object(IntlTimeZone)#2 (4) { + ["valid"]=> + bool(true) + ["id"]=> + string(3) "GMT" + ["rawOffset"]=> + int(0) + ["currentOffset"]=> + int(0) +} +string(9) "Exception" +string(63) "Comparison with at least one unconstructed IntlTimeZone operand" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_fromDateTimeZone_basic.phpt b/ext/intl/tests/timezone_fromDateTimeZone_basic.phpt new file mode 100644 index 0000000000..10e2621ae4 --- /dev/null +++ b/ext/intl/tests/timezone_fromDateTimeZone_basic.phpt @@ -0,0 +1,41 @@ +--TEST-- +IntlTimeZone::fromDateTimeZone(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); +date_default_timezone_set('Europe/Lisbon'); + +$tz = IntlTimeZone::fromDateTimeZone(new DateTimeZone('Europe/Amsterdam')); +var_dump($tz->getID(), $tz->getRawOffset()); + + +$dt = new DateTime('2012-01-01 00:00:00 CET'); +$dtz = $dt->getTimeZone(); +/* this is different from new DateTimeZone('CET'), + * which gives a Europe/Berlin timezone */ +var_dump($dtz->getName()); +$tz = IntlTimeZone::fromDateTimeZone($dtz); +var_dump($tz->getID(), $tz->getRawOffset()); + + +$dt = new DateTime('2012-01-01 00:00:00 +0340'); +$dtz = $dt->getTimeZone(); +/* I don't think this timezone can be generated without a DateTime object */ +var_dump($dtz->getName()); +$tz = IntlTimeZone::fromDateTimeZone($dtz); +var_dump($tz->getID(), $tz->getRawOffset() /* (3*60+40)*60000 */); + +--EXPECTF-- +string(16) "Europe/Amsterdam" +int(3600000) +string(3) "CET" +string(3) "CET" +int(3600000) +string(6) "+03:40" +string(%d) "GMT+03%s0" +int(13200000) diff --git a/ext/intl/tests/timezone_fromDateTimeZone_error.phpt b/ext/intl/tests/timezone_fromDateTimeZone_error.phpt new file mode 100644 index 0000000000..031882277e --- /dev/null +++ b/ext/intl/tests/timezone_fromDateTimeZone_error.phpt @@ -0,0 +1,50 @@ +--TEST-- +IntlTimeZone::fromDateTimeZone(): argument errors +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(IntlTimeZone::fromDateTimeZone()); +var_dump(IntlTimeZone::fromDateTimeZone(1,2)); +var_dump(IntlTimeZone::fromDateTimeZone('sdfds')); +var_dump(IntlTimeZone::fromDateTimeZone(new stdclass)); +$dt = new DateTime('2012-08-01 00:00:00 WEST'); +var_dump(IntlTimeZone::fromDateTimeZone($dt->getTimeZone())); + +var_dump(intltz_from_date_time_zone()); + +--EXPECTF-- + +Warning: IntlTimeZone::fromDateTimeZone() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d +NULL + +Warning: IntlTimeZone::fromDateTimeZone() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d +NULL + +Warning: IntlTimeZone::fromDateTimeZone() expects parameter 1 to be DateTimeZone, string given in %s on line %d + +Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d +NULL + +Warning: IntlTimeZone::fromDateTimeZone() expects parameter 1 to be DateTimeZone, object given in %s on line %d + +Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d +NULL + +Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d +NULL + +Warning: intltz_from_date_time_zone() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: intltz_from_date_time_zone(): intltz_from_date_time_zone: bad arguments in %s on line %d +NULL diff --git a/ext/intl/tests/timezone_getCanonicalID_basic.phpt b/ext/intl/tests/timezone_getCanonicalID_basic.phpt new file mode 100644 index 0000000000..897e9a9edc --- /dev/null +++ b/ext/intl/tests/timezone_getCanonicalID_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +IntlTimeZone::getCanonicalID: basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +print_R(IntlTimeZone::getCanonicalID('Portugal')); +echo "\n"; +print_R(intltz_get_canonical_id('Portugal')); +echo "\n"; +?> +==DONE== +--EXPECT-- +Europe/Lisbon +Europe/Lisbon +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getCanonicalID_error.phpt b/ext/intl/tests/timezone_getCanonicalID_error.phpt new file mode 100644 index 0000000000..c7ffb45b77 --- /dev/null +++ b/ext/intl/tests/timezone_getCanonicalID_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +IntlTimeZone::getCanonicalID(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(IntlTimeZone::getCanonicalID()); +var_dump(IntlTimeZone::getCanonicalID(array())); +var_dump(IntlTimeZone::getCanonicalID("foo\x81")); +var_dump(IntlTimeZone::getCanonicalID('foobar', null)); + + +--EXPECTF-- + +Warning: IntlTimeZone::getCanonicalID() expects at least 1 parameter, 0 given in %s on line %d + +Warning: IntlTimeZone::getCanonicalID(): intltz_get_canonical_id: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getCanonicalID() expects parameter 1 to be string, array given in %s on line %d + +Warning: IntlTimeZone::getCanonicalID(): intltz_get_canonical_id: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getCanonicalID(): intltz_get_canonical_id: could not convert time zone id to UTF-16 in %s on line %d +bool(false) + +Fatal error: Cannot pass parameter 2 by reference in %s on line %d diff --git a/ext/intl/tests/timezone_getCanonicalID_variant1.phpt b/ext/intl/tests/timezone_getCanonicalID_variant1.phpt new file mode 100644 index 0000000000..92a7f07378 --- /dev/null +++ b/ext/intl/tests/timezone_getCanonicalID_variant1.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlTimeZone::getCanonicalID(): second argument +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(IntlTimeZone::getCanonicalID('Portugal', $isSystemId)); +var_dump($isSystemId); + +var_dump(IntlTimeZone::getCanonicalID('GMT +01:25', $isSystemId)); +var_dump($isSystemId); + +?> +==DONE== +--EXPECT-- +string(13) "Europe/Lisbon" +bool(true) +string(0) "" +bool(false) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getDSTSavings_basic.phpt b/ext/intl/tests/timezone_getDSTSavings_basic.phpt new file mode 100644 index 0000000000..8dee5b8e94 --- /dev/null +++ b/ext/intl/tests/timezone_getDSTSavings_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +IntlTimeZone::getDSTSavings(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon'); +var_dump($lsb->getDSTSavings()); + +var_dump(intltz_get_dst_savings($lsb)); + +?> +==DONE== +--EXPECT-- +int(3600000) +int(3600000) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getDSTSavings_error.phpt b/ext/intl/tests/timezone_getDSTSavings_error.phpt new file mode 100644 index 0000000000..e1469f4ac6 --- /dev/null +++ b/ext/intl/tests/timezone_getDSTSavings_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlTimeZone::getDSTSavings(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$tz = IntlTimeZone::createTimeZone('Europe/Lisbon'); +var_dump($tz->getDSTSavings(array())); + +var_dump(intltz_get_dst_savings(null)); + +--EXPECTF-- + +Warning: IntlTimeZone::getDSTSavings() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::getDSTSavings(): intltz_get_dst_savings: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_get_dst_savings() must be an instance of IntlTimeZone, null given in %s on line %d diff --git a/ext/intl/tests/timezone_getDisplayName_basic.phpt b/ext/intl/tests/timezone_getDisplayName_basic.phpt new file mode 100644 index 0000000000..e4fc2f37ce --- /dev/null +++ b/ext/intl/tests/timezone_getDisplayName_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +IntlTimeZone::getDisplayName(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon'); + +ini_set('intl.default_locale', 'en_US'); +var_dump($lsb->getDisplayName()); + +ini_set('intl.default_locale', 'pt_PT'); +var_dump($lsb->getDisplayName()); + +?> +==DONE== +--EXPECTF-- +string(%d) "Western European%sTime" +string(%d) "Hora%sda Europa Ocidental" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getDisplayName_error.phpt b/ext/intl/tests/timezone_getDisplayName_error.phpt new file mode 100644 index 0000000000..a12f85c855 --- /dev/null +++ b/ext/intl/tests/timezone_getDisplayName_error.phpt @@ -0,0 +1,45 @@ +--TEST-- +IntlTimeZone::getDisplayName(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$tz = IntlTimeZone::createTimeZone('Europe/Lisbon'); +var_dump($tz->getDisplayName(array())); +var_dump($tz->getDisplayName(false, array())); +var_dump($tz->getDisplayName(false, -1)); +var_dump($tz->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT, array())); +var_dump($tz->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT, NULL, NULL)); + +var_dump(intltz_get_display_name(null, IntlTimeZone::DISPLAY_SHORT, false, 'pt_PT')); + +--EXPECTF-- + +Warning: IntlTimeZone::getDisplayName() expects parameter 1 to be boolean, array given in %s on line %d + +Warning: IntlTimeZone::getDisplayName(): intltz_get_display_name: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getDisplayName() expects parameter 2 to be long, array given in %s on line %d + +Warning: IntlTimeZone::getDisplayName(): intltz_get_display_name: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getDisplayName(): intltz_get_display_name: wrong display type in %s on line %d +bool(false) + +Warning: IntlTimeZone::getDisplayName() expects parameter 3 to be string, array given in %s on line %d + +Warning: IntlTimeZone::getDisplayName(): intltz_get_display_name: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getDisplayName() expects at most 3 parameters, 4 given in %s on line %d + +Warning: IntlTimeZone::getDisplayName(): intltz_get_display_name: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_get_display_name() must be an instance of IntlTimeZone, null given in %s on line %d diff --git a/ext/intl/tests/timezone_getDisplayName_variant1.phpt b/ext/intl/tests/timezone_getDisplayName_variant1.phpt new file mode 100644 index 0000000000..83922dd170 --- /dev/null +++ b/ext/intl/tests/timezone_getDisplayName_variant1.phpt @@ -0,0 +1,26 @@ +--TEST-- +IntlTimeZone::getDisplayName(): daylight parameter effect +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("error_reporting", -1); +ini_set("display_errors", 1); + +$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon'); + +ini_set('intl.default_locale', 'en_US'); +var_dump($lsb->getDisplayName()); +var_dump($lsb->getDisplayName(false)); +var_dump($lsb->getDisplayName(true)); + +?> +==DONE== +--EXPECTF-- +string(%d) "Western European%sTime" +string(%d) "Western European%sTime" +string(28) "Western European Summer Time" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getDisplayName_variant2-49+.phpt b/ext/intl/tests/timezone_getDisplayName_variant2-49+.phpt new file mode 100644 index 0000000000..4ee30aee12 --- /dev/null +++ b/ext/intl/tests/timezone_getDisplayName_variant2-49+.phpt @@ -0,0 +1,38 @@ +--TEST-- +IntlTimeZone::getDisplayName(): type parameter (ICU >= 49) +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '49') < 0) + die('skip for ICU 49+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("error_reporting", -1); +ini_set("display_errors", 1); + +$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon'); + +ini_set('intl.default_locale', 'en_US'); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_GENERIC)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG_GENERIC)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_GMT)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG_GMT)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_COMMONLY_USED)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_GENERIC_LOCATION)); + +?> +==DONE== +--EXPECT-- +string(3) "GMT" +string(30) "Western European Standard Time" +string(22) "Portugal Time (Lisbon)" +string(21) "Western European Time" +string(5) "+0000" +string(3) "GMT" +string(3) "GMT" +string(22) "Portugal Time (Lisbon)" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getDisplayName_variant2.phpt b/ext/intl/tests/timezone_getDisplayName_variant2.phpt new file mode 100644 index 0000000000..1ccf68767f --- /dev/null +++ b/ext/intl/tests/timezone_getDisplayName_variant2.phpt @@ -0,0 +1,40 @@ +--TEST-- +IntlTimeZone::getDisplayName(): type parameter (ICU < 49) +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '49') >= 0) + die('skip for ICU < 49'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("error_reporting", -1); +ini_set("display_errors", 1); + +$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon'); + +ini_set('intl.default_locale', 'en_US'); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_GENERIC)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG_GENERIC)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_GMT)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG_GMT)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_COMMONLY_USED)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_GENERIC_LOCATION)); + +?> +==DONE== +--EXPECT-- +string(3) "WET" +string(21) "Western European Time" +string(22) "Portugal Time (Lisbon)" +string(22) "Portugal Time (Lisbon)" +string(5) "+0000" +string(3) "GMT" +string(3) "GMT" +string(22) "Portugal Time (Lisbon)" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getDisplayName_variant3-49+.phpt b/ext/intl/tests/timezone_getDisplayName_variant3-49+.phpt new file mode 100644 index 0000000000..e90cc4748c --- /dev/null +++ b/ext/intl/tests/timezone_getDisplayName_variant3-49+.phpt @@ -0,0 +1,28 @@ +--TEST-- +IntlTimeZone::getDisplayName(): locale parameter +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '49') < 0) + die('skip for ICU 49+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("error_reporting", -1); +ini_set("display_errors", 1); + +$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon'); + +ini_set('intl.default_locale', 'en_US'); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG, NULL)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG, 'pt_PT')); + +?> +==DONE== +--EXPECT-- +string(30) "Western European Standard Time" +string(30) "Western European Standard Time" +string(32) "Hora PadrĂ£o da Europa Ocidental" +==DONE== diff --git a/ext/intl/tests/timezone_getDisplayName_variant3.phpt b/ext/intl/tests/timezone_getDisplayName_variant3.phpt new file mode 100644 index 0000000000..c160777583 --- /dev/null +++ b/ext/intl/tests/timezone_getDisplayName_variant3.phpt @@ -0,0 +1,28 @@ +--TEST-- +IntlTimeZone::getDisplayName(): locale parameter +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '49') >= 0) + die('skip for ICU <= 4.8'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("error_reporting", -1); +ini_set("display_errors", 1); + +$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon'); + +ini_set('intl.default_locale', 'en_US'); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG, NULL)); +var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG, 'pt_PT')); + +?> +==DONE== +--EXPECT-- +string(21) "Western European Time" +string(21) "Western European Time" +string(24) "Hora da Europa Ocidental" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getEquivalentID_basic.phpt b/ext/intl/tests/timezone_getEquivalentID_basic.phpt new file mode 100644 index 0000000000..8af1e20897 --- /dev/null +++ b/ext/intl/tests/timezone_getEquivalentID_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +IntlTimeZone::getEquivalentID(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +print_R(IntlTimeZone::getEquivalentID('Europe/Lisbon', "1")); +echo "\n"; +print_R(intltz_get_equivalent_id('Europe/Lisbon', 1)); +echo "\n"; +?> +==DONE== +--EXPECT-- +Portugal +Portugal +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getEquivalentID_error.phpt b/ext/intl/tests/timezone_getEquivalentID_error.phpt new file mode 100644 index 0000000000..b3f344b54d --- /dev/null +++ b/ext/intl/tests/timezone_getEquivalentID_error.phpt @@ -0,0 +1,34 @@ +--TEST-- +IntlTimeZone::getEquivalentID(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(IntlTimeZone::getEquivalentID('foo')); +var_dump(IntlTimeZone::getEquivalentID('foo', 'bar')); +var_dump(IntlTimeZone::getEquivalentID('Europe/Lisbon', 0, 1)); +var_dump(IntlTimeZone::getEquivalentID("foo\x80", 0)); + +--EXPECTF-- + +Warning: IntlTimeZone::getEquivalentID() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::getEquivalentID(): intltz_get_equivalent_id: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getEquivalentID() expects parameter 2 to be long, string given in %s on line %d + +Warning: IntlTimeZone::getEquivalentID(): intltz_get_equivalent_id: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getEquivalentID() expects exactly 2 parameters, 3 given in %s on line %d + +Warning: IntlTimeZone::getEquivalentID(): intltz_get_equivalent_id: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getEquivalentID(): intltz_get_equivalent_id: could not convert time zone id to UTF-16 in %s on line %d +bool(false) diff --git a/ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt b/ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt new file mode 100644 index 0000000000..d3a3dee47d --- /dev/null +++ b/ext/intl/tests/timezone_getErrorCodeMessage_basic.phpt @@ -0,0 +1,31 @@ +--TEST-- +IntlTimeZone::getErrorCode/Message(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon'); + +var_dump($lsb->getErrorCode()); +var_dump($lsb->getErrorMessage()); + +var_dump($lsb->getOffset(INF, 1, $a, $b)); + +var_dump($lsb->getErrorCode()); +var_dump($lsb->getErrorMessage()); + +?> +==DONE== +--EXPECTF-- +int(0) +string(12) "U_ZERO_ERROR" + +Warning: IntlTimeZone::getOffset(): intltz_get_offset: error obtaining offset in %s on line %d +bool(false) +int(1) +string(67) "intltz_get_offset: error obtaining offset: U_ILLEGAL_ARGUMENT_ERROR" +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getErrorCode_error.phpt b/ext/intl/tests/timezone_getErrorCode_error.phpt new file mode 100644 index 0000000000..b56d3b0a48 --- /dev/null +++ b/ext/intl/tests/timezone_getErrorCode_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlTimeZone::getErrorCode(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$tz = IntlTimeZone::createTimeZone('Europe/Lisbon'); +var_dump($tz->getErrorCode(array())); + +var_dump(intltz_get_error_code(null)); + +--EXPECTF-- + +Warning: IntlTimeZone::getErrorCode() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::getErrorCode(): intltz_get_error_code: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_get_error_code() must be an instance of IntlTimeZone, null given in %s on line %d diff --git a/ext/intl/tests/timezone_getErrorMessage_error.phpt b/ext/intl/tests/timezone_getErrorMessage_error.phpt new file mode 100644 index 0000000000..067dcdc13b --- /dev/null +++ b/ext/intl/tests/timezone_getErrorMessage_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlTimeZone::getErrorMessage(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$tz = IntlTimeZone::createTimeZone('Europe/Lisbon'); +var_dump($tz->getErrorMessage(array())); + +var_dump(intltz_get_error_message(null)); + +--EXPECTF-- + +Warning: IntlTimeZone::getErrorMessage() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::getErrorMessage(): intltz_get_error_message: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_get_error_message() must be an instance of IntlTimeZone, null given in %s on line %d diff --git a/ext/intl/tests/timezone_getGMT_basic.phpt b/ext/intl/tests/timezone_getGMT_basic.phpt new file mode 100644 index 0000000000..99b3fa22ca --- /dev/null +++ b/ext/intl/tests/timezone_getGMT_basic.phpt @@ -0,0 +1,31 @@ +--TEST-- +IntlTimeZone::getGMT(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +$tz = IntlTimeZone::getGMT(); +print_r($tz); +$tz = intltz_get_gmt(); +print_r($tz); +?> +==DONE== +--EXPECT-- +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT + [rawOffset] => 0 + [currentOffset] => 0 +) +IntlTimeZone Object +( + [valid] => 1 + [id] => GMT + [rawOffset] => 0 + [currentOffset] => 0 +) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getGMT_error.phpt b/ext/intl/tests/timezone_getGMT_error.phpt new file mode 100644 index 0000000000..15afb765e4 --- /dev/null +++ b/ext/intl/tests/timezone_getGMT_error.phpt @@ -0,0 +1,19 @@ +--TEST-- +IntlTimeZone::getGMT(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(IntlTimeZone::getGMT(4)); + + +--EXPECTF-- + +Warning: IntlTimeZone::getGMT() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::getGMT(): intltz_get_gmt: bad arguments in %s on line %d +NULL diff --git a/ext/intl/tests/timezone_getID_error.phpt b/ext/intl/tests/timezone_getID_error.phpt new file mode 100644 index 0000000000..b239b3facf --- /dev/null +++ b/ext/intl/tests/timezone_getID_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlTimeZone::getID(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$tz = IntlTimeZone::createTimeZone('Europe/Lisbon'); +var_dump($tz->getID('foo')); +intltz_get_id(null); + + +--EXPECTF-- + +Warning: IntlTimeZone::getID() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::getID(): intltz_get_id: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_get_id() must be an instance of IntlTimeZone, null given in %s on line %d diff --git a/ext/intl/tests/timezone_getOffset_basic.phpt b/ext/intl/tests/timezone_getOffset_basic.phpt new file mode 100644 index 0000000000..582d45cad9 --- /dev/null +++ b/ext/intl/tests/timezone_getOffset_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlTimeZone::getOffset(): basic test +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +$ams = IntlTimeZone::createTimeZone('Europe/Amsterdam'); + +$date = strtotime("1 July 2012 +0000"); + +var_dump($ams->getOffset($date *1000., true, $rawOffset, $dstOffset), + $rawOffset, $dstOffset); + +$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon'); + +var_dump(intltz_get_offset($lsb, $date *1000., true, $rawOffset, $dstOffset), + $rawOffset, $dstOffset); + +?> +==DONE== +--EXPECT-- +bool(true) +int(3600000) +int(3600000) +bool(true) +int(0) +int(3600000) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getOffset_error.phpt b/ext/intl/tests/timezone_getOffset_error.phpt new file mode 100644 index 0000000000..73555002c0 --- /dev/null +++ b/ext/intl/tests/timezone_getOffset_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +IntlTimeZone::getOffset(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$tz = IntlTimeZone::createTimeZone('Europe/Lisbon'); +var_dump($tz->getOffset(INF, true, $a, $a)); +var_dump($tz->getOffset(time()*1000, true, $a)); +var_dump($tz->getOffset(time()*1000, true, $a, $a, $a)); + +intltz_get_offset(null, time()*1000, false, $a, $a); + +--EXPECTF-- + +Warning: IntlTimeZone::getOffset(): intltz_get_offset: error obtaining offset in %s on line %d +bool(false) + +Warning: IntlTimeZone::getOffset() expects exactly 4 parameters, 3 given in %s on line %d + +Warning: IntlTimeZone::getOffset(): intltz_get_offset: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getOffset() expects exactly 4 parameters, 5 given in %s on line %d + +Warning: IntlTimeZone::getOffset(): intltz_get_offset: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_get_offset() must be an instance of IntlTimeZone, null given in %s on line %d diff --git a/ext/intl/tests/timezone_getRawOffset_basic.phpt b/ext/intl/tests/timezone_getRawOffset_basic.phpt new file mode 100644 index 0000000000..a2b4debf2b --- /dev/null +++ b/ext/intl/tests/timezone_getRawOffset_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +IntlTimeZone::getRawOffset(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +$ams = IntlTimeZone::createTimeZone('Europe/Amsterdam'); +var_dump($ams->getRawOffset()); + +$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon'); +var_dump(intltz_get_raw_offset($lsb)); + +?> +==DONE== +--EXPECT-- +int(3600000) +int(0) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getRawOffset_error.phpt b/ext/intl/tests/timezone_getRawOffset_error.phpt new file mode 100644 index 0000000000..eb6aac02cd --- /dev/null +++ b/ext/intl/tests/timezone_getRawOffset_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +IntlTimeZone::getRawOffset(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$tz = IntlTimeZone::createTimeZone('Europe/Lisbon'); +var_dump($tz->getRawOffset('foo')); + +intltz_get_raw_offset(null); + +--EXPECTF-- + +Warning: IntlTimeZone::getRawOffset() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::getRawOffset(): intltz_get_raw_offset: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_get_raw_offset() must be an instance of IntlTimeZone, null given in %s on line %d diff --git a/ext/intl/tests/timezone_getRegion_basic.phpt b/ext/intl/tests/timezone_getRegion_basic.phpt new file mode 100644 index 0000000000..1a41ae8d58 --- /dev/null +++ b/ext/intl/tests/timezone_getRegion_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +IntlTimeZone::getRegion(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +print_R(IntlTimeZone::getRegion('Europe/Amsterdam')); +echo "\n"; +print_R(intltz_get_region('Europe/Amsterdam')); +echo "\n"; +?> +==DONE== +--EXPECT-- +NL +NL +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getRegion_error.phpt b/ext/intl/tests/timezone_getRegion_error.phpt new file mode 100644 index 0000000000..34911d9abc --- /dev/null +++ b/ext/intl/tests/timezone_getRegion_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +IntlTimeZone::getRegion(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '4.8') < 0) + die('skip for ICU 4.8+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(IntlTimeZone::getRegion()); +var_dump(IntlTimeZone::getRegion(array())); +var_dump(IntlTimeZone::getRegion('Europe/Lisbon', 4)); +var_dump(IntlTimeZone::getRegion("foo\x81")); +var_dump(IntlTimeZone::getRegion("foo")); + + + +--EXPECTF-- + +Warning: IntlTimeZone::getRegion() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: IntlTimeZone::getRegion(): intltz_get_region: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getRegion() expects parameter 1 to be string, array given in %s on line %d + +Warning: IntlTimeZone::getRegion(): intltz_get_region: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getRegion() expects exactly 1 parameter, 2 given in %s on line %d + +Warning: IntlTimeZone::getRegion(): intltz_get_region: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::getRegion(): intltz_get_region: could not convert time zone id to UTF-16 in %s on line %d +bool(false) + +Warning: IntlTimeZone::getRegion(): intltz_get_region: Error obtaining region in %s on line %d +bool(false) diff --git a/ext/intl/tests/timezone_getTZDataVersion_error.phpt b/ext/intl/tests/timezone_getTZDataVersion_error.phpt new file mode 100644 index 0000000000..258b8807b7 --- /dev/null +++ b/ext/intl/tests/timezone_getTZDataVersion_error.phpt @@ -0,0 +1,18 @@ +--TEST-- +IntlTimeZone::getTZDataVersion(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +var_dump(IntlTimeZone::getTZDataVersion('foo')); + +--EXPECTF-- + +Warning: IntlTimeZone::getTZDataVersion() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::getTZDataVersion(): intltz_get_tz_data_version: bad arguments in %s on line %d +bool(false) diff --git a/ext/intl/tests/timezone_getTZData_basic.phpt b/ext/intl/tests/timezone_getTZData_basic.phpt new file mode 100644 index 0000000000..dea5b7c4b3 --- /dev/null +++ b/ext/intl/tests/timezone_getTZData_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +IntlTimeZone::getTZDataVersion: basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +print_R(IntlTimeZone::getTZDataVersion()); +echo "\n"; +print_R(intltz_get_tz_data_version()); +echo "\n"; +?> +==DONE== +--EXPECTF-- +20%d%s +20%d%s +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getUnknown_basic.phpt b/ext/intl/tests/timezone_getUnknown_basic.phpt new file mode 100644 index 0000000000..aef1a54561 --- /dev/null +++ b/ext/intl/tests/timezone_getUnknown_basic.phpt @@ -0,0 +1,35 @@ +--TEST-- +IntlCalendar::getUnknown(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '49') < 0) + die('skip for ICU 49+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); + +$tz = IntlTimeZone::getUnknown(); +print_r($tz); +$tz = intltz_get_unknown(); +print_r($tz); +?> +==DONE== +--EXPECT-- +IntlTimeZone Object +( + [valid] => 1 + [id] => Etc/Unknown + [rawOffset] => 0 + [currentOffset] => 0 +) +IntlTimeZone Object +( + [valid] => 1 + [id] => Etc/Unknown + [rawOffset] => 0 + [currentOffset] => 0 +) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_getUnknown_error.phpt b/ext/intl/tests/timezone_getUnknown_error.phpt new file mode 100644 index 0000000000..704b1b096f --- /dev/null +++ b/ext/intl/tests/timezone_getUnknown_error.phpt @@ -0,0 +1,29 @@ +--TEST-- +IntlCalendar::getUnknown(): bad arguments +--INI-- +date.timezone=Atlantic/Azores +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +if (version_compare(INTL_ICU_VERSION, '49') < 0) + die('skip for ICU 49+'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$c = new IntlGregorianCalendar(NULL, 'pt_PT'); + +IntlTimeZone::getUnknown(1); + +intltz_get_unknown(1); + +--EXPECTF-- + +Warning: IntlTimeZone::getUnknown() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::getUnknown(): intltz_get_unknown: bad arguments in %s on line %d + +Warning: intltz_get_unknown() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: intltz_get_unknown(): intltz_get_unknown: bad arguments in %s on line %d diff --git a/ext/intl/tests/timezone_hasSameRules_basic.phpt b/ext/intl/tests/timezone_hasSameRules_basic.phpt new file mode 100644 index 0000000000..55faaf760b --- /dev/null +++ b/ext/intl/tests/timezone_hasSameRules_basic.phpt @@ -0,0 +1,35 @@ +--TEST-- +IntlTimeZone::hasSameRules(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon'); +$prt = IntlTimeZone::createTimeZone('Portugal'); +$azo = IntlTimeZone::createTimeZone('Atlantic/Azores'); + +echo "Europe/Lisbon has same rules as itself:\n"; +var_dump($lsb->hasSameRules($lsb)); + +echo "\nEurope/Lisbon has same rules as Portugal:\n"; +var_dump($lsb->hasSameRules($prt)); + +echo "\nEurope/Lisbon has same rules as Atlantic/Azores:\n"; +var_dump(intltz_has_same_rules($lsb, $azo)); + +?> +==DONE== +--EXPECT-- +Europe/Lisbon has same rules as itself: +bool(true) + +Europe/Lisbon has same rules as Portugal: +bool(true) + +Europe/Lisbon has same rules as Atlantic/Azores: +bool(false) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_hasSameRules_error.phpt b/ext/intl/tests/timezone_hasSameRules_error.phpt new file mode 100644 index 0000000000..35a29be5db --- /dev/null +++ b/ext/intl/tests/timezone_hasSameRules_error.phpt @@ -0,0 +1,37 @@ +--TEST-- +IntlTimeZone::hasSameRules(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +function error_handler($errno, $errstr, $errfile, $errline) +{ + var_dump($errno, $errstr); + return true; +} +set_error_handler("error_handler"); + +$tz = IntlTimeZone::createTimeZone('Europe/Lisbon'); +var_dump($tz->hasSameRules('foo')); + +var_dump(intltz_has_same_rules(null, $tz)); + +--EXPECT-- +int(4096) +string(99) "Argument 1 passed to IntlTimeZone::hasSameRules() must be an instance of IntlTimeZone, string given" +int(2) +string(81) "IntlTimeZone::hasSameRules() expects parameter 1 to be IntlTimeZone, string given" +int(2) +string(66) "IntlTimeZone::hasSameRules(): intltz_has_same_rules: bad arguments" +bool(false) +int(4096) +string(92) "Argument 1 passed to intltz_has_same_rules() must be an instance of IntlTimeZone, null given" +int(2) +string(74) "intltz_has_same_rules() expects parameter 1 to be IntlTimeZone, null given" +int(2) +string(61) "intltz_has_same_rules(): intltz_has_same_rules: bad arguments" +bool(false) diff --git a/ext/intl/tests/timezone_toDateTimeZone_basic.phpt b/ext/intl/tests/timezone_toDateTimeZone_basic.phpt new file mode 100644 index 0000000000..d22aa689dc --- /dev/null +++ b/ext/intl/tests/timezone_toDateTimeZone_basic.phpt @@ -0,0 +1,38 @@ +--TEST-- +IntlTimeZone::toDateTimeZone(): basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +ini_set("intl.default_locale", "nl"); +date_default_timezone_set('Europe/Lisbon'); + +function do_test(IntlTimeZone $tz, $proc = false) { + var_dump($tz->getID(), $tz->getRawOffset()); + if (!$proc) + $dtz = $tz->toDateTimeZone(); + else + $dtz = intltz_to_date_time_zone($tz); + var_dump($dtz->getName(), $dtz->getOffset(new DateTime('2012-01-01 00:00:00'))); +} + +do_test(IntlTimeZone::createTimeZone('CET')); +do_test(IntlTimeZone::createTimeZone('Europe/Amsterdam')); +do_test(IntlTimeZone::createTimeZone('GMT+0405'), true); + +--EXPECTF-- +string(3) "CET" +int(3600000) +string(13) "Europe/Berlin" +int(3600) +string(16) "Europe/Amsterdam" +int(3600000) +string(16) "Europe/Amsterdam" +int(3600) +string(%s) "GMT+04%s5" +int(14700000) +string(6) "+04:05" +int(14700) diff --git a/ext/intl/tests/timezone_toDateTimeZone_error.phpt b/ext/intl/tests/timezone_toDateTimeZone_error.phpt new file mode 100644 index 0000000000..e48d7aca92 --- /dev/null +++ b/ext/intl/tests/timezone_toDateTimeZone_error.phpt @@ -0,0 +1,38 @@ +--TEST-- +IntlTimeZone::toDateTimeZone(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$tz = IntlTimeZone::createTimeZone('Etc/Unknown'); + +var_dump($tz->toDateTimeZone('')); +try { + var_dump($tz->toDateTimeZone()); +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +var_dump(intltz_to_date_time_zone()); +var_dump(intltz_to_date_time_zone(1)); + +--EXPECTF-- + +Warning: IntlTimeZone::toDateTimeZone() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::toDateTimeZone(): intltz_to_date_time_zone: bad arguments in %s on line %d +bool(false) + +Warning: IntlTimeZone::toDateTimeZone(): intltz_to_date_time_zone: DateTimeZone constructor threw exception in %s on line %d +string(66) "DateTimeZone::__construct(): Unknown or bad timezone (Etc/Unknown)" + +Warning: intltz_to_date_time_zone() expects exactly 1 parameter, 0 given in %s on line %d + +Warning: intltz_to_date_time_zone(): intltz_to_date_time_zone: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_to_date_time_zone() must be an instance of IntlTimeZone, integer given in %s on line %d diff --git a/ext/intl/tests/timezone_useDaylightTime_basic.phpt b/ext/intl/tests/timezone_useDaylightTime_basic.phpt new file mode 100644 index 0000000000..15baf108b3 --- /dev/null +++ b/ext/intl/tests/timezone_useDaylightTime_basic.phpt @@ -0,0 +1,25 @@ +--TEST-- +IntlTimeZone::useDaylightTime: basic test +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); +$lsb = IntlTimeZone::createTimeZone('Europe/Lisbon'); +$gmt = IntlTimeZone::getGMT(); + +var_dump($lsb->useDaylightTime()); +var_dump($gmt->useDaylightTime()); + +var_dump(intltz_use_daylight_time($lsb)); +var_dump(intltz_use_daylight_time($gmt)); +?> +==DONE== +--EXPECT-- +bool(true) +bool(false) +bool(true) +bool(false) +==DONE==
\ No newline at end of file diff --git a/ext/intl/tests/timezone_useDaylightTime_error.phpt b/ext/intl/tests/timezone_useDaylightTime_error.phpt new file mode 100644 index 0000000000..aa5ca6cfca --- /dev/null +++ b/ext/intl/tests/timezone_useDaylightTime_error.phpt @@ -0,0 +1,22 @@ +--TEST-- +IntlTimeZone::useDaylightTime(): errors +--SKIPIF-- +<?php +if (!extension_loaded('intl')) + die('skip intl extension not enabled'); +--FILE-- +<?php +ini_set("intl.error_level", E_WARNING); + +$tz = IntlTimeZone::createTimeZone('Europe/Lisbon'); +var_dump($tz->useDaylightTime('foo')); +intltz_use_daylight_time(null); + +--EXPECTF-- + +Warning: IntlTimeZone::useDaylightTime() expects exactly 0 parameters, 1 given in %s on line %d + +Warning: IntlTimeZone::useDaylightTime(): intltz_use_daylight_time: bad arguments in %s on line %d +bool(false) + +Catchable fatal error: Argument 1 passed to intltz_use_daylight_time() must be an instance of IntlTimeZone, null given in %s on line %d |