forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw specific exceptions depending on the errno in IO.
Merges #3
- Loading branch information
Showing
7 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--TEST-- | ||
Test chroot() function error conditions with throw on error declare enabled - Non-existent directory | ||
--SKIPIF-- | ||
<?php | ||
if (substr(PHP_OS, 0, 3) == 'WIN') { | ||
die('skip.. Not valid for Windows'); | ||
} | ||
|
||
if (!function_exists('chroot')) { | ||
die('skip.. chroot() not defined in this build'); | ||
} | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
declare(throw_on_error=1); | ||
|
||
echo "*** Testing chroot() : error conditions ***\n"; | ||
$directory = __DIR__ . '/idonotexist'; | ||
|
||
echo "\n-- Pass chroot() an absolute path that does not exist --\n"; | ||
try { | ||
chroot($directory); | ||
} catch (\FileNotFound $e) { | ||
echo $e->getMessage() . \PHP_EOL; | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
*** Testing chroot() : error conditions *** | ||
|
||
-- Pass chroot() an absolute path that does not exist -- | ||
File not found: "%sidonotexist" |
33 changes: 33 additions & 0 deletions
33
ext/standard/tests/dir/chroot_throw_on_error_file_in_path.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--TEST-- | ||
Test chroot() function error conditions with throw on error declare enabled - Non-existent directory | ||
--SKIPIF-- | ||
<?php | ||
if (substr(PHP_OS, 0, 3) == 'WIN') { | ||
die('skip.. Not valid for Windows'); | ||
} | ||
|
||
if (!function_exists('chroot')) { | ||
die('skip.. chroot() not defined in this build'); | ||
} | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
declare(throw_on_error=1); | ||
|
||
echo "*** Testing chroot() : error conditions ***\n"; | ||
$directory = __FILE__; | ||
|
||
echo "\n-- Pass chroot() a non directory --\n"; | ||
try { | ||
chroot($directory); | ||
} catch (\NotDirectory $e) { | ||
echo $e->getMessage() . \PHP_EOL; | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
*** Testing chroot() : error conditions *** | ||
|
||
-- Pass chroot() a non directory -- | ||
"%schroot_throw_on_error_file_in_path.php" is not a directory |