diff options
author | Tomas V.V.Cox <cox@php.net> | 2002-02-10 17:12:43 +0000 |
---|---|---|
committer | Tomas V.V.Cox <cox@php.net> | 2002-02-10 17:12:43 +0000 |
commit | 0dd3010501daf0dcb4565e8d43ea47edc659635c (patch) | |
tree | 0fcaa0bf956c066548caee4569e4bd140dbf414b | |
parent | d966015b5237955386722c120140160d37de6d78 (diff) | |
download | php-git-0dd3010501daf0dcb4565e8d43ea47edc659635c.tar.gz |
test suite for the System class
-rw-r--r-- | pear/tests/pear_system.phpt | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/pear/tests/pear_system.phpt b/pear/tests/pear_system.phpt new file mode 100644 index 0000000000..3c8e3371b5 --- /dev/null +++ b/pear/tests/pear_system.phpt @@ -0,0 +1,95 @@ +--TEST-- +System commands tests +--SKIPIF-- +--FILE-- +<?php +error_reporting(E_ALL); +require_once 'System.php'; + +$sep = DIRECTORY_SEPARATOR; + +/******************* + mkDir +********************/ + +// Multiple directory creation +System::mkDir('dir1 dir2 dir3'); +if (!@is_dir('dir1') || !@is_dir('dir2') || !@is_dir('dir3')) { + print "System::mkDir('dir1 dir2 dir3'); failed\n"; +} + +// Parent creation without "-p" fail +if (@System::mkDir("dir4{$sep}dir3")) { + print "System::mkDir(\"dir4{$sep}dir3\") did not failed\n"; +} + +// Create a directory which is a file already fail +touch('file4'); +$res = @System::mkDir('file4 dir5'); +if ($res) { + print "System::mkDir('file4 dir5') did not failed\n"; +} +if (!@is_dir('dir5')) { + print "System::mkDir('file4 dir5') failed\n"; +} + +// Parent directory creation +System::mkDir("-p dir2{$sep}dir21 dir6{$sep}dir61{$sep}dir611"); +if (!@is_dir("dir2{$sep}dir21") || !@is_dir("dir6{$sep}dir61{$sep}dir611")) { + print "System::mkDir(\"-p dir2{$sep}dir21 dir6{$sep}dir61{$sep}dir611\")); failed\n"; +} + +/******************* + mkTemp +********************/ + +// Create a temporal file with "tst" as filename prefix +$tmpfile = System::mkTemp('tst'); +$tmpenv = System::tmpDir(); +if (!@is_file($tmpfile) || !ereg("^$tmpenv{$sep}tst", $tmpfile)) { + print "System::mkTemp('tst') failed\n"; +} + +// Create a temporal dir in "dir1" with default prefix "tmp" +$tmpdir = System::mkTemp('-d -t dir1'); +if (!@is_dir($tmpdir) || !ereg("^dir1{$sep}tmp", $tmpdir)) { + print "System::mkTemp('-d -t dir1') failed\n"; +} + +/******************* + rm +********************/ + +// Try to delete a dir without "-r" option +if (@System::rm('dir1')) { + print "System::rm('dir1') did not fail\n"; +} + +// Multiple and recursive delete +$del = "dir1 dir2 dir3 file4 dir5 dir6"; +if (!@System::rm("-r $del")) { + print "System::rm(\"-r $del\") failed\n"; +} + +/******************* + type +********************/ + +if (OS_UNIX) { + if (System::type('ls') != '/bin/ls') { + print "System::type('ls') failed\n"; + } + if (System::type('i_am_not_a_command')) { + print "System::type('i_am_not_a_command') did not failed\n"; + } +} // XXX Windows test + +/******************* + cat +********************/ +// Missing tests yet + +print "end\n"; +?> +--EXPECT-- +end |