Skip to content

Commit dc6e18c

Browse files
authored
Zend: applied fixers to improve test robustness (part 2/8) (#23310)
1 parent bd044a2 commit dc6e18c

85 files changed

Lines changed: 502 additions & 506 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/bug47836.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ Bug #47836 (array operator [] inconsistency when the array has PHP_INT_MAX index
66
$arr[PHP_INT_MAX] = 1;
77
try {
88
$arr[] = 2;
9-
} catch (Error $e) {
10-
echo $e->getMessage(), "\n";
9+
} catch (Throwable $e) {
10+
echo $e::class, ': ', $e->getMessage(), "\n";
1111
}
1212

1313
var_dump($arr);
1414
?>
1515
--EXPECTF--
16-
Cannot add element to the array as the next element is already occupied
16+
Error: Cannot add element to the array as the next element is already occupied
1717
array(1) {
1818
[%d]=>
1919
int(1)

Zend/tests/bug49893.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ class A {
66
function __destruct() {
77
try {
88
throw new Exception("2");
9-
} catch (Exception $e) {
10-
echo $e->getMessage() . "\n";
9+
} catch (Throwable $e) {
10+
echo $e::class, ': ', $e->getMessage(), "\n";
1111
}
1212
}
1313
}
@@ -20,10 +20,10 @@ class B {
2020
}
2121
try {
2222
$b = new B();
23-
} catch(Exception $e) {
24-
echo $e->getMessage() . "\n";
23+
} catch(Throwable $e) {
24+
echo $e::class, ': ', $e->getMessage(), "\n";
2525
}
2626
?>
2727
--EXPECT--
28-
2
29-
1
28+
Exception: 2
29+
Exception: 1

Zend/tests/bug52041.phpt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,33 @@ function foo() {
88

99
try {
1010
foo()->a = 1;
11-
} catch (Error $e) {
12-
echo $e->getMessage(), "\n";
11+
} catch (Throwable $e) {
12+
echo $e::class, ': ', $e->getMessage(), "\n";
1313
}
1414
try {
1515
foo()->a->b = 2;
16-
} catch (Error $e) {
17-
echo $e->getMessage(), "\n";
16+
} catch (Throwable $e) {
17+
echo $e::class, ': ', $e->getMessage(), "\n";
1818
}
1919
try {
2020
foo()->a++;
21-
} catch (Error $e) {
22-
echo $e->getMessage(), "\n";
21+
} catch (Throwable $e) {
22+
echo $e::class, ': ', $e->getMessage(), "\n";
2323
}
2424
try {
2525
foo()->a->b++;
26-
} catch (Error $e) {
27-
echo $e->getMessage(), "\n";
26+
} catch (Throwable $e) {
27+
echo $e::class, ': ', $e->getMessage(), "\n";
2828
}
2929
try {
3030
foo()->a += 2;
31-
} catch (Error $e) {
32-
echo $e->getMessage(), "\n";
31+
} catch (Throwable $e) {
32+
echo $e::class, ': ', $e->getMessage(), "\n";
3333
}
3434
try {
3535
foo()->a->b += 2;
36-
} catch (Error $e) {
37-
echo $e->getMessage(), "\n";
36+
} catch (Throwable $e) {
37+
echo $e::class, ': ', $e->getMessage(), "\n";
3838
}
3939

4040
foo()[0] = 1;
@@ -48,22 +48,22 @@ var_dump(foo());
4848
?>
4949
--EXPECTF--
5050
Warning: Undefined variable $x in %s on line %d
51-
Attempt to assign property "a" on null
51+
Error: Attempt to assign property "a" on null
5252

5353
Warning: Undefined variable $x in %s on line %d
54-
Attempt to modify property "a" on null
54+
Error: Attempt to modify property "a" on null
5555

5656
Warning: Undefined variable $x in %s on line %d
57-
Attempt to increment/decrement property "a" on null
57+
Error: Attempt to increment/decrement property "a" on null
5858

5959
Warning: Undefined variable $x in %s on line %d
60-
Attempt to modify property "a" on null
60+
Error: Attempt to modify property "a" on null
6161

6262
Warning: Undefined variable $x in %s on line %d
63-
Attempt to assign property "a" on null
63+
Error: Attempt to assign property "a" on null
6464

6565
Warning: Undefined variable $x in %s on line %d
66-
Attempt to modify property "a" on null
66+
Error: Attempt to modify property "a" on null
6767

6868
Warning: Undefined variable $x in %s on line %d
6969

Zend/tests/bug52355.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ var_dump($foo);
1212

1313
try {
1414
var_dump(1.0 / -0.0);
15-
} catch (\DivisionByZeroError $e) {
16-
echo $e->getMessage() . \PHP_EOL;
15+
} catch (\Throwable $e) {
16+
echo $e::class, ': ', $e->getMessage(), "\n";
1717
}
1818

1919
?>
2020
--EXPECT--
2121
float(-0)
2222
float(-0)
2323
float(-0)
24-
Division by zero
24+
DivisionByZeroError: Division by zero

Zend/tests/bug52614.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ var_dump($foo->a3);
5454

5555
try {
5656
$foo->f4()->a = 1;
57-
} catch (Error $e) {
58-
echo $e->getMessage(), "\n";
57+
} catch (Throwable $e) {
58+
echo $e::class, ': ', $e->getMessage(), "\n";
5959
}
6060
var_dump($foo->o1);
6161

@@ -76,7 +76,7 @@ array(0) {
7676
}
7777
array(0) {
7878
}
79-
Attempt to assign property "a" on null
79+
Error: Attempt to assign property "a" on null
8080
NULL
8181
object(stdClass)#3 (1) {
8282
["a"]=>

Zend/tests/bug53432.phpt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,32 @@ var_dump($str);
1818
$str = '';
1919
try {
2020
var_dump($str['foo'] = 'a');
21-
} catch (\TypeError $e) {
22-
echo $e->getMessage() . \PHP_EOL;
21+
} catch (\Throwable $e) {
22+
echo $e::class, ': ', $e->getMessage(), "\n";
2323
}
2424
var_dump($str);
2525

2626
$str = '';
2727
try {
2828
var_dump($str[] = 'a');
29-
} catch (Error $e) {
30-
echo "Error: {$e->getMessage()}\n";
29+
} catch (Throwable $e) {
30+
echo $e::class, ': ', $e->getMessage(), "\n";
3131
}
3232
var_dump($str);
3333

3434
$str = '';
3535
try {
3636
var_dump($str[0] += 1);
37-
} catch (Error $e) {
38-
echo "Error: {$e->getMessage()}\n";
37+
} catch (Throwable $e) {
38+
echo $e::class, ': ', $e->getMessage(), "\n";
3939
}
4040
var_dump($str);
4141

4242
$str = '';
4343
try {
4444
var_dump($str[0][0] = 'a');
45-
} catch (Error $e) {
46-
echo "Error: {$e->getMessage()}\n";
45+
} catch (Throwable $e) {
46+
echo $e::class, ': ', $e->getMessage(), "\n";
4747
}
4848
var_dump($str);
4949

@@ -57,7 +57,7 @@ string(6) " a"
5757
Warning: Illegal string offset -1 in %s on line %d
5858
NULL
5959
string(0) ""
60-
Cannot access offset of type string on string
60+
TypeError: Cannot access offset of type string on string
6161
string(0) ""
6262
Error: [] operator not supported for strings
6363
string(0) ""

Zend/tests/bug63882.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ $testobj2->x = $testobj2;
1111

1212
try {
1313
var_dump($testobj1 == $testobj2);
14-
} catch (Error $e) {
15-
echo $e->getMessage(), "\n";
14+
} catch (Throwable $e) {
15+
echo $e::class, ': ', $e->getMessage(), "\n";
1616
}
1717

1818
?>
1919
--EXPECT--
20-
Nesting level too deep - recursive dependency?
20+
Error: Nesting level too deep - recursive dependency?

Zend/tests/bug65784.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ function foo1() {
1616
try {
1717
$foo = foo1();
1818
var_dump($foo);
19-
} catch (Exception $e) {
19+
} catch (Throwable $e) {
2020
do {
21-
var_dump($e->getMessage());
21+
echo $e::class, ': ', $e->getMessage(), "\n";
2222
} while ($e = $e->getPrevious());
2323
}
2424

@@ -55,7 +55,7 @@ function foo3() {
5555
$bar = foo3();
5656
?>
5757
--EXPECTF--
58-
string(9) "not catch"
58+
Exception: not catch
5959
NULL
6060

6161
Fatal error: Uncaught Exception: not caught in %sbug65784.php:42

Zend/tests/bug69017.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ c1::$a1[] = 1;
1818
c1::$a2[] = 1;
1919
try {
2020
c1::$a3[] = 1;
21-
} catch (Error $e) {
22-
echo $e->getMessage(), "\n";
21+
} catch (Throwable $e) {
22+
echo $e::class, ': ', $e->getMessage(), "\n";
2323
}
2424

2525
var_dump(c1::$a1);
2626
var_dump(c1::$a2);
2727
var_dump(c1::$a3);
2828
?>
2929
--EXPECTF--
30-
Cannot add element to the array as the next element is already occupied
30+
Error: Cannot add element to the array as the next element is already occupied
3131
array(2) {
3232
[1]=>
3333
string(3) "one"

Zend/tests/bug69315.phpt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,42 @@ var_dump(function_exists("strlen"));
99
var_dump(is_callable("strlen"));
1010
try {
1111
var_dump(strlen("xxx"));
12-
} catch (Error $e) {
13-
echo $e->getMessage(), "\n";
12+
} catch (Throwable $e) {
13+
echo $e::class, ': ', $e->getMessage(), "\n";
1414
}
1515
try {
1616
var_dump(defined("PHP_VERSION"));
17-
} catch (Error $e) {
18-
echo $e->getMessage(), "\n";
17+
} catch (Throwable $e) {
18+
echo $e::class, ': ', $e->getMessage(), "\n";
1919
}
2020
try {
2121
var_dump(constant("PHP_VERSION"));
22-
} catch (Error $e) {
23-
echo $e->getMessage(), "\n";
22+
} catch (Throwable $e) {
23+
echo $e::class, ': ', $e->getMessage(), "\n";
2424
}
2525
try {
2626
var_dump(call_user_func("strlen"));
27-
} catch (Error $e) {
28-
echo $e->getMessage(), "\n";
27+
} catch (Throwable $e) {
28+
echo $e::class, ': ', $e->getMessage(), "\n";
2929
}
3030
try {
3131
var_dump(is_string("xxx"));
32-
} catch (Error $e) {
33-
echo $e->getMessage(), "\n";
32+
} catch (Throwable $e) {
33+
echo $e::class, ': ', $e->getMessage(), "\n";
3434
}
3535
try {
3636
var_dump(is_string());
37-
} catch (Error $e) {
38-
echo $e->getMessage(), "\n";
37+
} catch (Throwable $e) {
38+
echo $e::class, ': ', $e->getMessage(), "\n";
3939
}
4040

4141
?>
4242
--EXPECT--
4343
bool(false)
4444
bool(false)
45-
Call to undefined function strlen()
46-
Call to undefined function defined()
47-
Call to undefined function constant()
48-
Call to undefined function call_user_func()
49-
Call to undefined function is_string()
50-
Call to undefined function is_string()
45+
Error: Call to undefined function strlen()
46+
Error: Call to undefined function defined()
47+
Error: Call to undefined function constant()
48+
Error: Call to undefined function call_user_func()
49+
Error: Call to undefined function is_string()
50+
Error: Call to undefined function is_string()

0 commit comments

Comments
 (0)