Skip to content

Commit bb5267e

Browse files
committed
Remove stacktraces from tests testing throwing clones
1 parent 36891a6 commit bb5267e

File tree

15 files changed

+115
-111
lines changed

15 files changed

+115
-111
lines changed

Zend/tests/generators/clone.phpt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ function gen() {
77
yield;
88
}
99

10-
$gen = gen();
11-
clone $gen;
10+
11+
try {
12+
$gen = gen();
13+
clone $gen;
14+
} catch (Throwable $e) {
15+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
16+
}
1217

1318
?>
14-
--EXPECTF--
15-
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class Generator in %s:%d
16-
Stack trace:
17-
#0 {main}
18-
thrown in %s on line %d
19+
--EXPECT--
20+
Error: Trying to clone an uncloneable object of class Generator

ext/dom/tests/modern/token_list/clone.phpt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ dom
77

88
$dom = DOM\XMLDocument::createFromString('<root class="a b c"><child/></root>');
99
$element = $dom->documentElement;
10-
clone $element->classList;
10+
try {
11+
clone $element->classList;
12+
} catch (Throwable $e) {
13+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
14+
}
1115

1216
?>
13-
--EXPECTF--
14-
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class Dom\TokenList in %s:%d
15-
Stack trace:
16-
#0 {main}
17-
thrown in %s on line %d
17+
--EXPECT--
18+
Error: Trying to clone an uncloneable object of class Dom\TokenList

ext/gd/tests/gdimage_prevent_cloning.phpt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ gd
55
--FILE--
66
<?php
77

8+
try {
89
$img_src = imagecreatetruecolor(32, 32);
910
$img_dst = clone $img_src;
11+
} catch (Throwable $e) {
12+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
13+
}
1014

1115
?>
12-
--EXPECTF--
13-
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class GdImage in %s:%d
14-
Stack trace:
15-
#0 {main}
16-
thrown in %s on line %d
16+
--EXPECT--
17+
Error: Trying to clone an uncloneable object of class GdImage

ext/mysqli/tests/mysqli_driver_unclonable.phpt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ Trying to clone mysqli_driver object
44
mysqli
55
--FILE--
66
<?php
7+
8+
try {
79
$driver = new mysqli_driver;
810
$driver_clone = clone $driver;
9-
print "done!";
11+
} catch (Throwable $e) {
12+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
13+
}
14+
1015
?>
11-
--EXPECTF--
12-
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_driver in %s:%d
13-
Stack trace:
14-
#0 {main}
15-
thrown in %s on line %d
16+
--EXPECT--
17+
Error: Trying to clone an uncloneable object of class mysqli_driver

ext/mysqli/tests/mysqli_result_unclonable.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ require_once 'skipifconnectfailure.inc';
1717
if (!($res = mysqli_query($link, "SELECT 'good' AS morning")))
1818
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
1919

20-
$res_clone = clone $res;
21-
print "done!";
20+
try {
21+
$res_clone = clone $res;
22+
} catch (Throwable $e) {
23+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
24+
}
2225
?>
23-
--EXPECTF--
24-
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_result in %s:%d
25-
Stack trace:
26-
#0 {main}
27-
thrown in %s on line %d
26+
--EXPECT--
27+
Error: Trying to clone an uncloneable object of class mysqli_result

ext/mysqli/tests/mysqli_stmt_unclonable.phpt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ require_once 'skipifconnectfailure.inc';
1717
if (!$stmt = mysqli_stmt_init($link))
1818
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
1919

20-
/* no, still bails out */
21-
$stmt_clone = clone $stmt;
22-
print "done!";
20+
try {
21+
$stmt_clone = clone $stmt;
22+
} catch (Throwable $e) {
23+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
24+
}
2325
?>
24-
--EXPECTF--
25-
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_stmt in %s:%d
26-
Stack trace:
27-
#0 {main}
28-
thrown in %s on line %d
26+
--EXPECT--
27+
Error: Trying to clone an uncloneable object of class mysqli_stmt

ext/mysqli/tests/mysqli_unclonable.phpt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ require_once 'skipifconnectfailure.inc';
1414
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
1515
$host, $user, $db, $port, $socket);
1616

17-
$link_clone = clone $link;
18-
mysqli_close($link);
17+
try {
18+
$link_clone = clone $link;
19+
} catch (Throwable $e) {
20+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
21+
}
1922

20-
print "done!";
2123
?>
22-
--EXPECTF--
23-
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli in %s:%d
24-
Stack trace:
25-
#0 {main}
26-
thrown in %s on line %d
24+
--EXPECT--
25+
Error: Trying to clone an uncloneable object of class mysqli

ext/pdo/tests/bug_77849.phpt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE_
1515
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
1616

1717
$db = PDOTest::factory();
18-
$db2 = clone $db;
18+
try {
19+
$db2 = clone $db;
20+
} catch (Throwable $e) {
21+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
22+
}
1923
?>
20-
--EXPECTF--
21-
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class PDO in %s
22-
Stack trace:
23-
#0 {main}
24-
thrown in %s on line %d
24+
--EXPECT--
25+
Error: Trying to clone an uncloneable object of class PDO

ext/pdo/tests/bug_77849_2.phpt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ PDO Common: Bug #77849 (inconsistent state of cloned statament object)
44
pdo
55
--FILE--
66
<?php
7-
$stmt = new PDOStatement();
87

9-
clone $stmt;
10-
?>
11-
--EXPECTF--
12-
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class PDOStatement in %s:4
13-
Stack trace:
14-
#0 {main}
15-
thrown in %s on line 4
8+
try {
9+
$stmt = new PDOStatement();
10+
clone $stmt;
11+
} catch (Throwable $e) {
12+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
13+
}
1614

15+
?>
16+
--EXPECT--
17+
Error: Trying to clone an uncloneable object of class PDOStatement

ext/reflection/tests/ReflectionClass_CannotClone_basic.phpt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ TestFest PHP|Tek
66
--FILE--
77
<?php
88
$rc = new ReflectionClass("stdClass");
9-
$rc2 = clone($rc);
9+
try {
10+
$rc2 = clone($rc);
11+
} catch (Throwable $e) {
12+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
13+
}
1014
?>
11-
--EXPECTF--
12-
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class ReflectionClass in %s:%d
13-
Stack trace:
14-
#0 {main}
15-
thrown in %s on line %d
15+
--EXPECT--
16+
Error: Trying to clone an uncloneable object of class ReflectionClass

0 commit comments

Comments
 (0)