mirror of
https://github.com/php/php-src.git
synced 2024-09-24 03:17:26 +00:00
- New tests for getcwd() function
This commit is contained in:
parent
49b8c820e6
commit
f30035ea79
39
ext/standard/tests/dir/getcwd_basic.phpt
Normal file
39
ext/standard/tests/dir/getcwd_basic.phpt
Normal file
@ -0,0 +1,39 @@
|
||||
--TEST--
|
||||
Test getcwd() function : basic functionality
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : mixed getcwd(void)
|
||||
* Description: Gets the current directory
|
||||
* Source code: ext/standard/dir.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test basic functionality of getcwd()
|
||||
*/
|
||||
|
||||
echo "*** Testing getcwd() : basic functionality ***\n";
|
||||
|
||||
//create temporary directory for test, removed in CLEAN section
|
||||
$directory = dirname(__FILE__) . "/getcwd_basic";
|
||||
mkdir($directory);
|
||||
|
||||
var_dump(getcwd());
|
||||
chdir($directory);
|
||||
var_dump(getcwd());
|
||||
?>
|
||||
===DONE===
|
||||
--CLEAN--
|
||||
<?php
|
||||
$directory = dirname(__FILE__) . "/getcwd_basic";
|
||||
rmdir($directory);
|
||||
?>
|
||||
--EXPECTF--
|
||||
*** Testing getcwd() : basic functionality ***
|
||||
string(%d) "%s"
|
||||
string(%d) "%s%egetcwd_basic"
|
||||
===DONE===
|
||||
--UEXPECTF--
|
||||
*** Testing getcwd() : basic functionality ***
|
||||
unicode(%d) "%s"
|
||||
unicode(%d) "%s%egetcwd_basic"
|
||||
===DONE===
|
37
ext/standard/tests/dir/getcwd_error.phpt
Normal file
37
ext/standard/tests/dir/getcwd_error.phpt
Normal file
@ -0,0 +1,37 @@
|
||||
--TEST--
|
||||
Test getcwd() function : error conditions - Incorrect number of arguments
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : mixed getcwd(void)
|
||||
* Description: Gets the current directory
|
||||
* Source code: ext/standard/dir.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pass incorrect number of arguments to getcwd() to test behaviour
|
||||
*/
|
||||
|
||||
echo "*** Testing getcwd() : error conditions ***\n";
|
||||
|
||||
// One argument
|
||||
echo "\n-- Testing getcwd() function with one argument --\n";
|
||||
$extra_arg = 10;
|
||||
var_dump( getcwd($extra_arg) );
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing getcwd() : error conditions ***
|
||||
|
||||
-- Testing getcwd() function with one argument --
|
||||
|
||||
Warning: getcwd() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
NULL
|
||||
===DONE===
|
||||
--UEXPECTF--
|
||||
*** Testing getcwd() : error conditions ***
|
||||
|
||||
-- Testing getcwd() function with one argument --
|
||||
|
||||
Warning: getcwd() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
NULL
|
||||
===DONE===
|
Loading…
Reference in New Issue
Block a user