Skip to content

Commit f918755

Browse files
committed
Remove stacktraces from tests testing throwing clones
1 parent a7a2b6b commit f918755

File tree

6 files changed

+46
-44
lines changed

6 files changed

+46
-44
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/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

ext/reflection/tests/ReflectionClass_isCloneable_001.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ $obj = new ReflectionClass('xmlwriter');
4949
var_dump($obj->isCloneable());
5050
$obj = new ReflectionObject(new XMLWriter);
5151
var_dump($obj->isCloneable());
52-
$h = clone new xmlwriter;
52+
try {
53+
$h = clone new xmlwriter;
54+
} catch (Throwable $e) {
55+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
56+
}
5357

5458
?>
55-
--EXPECTF--
59+
--EXPECT--
5660
User class
5761
bool(true)
5862
bool(true)
@@ -68,8 +72,4 @@ bool(true)
6872
Internal class - XMLWriter
6973
bool(false)
7074
bool(false)
71-
72-
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class XMLWriter in %s:%d
73-
Stack trace:
74-
#0 {main}
75-
thrown in %s on line %d
75+
Error: Trying to clone an uncloneable object of class XMLWriter

tests/classes/factory_and_singleton_007.phpt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ class test {
88
}
99
}
1010

11-
$obj = new test;
12-
$clone = clone $obj;
13-
$obj = NULL;
11+
try {
12+
$obj = new test;
13+
$clone = clone $obj;
14+
} catch (Throwable $e) {
15+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
16+
}
1417

15-
echo "Done\n";
1618
?>
17-
--EXPECTF--
18-
Fatal error: Uncaught Error: Call to protected test::__clone() from global scope in %s:%d
19-
Stack trace:
20-
#0 {main}
21-
thrown in %s on line %d
19+
--EXPECT--
20+
Error: Call to protected test::__clone() from global scope

tests/classes/factory_and_singleton_008.phpt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ class test {
88
}
99
}
1010

11-
$obj = new test;
12-
$clone = clone $obj;
13-
$obj = NULL;
11+
try {
12+
$obj = new test;
13+
$clone = clone $obj;
14+
} catch (Throwable $e) {
15+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
16+
}
1417

15-
echo "Done\n";
1618
?>
17-
--EXPECTF--
18-
Fatal error: Uncaught Error: Call to private test::__clone() from global scope in %s:%d
19-
Stack trace:
20-
#0 {main}
21-
thrown in %s on line %d
19+
--EXPECT--
20+
Error: Call to private test::__clone() from global scope

0 commit comments

Comments
 (0)