Skip to content

Commit a7d5a87

Browse files
committed
Zend: applied fixers to improve test robustness (part 4/8)
1 parent 98a259e commit a7d5a87

87 files changed

Lines changed: 406 additions & 411 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Zend/tests/function_arguments/variadic_argument_type_error.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ function foo($foo, int ...$bar) {}
88
try {
99
foo(1, []);
1010
} catch (TypeError $exception) {
11-
echo $exception->getMessage() . "\n";
11+
echo $exception::class, ': ', $exception->getMessage(), "\n";
1212
}
1313

1414
try {
1515
foo(1, 1, 1, []);
1616
} catch (TypeError $exception) {
17-
echo $exception->getMessage() . "\n";
17+
echo $exception::class, ': ', $exception->getMessage(), "\n";
1818
}
1919

2020
?>
2121
--EXPECTF--
22-
foo(): Argument #2 must be of type int, array given, called in %s on line %d
23-
foo(): Argument #4 must be of type int, array given, called in %s on line %d
22+
TypeError: foo(): Argument #2 must be of type int, array given, called in %s on line %d
23+
TypeError: foo(): Argument #4 must be of type int, array given, called in %s on line %d

Zend/tests/gc/bug54305.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ $methodWithArgs = new ReflectionMethod('TestClass', 'methodWithArgs');
1212
try {
1313
echo $methodWithArgs++;
1414
} catch (TypeError $e) {
15-
echo $e->getMessage(), "\n";
15+
echo $e::class, ': ', $e->getMessage(), "\n";
1616
}
1717
?>
1818
--EXPECT--
19-
Cannot increment ReflectionMethod
19+
TypeError: Cannot increment ReflectionMethod

Zend/tests/gc/bug80072.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ try {
77
$s = 'O:8:"stdClass":1:{s:1:"x";r:1;}';
88
unserialize($s) % gc_collect_cycles();
99
} catch (Error $e) {
10-
echo $e->getMessage(), "\n";
10+
echo $e::class, ': ', $e->getMessage(), "\n";
1111
}
1212

1313
$a[]=&$a == $a=&$b > gc_collect_cycles();
1414

1515
?>
1616
--EXPECT--
17-
Unsupported operand types: stdClass % int
17+
TypeError: Unsupported operand types: stdClass % int

Zend/tests/generators/bug79927.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ $generator->next();
1212
try {
1313
$generator->rewind();
1414
} catch (Exception $e) {
15-
echo $e->getMessage(), "\n";
15+
echo $e::class, ': ', $e->getMessage(), "\n";
1616
}
1717
echo $generator->current(), "\n";
1818

@@ -26,6 +26,6 @@ echo $generator2->current(), "\n";
2626

2727
?>
2828
--EXPECT--
29-
Cannot rewind a generator that was already run
29+
Exception: Cannot rewind a generator that was already run
3030
3
3131
4

Zend/tests/generators/dynamic_properties.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ $gen = gen();
1111
try {
1212
$gen->prop = new stdClass;
1313
} catch (Error $e) {
14-
echo $e->getMessage(), "\n";
14+
echo $e::class, ': ', $e->getMessage(), "\n";
1515
}
1616

1717
?>
1818
--EXPECT--
19-
Cannot create dynamic property Generator::$prop
19+
Error: Cannot create dynamic property Generator::$prop

Zend/tests/generators/errors/count_error.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ $gen = gen();
1010
try {
1111
count($gen);
1212
} catch (\TypeError $e) {
13-
echo $e->getMessage(), PHP_EOL;
13+
echo $e::class, ': ', $e->getMessage(), "\n";
1414
}
1515

1616
?>
1717
--EXPECT--
18-
count(): Argument #1 ($value) must be of type Countable|array, Generator given
18+
TypeError: count(): Argument #1 ($value) must be of type Countable|array, Generator given

Zend/tests/generators/errors/resume_running_generator_error.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function gen() {
88
try {
99
$gen->next();
1010
} catch (Error $e) {
11-
echo "\nException: " . $e->getMessage() . "\n";
11+
echo $e::class, ': ', $e->getMessage(), "\n";
1212
}
1313
$gen->next();
1414
}
@@ -19,7 +19,7 @@ $gen->next();
1919

2020
?>
2121
--EXPECTF--
22-
Exception: Cannot resume an already running generator
22+
Error: Cannot resume an already running generator
2323

2424
Fatal error: Uncaught Error: Cannot resume an already running generator in %s:%d
2525
Stack trace:

Zend/tests/generators/errors/resume_running_generator_error_002.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ $gen = gen();
1010
try {
1111
$gen->send($gen);
1212
} catch (Throwable $e) {
13-
echo $e->getMessage() . "\n";
13+
echo $e::class, ': ', $e->getMessage(), "\n";
1414
}
1515
?>
1616
--EXPECT--
17-
Cannot resume an already running generator
17+
Error: Cannot resume an already running generator

Zend/tests/generators/generator_throwing_during_function_call.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ var_dump($gen->current());
2020
try {
2121
$gen->next();
2222
} catch (Exception $e) {
23-
echo 'Caught exception with message "', $e->getMessage(), '"', "\n";
23+
echo $e::class, ': ', $e->getMessage(), "\n";
2424
}
2525

2626
var_dump($gen->current());
2727

2828
?>
2929
--EXPECT--
3030
string(3) "foo"
31-
Caught exception with message "test"
31+
Exception: test
3232
NULL

Zend/tests/generators/generator_throwing_exception.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ var_dump($gen->current());
1616
try {
1717
$gen->next();
1818
} catch (Exception $e) {
19-
echo 'Caught exception with message "', $e->getMessage(), '"', "\n";
19+
echo $e::class, ': ', $e->getMessage(), "\n";
2020
}
2121

2222
var_dump($gen->current());
2323

2424
?>
2525
--EXPECT--
2626
string(3) "foo"
27-
Caught exception with message "test"
27+
Exception: test
2828
NULL

0 commit comments

Comments
 (0)