php-src/ext/standard/tests/dir/chdir_basic.phpt

54 lines
1.3 KiB
Plaintext
Raw Normal View History

2008-02-26 09:34:28 +00:00
--TEST--
Test chdir() function : basic functionality
--FILE--
<?php
/* Prototype : bool chdir(string $directory)
* Description: Change the current directory
* Source code: ext/standard/dir.c
*/
/*
* Test basic functionality of chdir() with absolute and relative paths
*/
echo "*** Testing chdir() : basic functionality ***\n";
$base_dir_path = dirname(__FILE__);
2013-09-18 08:52:18 +00:00
$level1_one_dir_name = "level1_one";
$level1_one_dir_path = "$base_dir_path/$level1_one_dir_name";
2008-02-26 09:34:28 +00:00
2013-09-18 08:52:18 +00:00
$level1_two_dir_name = "level1_two";
$level1_two_dir_path = "$base_dir_path/$level1_one_dir_name/$level1_two_dir_name";
2008-02-26 09:34:28 +00:00
// create directories
2013-09-18 08:52:18 +00:00
mkdir($level1_one_dir_path);
mkdir($level1_two_dir_path);
2008-02-26 09:34:28 +00:00
echo "\n-- Testing chdir() with absolute path: --\n";
chdir($base_dir_path);
2013-09-18 08:52:18 +00:00
var_dump(chdir($level1_one_dir_path));
2008-02-26 09:34:28 +00:00
var_dump(getcwd());
echo "\n-- Testing chdir() with relative paths: --\n";
2013-09-18 08:52:18 +00:00
var_dump(chdir($level1_two_dir_name));
2008-02-26 09:34:28 +00:00
var_dump(getcwd());
?>
===DONE===
--CLEAN--
<?php
$file_path = dirname(__FILE__);
2013-09-18 08:52:18 +00:00
rmdir("$file_path/level1_one/level1_two");
rmdir("$file_path/level1_one");
2008-02-26 09:34:28 +00:00
?>
--EXPECTF--
*** Testing chdir() : basic functionality ***
-- Testing chdir() with absolute path: --
bool(true)
2013-09-18 08:52:18 +00:00
string(%d) "%slevel1_one"
2008-02-26 09:34:28 +00:00
-- Testing chdir() with relative paths: --
bool(true)
2013-09-18 08:52:18 +00:00
string(%d) "%slevel1_one%elevel1_two"
2008-02-26 09:34:28 +00:00
===DONE===