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