Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/require-missing-php5.phpt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
--TEST--
Include and require of nonexistent files
Include and require of nonexistent files (PHP < 8.0)

--SKIPIF--
<?php
// PHP 8.0 changed require failing from a fatal error to a thrown exception. That's too much of a difference
// to handle easily in EXPECTF, easier to just copy the file.
if (!version_compare(PHP_VERSION, "8.0", "<")) {
echo "skip PHP 5 version of the test in PHP 8+";
if (version_compare(PHP_VERSION_ID, "80000", ">=")) {
echo "skip PHP 7 version of the test on PHP 8+";
}
--FILE--
<?php
Expand Down
49 changes: 49 additions & 0 deletions tests/require-missing-phpgte86.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
--TEST--
Include and require of nonexistent files (PHP >= 8.6)

--SKIPIF--
<?php
// PHP 8.6 changed the error message format significantly. That's too much of a difference
// to handle easily in EXPECTF, easier to just copy the file.
if (version_compare(PHP_VERSION_ID, "80600", "<")) {
echo "skip PHP 8.6+ version of the test on PHP <8.6";
}
--FILE--
<?php

ini_set('zend.assertions', 1);
error_reporting(E_ALL);

require __DIR__ . "/../Patchwork.php";

echo "Including missing file...\n";
include __DIR__ . "/includes/does-not-exist.php";
echo "Good, it did not throw/exit.\n\n";

echo "Requiring missing file...\n";
require __DIR__ . "/includes/does-not-exist.php";
echo "It did not throw/exit. This is wrong.\n";

?>
===DONE===

--EXPECTF--
Including missing file...

Warning: fopen('%s', 'r', true): Failed to open stream: No such file or directory in %s%esrc%eCodeManipulation%eStream.php on line %d

Warning: include('%s'): Failed to open stream: "Patchwork\CodeManipulation\Stream::stream_open" call failed in %s on line 9

Warning: include('%s'): Failed opening '%s/includes/does-not-exist.php' for inclusion (include_path='%s') in %s on line 9
Good, it did not throw/exit.

Requiring missing file...

Warning: fopen('%s', 'r', true): Failed to open stream: No such file or directory in %s%esrc%eCodeManipulation%eStream.php on line %d

Warning: require('%s'): Failed to open stream: "Patchwork\CodeManipulation\Stream::stream_open" call failed in %s on line 13

Fatal error: Uncaught Error: Failed opening required '%s/includes/does-not-exist.php' (include_path='%s') in %s:13
Stack trace:
#0 {main}
thrown in %s on line 13
9 changes: 6 additions & 3 deletions tests/require-missing.phpt
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
--TEST--
Include and require of nonexistent files
Include and require of nonexistent files (PHP 8.0-8.5)

--SKIPIF--
<?php
// PHP 8.0 changed require failing from a fatal error to a thrown exception. That's too much of a difference
// to handle easily in EXPECTF, easier to just copy the file.
if (!version_compare(PHP_VERSION, "8.0", ">=")) {
echo "skip PHP 8+ version of the test in PHP <8";
if (version_compare(PHP_VERSION_ID, "80000", "<")) {
echo "skip PHP 8.0-8.5 version of the test on PHP <8";
}
if (version_compare(PHP_VERSION_ID, "80600", ">=")) {
echo "skip PHP 8.0-8.5 version of the test on PHP >=8.6";
}
--FILE--
<?php
Expand Down
Loading