mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
tree-wide: Remove stacktraces from tests testing throwing clones (#18748)
This is in preparation for the possible future transformation of `clone` into a function call, but also meaningful on its own, since the purpose of the tests is not to test the stack trace generation, but rather that an exception was thrown. It also cleans up some unreachable code in the tests.
This commit is contained in:
parent
0a8961a0e2
commit
4c5a6b0e8d
15 changed files with 115 additions and 111 deletions
|
@ -7,12 +7,14 @@ function gen() {
|
||||||
yield;
|
yield;
|
||||||
}
|
}
|
||||||
|
|
||||||
$gen = gen();
|
|
||||||
clone $gen;
|
try {
|
||||||
|
$gen = gen();
|
||||||
|
clone $gen;
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class Generator in %s:%d
|
Error: Trying to clone an uncloneable object of class Generator
|
||||||
Stack trace:
|
|
||||||
#0 {main}
|
|
||||||
thrown in %s on line %d
|
|
||||||
|
|
|
@ -7,11 +7,12 @@ dom
|
||||||
|
|
||||||
$dom = DOM\XMLDocument::createFromString('<root class="a b c"><child/></root>');
|
$dom = DOM\XMLDocument::createFromString('<root class="a b c"><child/></root>');
|
||||||
$element = $dom->documentElement;
|
$element = $dom->documentElement;
|
||||||
clone $element->classList;
|
try {
|
||||||
|
clone $element->classList;
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class Dom\TokenList in %s:%d
|
Error: Trying to clone an uncloneable object of class Dom\TokenList
|
||||||
Stack trace:
|
|
||||||
#0 {main}
|
|
||||||
thrown in %s on line %d
|
|
||||||
|
|
|
@ -5,12 +5,13 @@ gd
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
try {
|
||||||
$img_src = imagecreatetruecolor(32, 32);
|
$img_src = imagecreatetruecolor(32, 32);
|
||||||
$img_dst = clone $img_src;
|
$img_dst = clone $img_src;
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class GdImage in %s:%d
|
Error: Trying to clone an uncloneable object of class GdImage
|
||||||
Stack trace:
|
|
||||||
#0 {main}
|
|
||||||
thrown in %s on line %d
|
|
||||||
|
|
|
@ -4,12 +4,14 @@ Trying to clone mysqli_driver object
|
||||||
mysqli
|
mysqli
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
try {
|
||||||
$driver = new mysqli_driver;
|
$driver = new mysqli_driver;
|
||||||
$driver_clone = clone $driver;
|
$driver_clone = clone $driver;
|
||||||
print "done!";
|
} catch (Throwable $e) {
|
||||||
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_driver in %s:%d
|
Error: Trying to clone an uncloneable object of class mysqli_driver
|
||||||
Stack trace:
|
|
||||||
#0 {main}
|
|
||||||
thrown in %s on line %d
|
|
||||||
|
|
|
@ -17,11 +17,11 @@ require_once 'skipifconnectfailure.inc';
|
||||||
if (!($res = mysqli_query($link, "SELECT 'good' AS morning")))
|
if (!($res = mysqli_query($link, "SELECT 'good' AS morning")))
|
||||||
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||||
|
|
||||||
$res_clone = clone $res;
|
try {
|
||||||
print "done!";
|
$res_clone = clone $res;
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_result in %s:%d
|
Error: Trying to clone an uncloneable object of class mysqli_result
|
||||||
Stack trace:
|
|
||||||
#0 {main}
|
|
||||||
thrown in %s on line %d
|
|
||||||
|
|
|
@ -17,12 +17,11 @@ require_once 'skipifconnectfailure.inc';
|
||||||
if (!$stmt = mysqli_stmt_init($link))
|
if (!$stmt = mysqli_stmt_init($link))
|
||||||
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
|
||||||
|
|
||||||
/* no, still bails out */
|
try {
|
||||||
$stmt_clone = clone $stmt;
|
$stmt_clone = clone $stmt;
|
||||||
print "done!";
|
} catch (Throwable $e) {
|
||||||
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli_stmt in %s:%d
|
Error: Trying to clone an uncloneable object of class mysqli_stmt
|
||||||
Stack trace:
|
|
||||||
#0 {main}
|
|
||||||
thrown in %s on line %d
|
|
||||||
|
|
|
@ -14,13 +14,12 @@ require_once 'skipifconnectfailure.inc';
|
||||||
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
|
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
|
||||||
$host, $user, $db, $port, $socket);
|
$host, $user, $db, $port, $socket);
|
||||||
|
|
||||||
$link_clone = clone $link;
|
try {
|
||||||
mysqli_close($link);
|
$link_clone = clone $link;
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
print "done!";
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class mysqli in %s:%d
|
Error: Trying to clone an uncloneable object of class mysqli
|
||||||
Stack trace:
|
|
||||||
#0 {main}
|
|
||||||
thrown in %s on line %d
|
|
||||||
|
|
|
@ -15,10 +15,11 @@ if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE_
|
||||||
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
|
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
|
||||||
|
|
||||||
$db = PDOTest::factory();
|
$db = PDOTest::factory();
|
||||||
$db2 = clone $db;
|
try {
|
||||||
|
$db2 = clone $db;
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class PDO in %s
|
Error: Trying to clone an uncloneable object of class PDO
|
||||||
Stack trace:
|
|
||||||
#0 {main}
|
|
||||||
thrown in %s on line %d
|
|
||||||
|
|
|
@ -4,13 +4,14 @@ PDO Common: Bug #77849 (inconsistent state of cloned statament object)
|
||||||
pdo
|
pdo
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
$stmt = new PDOStatement();
|
|
||||||
|
|
||||||
clone $stmt;
|
try {
|
||||||
|
$stmt = new PDOStatement();
|
||||||
|
clone $stmt;
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class PDOStatement in %s:4
|
Error: Trying to clone an uncloneable object of class PDOStatement
|
||||||
Stack trace:
|
|
||||||
#0 {main}
|
|
||||||
thrown in %s on line 4
|
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,11 @@ TestFest PHP|Tek
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
$rc = new ReflectionClass("stdClass");
|
$rc = new ReflectionClass("stdClass");
|
||||||
$rc2 = clone($rc);
|
try {
|
||||||
|
$rc2 = clone($rc);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class ReflectionClass in %s:%d
|
Error: Trying to clone an uncloneable object of class ReflectionClass
|
||||||
Stack trace:
|
|
||||||
#0 {main}
|
|
||||||
thrown in %s on line %d
|
|
||||||
|
|
|
@ -49,10 +49,14 @@ $obj = new ReflectionClass('xmlwriter');
|
||||||
var_dump($obj->isCloneable());
|
var_dump($obj->isCloneable());
|
||||||
$obj = new ReflectionObject(new XMLWriter);
|
$obj = new ReflectionObject(new XMLWriter);
|
||||||
var_dump($obj->isCloneable());
|
var_dump($obj->isCloneable());
|
||||||
$h = clone new xmlwriter;
|
try {
|
||||||
|
$h = clone new xmlwriter;
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
User class
|
User class
|
||||||
bool(true)
|
bool(true)
|
||||||
bool(true)
|
bool(true)
|
||||||
|
@ -68,8 +72,4 @@ bool(true)
|
||||||
Internal class - XMLWriter
|
Internal class - XMLWriter
|
||||||
bool(false)
|
bool(false)
|
||||||
bool(false)
|
bool(false)
|
||||||
|
Error: Trying to clone an uncloneable object of class XMLWriter
|
||||||
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class XMLWriter in %s:%d
|
|
||||||
Stack trace:
|
|
||||||
#0 {main}
|
|
||||||
thrown in %s on line %d
|
|
||||||
|
|
|
@ -5,13 +5,13 @@ xml
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$parser = xml_parser_create();
|
try {
|
||||||
clone $parser;
|
$parser = xml_parser_create();
|
||||||
|
clone $parser;
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
===DONE===
|
--EXPECT--
|
||||||
--EXPECTF--
|
Error: Trying to clone an uncloneable object of class XMLParser
|
||||||
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class XMLParser in %s:%d
|
|
||||||
Stack trace:
|
|
||||||
#0 {main}
|
|
||||||
thrown in %s on line %d
|
|
||||||
|
|
|
@ -4,20 +4,19 @@ Bug #51936 (Crash with clone XMLReader)
|
||||||
xmlreader
|
xmlreader
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
echo "Test\n";
|
|
||||||
|
|
||||||
$xmlreader = new XMLReader();
|
$xmlreader = new XMLReader();
|
||||||
$xmlreader->xml("<a><b/></a>");
|
$xmlreader->xml("<a><b/></a>");
|
||||||
|
|
||||||
$xmlreader->next();
|
$xmlreader->next();
|
||||||
$xmlreader2 = clone $xmlreader;
|
|
||||||
$xmlreader2->next();
|
|
||||||
?>
|
|
||||||
Done
|
|
||||||
--EXPECTF--
|
|
||||||
Test
|
|
||||||
|
|
||||||
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class XMLReader in %s:%d
|
try {
|
||||||
Stack trace:
|
$xmlreader2 = clone $xmlreader;
|
||||||
#0 {main}
|
$xmlreader2->next();
|
||||||
thrown in %s on line %d
|
} catch (Throwable $e) {
|
||||||
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
Error: Trying to clone an uncloneable object of class XMLReader
|
||||||
|
|
|
@ -8,14 +8,13 @@ class test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$obj = new test;
|
try {
|
||||||
$clone = clone $obj;
|
$obj = new test;
|
||||||
$obj = NULL;
|
$clone = clone $obj;
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
echo "Done\n";
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
Fatal error: Uncaught Error: Call to protected test::__clone() from global scope in %s:%d
|
Error: Call to protected test::__clone() from global scope
|
||||||
Stack trace:
|
|
||||||
#0 {main}
|
|
||||||
thrown in %s on line %d
|
|
||||||
|
|
|
@ -8,14 +8,13 @@ class test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$obj = new test;
|
try {
|
||||||
$clone = clone $obj;
|
$obj = new test;
|
||||||
$obj = NULL;
|
$clone = clone $obj;
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
echo "Done\n";
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
Fatal error: Uncaught Error: Call to private test::__clone() from global scope in %s:%d
|
Error: Call to private test::__clone() from global scope
|
||||||
Stack trace:
|
|
||||||
#0 {main}
|
|
||||||
thrown in %s on line %d
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue