Skip to content

Commit 00dca8f

Browse files
committed
update tests
1 parent 8d4abea commit 00dca8f

5 files changed

+32
-21
lines changed

ext/intl/tests/bug62017.phpt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@ intl
55
--FILE--
66
<?php
77
ini_set('intl.error_level', E_WARNING);
8-
var_dump(
8+
try {
99
datefmt_create('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "\xFF",
10-
IntlDateFormatter::GREGORIAN, 'a'));
10+
IntlDateFormatter::GREGORIAN, 'a');
11+
} catch (IntlException $e) {
12+
echo PHP_EOL."Exception: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . PHP_EOL;
13+
}
14+
1115
try {
12-
var_dump(
1316
new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon",
14-
IntlDateFormatter::GREGORIAN, "\x80"));
17+
IntlDateFormatter::GREGORIAN, "\x80");
1518
} catch (IntlException $e) {
1619
echo PHP_EOL."Exception: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . PHP_EOL;
1720
}
1821
?>
1922
--EXPECTF--
20-
Warning: datefmt_create(): datefmt_create: Time zone identifier given is not a valid UTF-8 string in %s on line %d
21-
NULL
2223

23-
Exception: IntlDateFormatter::__construct(): datefmt_create: error converting pattern to UTF-16 in %sbug62017.php on line %d
24+
Exception: datefmt_create: Time zone identifier given is not a valid UTF-8 string in %s on line %d
25+
26+
Exception: IntlDateFormatter::__construct(): datefmt_create: error converting pattern to UTF-16 in %s on line %d

ext/intl/tests/calendar_createInstance_error.phpt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ class X extends IntlTimeZone {
1010
function __construct() {}
1111
}
1212

13-
var_dump(intlcal_create_instance(new X, NULL));
13+
try {
14+
intlcal_create_instance(new X, NULL);
15+
} catch (IntlException $e) {
16+
echo $e->getMessage();
17+
}
1418
?>
15-
--EXPECTF--
16-
Warning: intlcal_create_instance(): intlcal_create_instance: passed IntlTimeZone is not properly constructed in %s on line %d
17-
NULL
19+
--EXPECT--
20+
intlcal_create_instance: passed IntlTimeZone is not properly constructed

ext/intl/tests/dateformat___construct_bad_tz_cal.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ try {
2929
}
3030
?>
3131
--EXPECTF--
32-
Exception: IntlDateFormatter::__construct(): datefmt_create: No such time zone: 'bad timezone' in %s on line %d
32+
33+
Exception: datefmt_create: No such time zone: 'bad timezone' in %s on line %d
3334

3435
Exception: 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
3536

ext/intl/tests/dateformat_set_timezone_id_icu72-1.phpt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ function ut_main()
3737

3838
$res_str .= "-----------";
3939
$res_str .= "\nTrying to set timezone_id= $timezone_id_entry";
40-
if (ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry ) !== $result) die("ut_datefmt_set_timezone_id failed");
40+
try {
41+
if (ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry ) !== $result) die("ut_datefmt_set_timezone_id failed");
42+
} catch (IntlException $e) {
43+
echo $e->getMessage() . PHP_EOL;
44+
}
4145
$timezone_id = ut_datefmt_get_timezone_id( $fmt );
4246
$res_str .= "\nAfter call to set_timezone_id : timezone_id= $timezone_id";
4347
$formatted = ut_datefmt_format( $fmt, 0);
@@ -58,9 +62,8 @@ include_once( 'ut_common.inc' );
5862
ut_run();
5963
?>
6064
--EXPECTF--
61-
Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: No such time zone: 'CN' in %sut_common.inc on line %d
62-
63-
Warning: datefmt_set_timezone(): datefmt_set_timezone: No such time zone: 'CN' in %sut_common.inc on line %d
65+
datefmt_set_timezone: No such time zone: 'CN'
66+
datefmt_set_timezone: No such time zone: 'CN'
6467

6568
After creation of the dateformatter : timezone_id= US/Pacific
6669
-----------

ext/intl/timezone/timezone_class.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <unicode/timezone.h>
2323
#include <unicode/calendar.h>
2424
#include "../intl_convertcpp.h"
25+
#include "../intl_common.h"
2526

2627
#include "../common/common_date.h"
2728

@@ -148,14 +149,14 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone,
148149
TimeZone_object *to = Z_INTL_TIMEZONE_P(zv_timezone);
149150

150151
if (to->utimezone == NULL) {
151-
zend_throw_error(NULL, "%s: passed IntlTimeZone is not "
152+
zend_throw_error(IntlException_ce_ptr, "%s: passed IntlTimeZone is not "
152153
"properly constructed", func);
153154
zval_ptr_dtor_str(&local_zv_tz);
154155
return NULL;
155156
}
156157
timeZone = to->utimezone->clone();
157158
if (UNEXPECTED(timeZone == NULL)) {
158-
zend_throw_error(NULL, "%s: could not clone TimeZone", func);
159+
zend_throw_error(IntlException_ce_ptr, "%s: could not clone TimeZone", func);
159160
zval_ptr_dtor_str(&local_zv_tz);
160161
return NULL;
161162
}
@@ -176,19 +177,19 @@ U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone,
176177
}
177178
if (intl_stringFromChar(id, Z_STRVAL_P(zv_timezone), Z_STRLEN_P(zv_timezone),
178179
&status) == FAILURE) {
179-
zend_throw_error(NULL, "%s: Time zone identifier given is not a "
180+
zend_throw_error(IntlException_ce_ptr, "%s: Time zone identifier given is not a "
180181
"valid UTF-8 string", func);
181182
zval_ptr_dtor_str(&local_zv_tz);
182183
return NULL;
183184
}
184185
timeZone = TimeZone::createTimeZone(id);
185186
if (UNEXPECTED(timeZone == NULL)) {
186-
zend_throw_error(NULL, "%s: Could not create time zone", func);
187+
zend_throw_error(IntlException_ce_ptr, "%s: Could not create time zone", func);
187188
zval_ptr_dtor_str(&local_zv_tz);
188189
return NULL;
189190
}
190191
if (*timeZone == TimeZone::getUnknown()) {
191-
zend_throw_error(NULL, "%s: No such time zone: '%s'",
192+
zend_throw_error(IntlException_ce_ptr, "%s: No such time zone: '%s'",
192193
func, Z_STRVAL_P(zv_timezone));
193194
zval_ptr_dtor_str(&local_zv_tz);
194195
delete timeZone;

0 commit comments

Comments
 (0)