Annotation of embedaddon/php/ext/standard/tests/file/filetype_variation.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test filetype() function: Variations
3: --SKIPIF--
4: <?php
5: if (substr(PHP_OS, 0, 3) == 'WIN') {
6: die('skip no link()/symlink() on Windows');
7: }
8: if (!function_exists("posix_mkfifo")) {
9: die("skip no posix_mkfifo()");
10: }
11: ?>
12: --FILE--
13: <?php
14: /*
15: Prototype: string filetype ( string $filename );
16: Description: Returns the type of the file. Possible values are fifo, char,
17: dir, block, link, file, and unknown.
18: */
19:
20: echo "*** Testing filetype() with various types ***\n";
21: $file_path = dirname(__FILE__);
22: $file1 = $file_path."/filetype1_variation.tmp";
23: $file2 = $file_path."/filetype2_variation.tmp";
24: $file3 = $file_path."/filetype3_variation.tmp";
25: $link1 = $file_path."/filetype1_variation_link.tmp";
26: $link2 = $file_path."/filetype2_variation_link.tmp";
27:
28: fclose( fopen($file1, "w") );
29: fclose( fopen($file2, "w") );
30:
31: echo "-- Checking with files --\n";
32: print( filetype($file1) )."\n";
33: print( filetype($file2) )."\n";
34: clearstatcache();
35:
36: echo "-- Checking with links: hardlink --\n";
37: link( $file1, $link1);
38: print( filetype($link1 ) )."\n";
39:
40: echo "-- Checking with links: symlink --\n";
41: symlink( $file2, $link2);
42: print( filetype($link2) )."\n";
43:
44: unlink($link1);
45: unlink($link2);
46: unlink($file1);
47: unlink($file2);
48:
49: echo "-- Checking with directory --\n";
50: mkdir("$file_path/filetype_variation");
51: print( filetype("$file_path/filetype_variation") )."\n";
52: rmdir( "$file_path/filetype_variation" );
53:
54: echo "-- Checking with fifo --\n";
55: posix_mkfifo( $file3, 0755);
56: print( filetype( $file3) )."\n";
57: unlink($file3);
58:
59: /* Checking with block in file */
60: /* To test this PEAR package should be installed */
61:
62: echo "\n*** Done ***\n";
63: ?>
64: --EXPECTF--
65: *** Testing filetype() with various types ***
66: -- Checking with files --
67: file
68: file
69: -- Checking with links: hardlink --
70: file
71: -- Checking with links: symlink --
72: link
73: -- Checking with directory --
74: dir
75: -- Checking with fifo --
76: fifo
77:
78: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>