Test symlink(), linkinfo(), link() and is_link() functions: basic functionality - link to files
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
- die('skip no symlinks on Windows');
+if (PHP_OS_FAMILY === 'Windows') {
+ require_once __DIR__ . '/windows_links/common.inc';
+ skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
}
?>
--FILE--
// create soft link
var_dump( symlink($file, $sym_linkname) );
// checking information of link with linkinfo()
- var_dump( linkinfo($sym_linkname) );
+ $linkinfo = linkinfo($sym_linkname);
+ var_dump( is_int($linkinfo) && $linkinfo !== -1 );
// checking if given file is soft link
var_dump( is_link($sym_linkname) );
// clear the cache
// creating hard link
var_dump( link($file, $linkname) );
// checking information of link with linkinfo()
- var_dump( linkinfo($linkname) );
+ $linkinfo = linkinfo($sym_linkname);
+ var_dump( is_int($linkinfo) && $linkinfo !== -1 );
// checking if given link is soft link; expected: false
var_dump( is_link($linkname) );
// clear the cache
-- Iteration 1 --
-- Testing on soft links --
bool(true)
-int(%d)
+bool(true)
bool(true)
-- Testing on hard links --
bool(true)
-int(%d)
+bool(true)
bool(false)
-- Iteration 2 --
-- Testing on soft links --
bool(true)
-int(%d)
+bool(true)
bool(true)
-- Testing on hard links --
bool(true)
-int(%d)
+bool(true)
bool(false)
Done
Test symlink(), linkinfo(), link() and is_link() functions: basic functionality - link to dirs
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
- die('skip no symlinks on Windows');
+if (PHP_OS_FAMILY === 'Windows') {
+ require_once __DIR__ . '/windows_links/common.inc';
+ skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
}
?>
--FILE--
// creating soft link to $dirname
var_dump( symlink("$file_path/$dirname", $sym_linkname) ); // this works, expected true
// gets information about soft link created to directory; expected: true
-var_dump( linkinfo($sym_linkname) );
+$linkinfo = linkinfo($sym_linkname);
+var_dump( is_int($linkinfo) && $linkinfo !== -1 );
// checks if link created is soft link; expected: true
var_dump( is_link($sym_linkname) );
// clear the cache
clearstatcache();
// deleting the links
-unlink($sym_linkname);
+if (PHP_OS_FAMILY === 'Windows') {
+ rmdir($sym_linkname);
+} else {
+ unlink($sym_linkname);
+}
echo "Done\n";
?>
-- Testing on soft links --
bool(true)
-int(%d)
+bool(true)
bool(true)
-- Testing on hard links --
Test symlink(), linkinfo(), link() and is_link() functions : error conditions - symlink & linkinfo
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
- die('skip no symlinks on Windows');
-}
if (substr(PHP_OS, 0, 3) == 'SUN') {
die('skip Not valid for Sun Solaris');
}
Test symlink(), linkinfo(), link() and is_link() functions : error conditions - link & is_link
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
- die('skip no symlinks on Windows');
+if (PHP_OS_FAMILY === 'Windows' && PHP_ZTS) {
+ die('xfail different handling of space as filename with ZTS/NTS on Windows');
}
?>
--FILE--
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - link name stored in an array/object
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
- die('skip no symlinks on Windows');
+if (PHP_OS_FAMILY === 'Windows') {
+ require_once __DIR__ . '/windows_links/common.inc';
+ skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
}
?>
--FILE--
// creating soft link
var_dump( symlink($filename, $obj->linkname) );
// check if the link exists
-var_dump( linkinfo($obj->linkname) );
+$linkinfo = linkinfo($obj->linkname);
+var_dump( is_int($linkinfo) && $linkinfo !== -1 );
// check if link is soft link
var_dump( is_link($obj->linkname) );
// delete the link created
// creating hard link
var_dump( link($filename, $obj->linkname) );
// check if the link exists
-var_dump( linkinfo($obj->linkname) );
+$linkinfo = linkinfo($obj->linkname);
+var_dump( is_int($linkinfo) && $linkinfo !== -1 );
// check if link is soft link; expected: false as the link is a hardlink
var_dump( is_link($obj->linkname) );
// delete the link created
// creating soft link
var_dump( symlink($filename, $link_arr[0]) );
// check if the link exist
-var_dump( linkinfo($link_arr[0]) );
+$linkinfo = linkinfo($link_arr[0]);
+var_dump( is_int($linkinfo) && $linkinfo !== -1 );
// check if link is soft link
var_dump( is_link($link_arr[0]) );
// delete the link created
// creating hard link
var_dump( link($filename, $link_arr[0]) );
// check if the link exist
-var_dump( linkinfo($link_arr[0]) );
+$linkinfo = linkinfo($link_arr[0]);
+var_dump( is_int($linkinfo) && $linkinfo !== -1 );
// check if link is soft link; expected: false as this is a hardlink
var_dump( is_link($link_arr[0]) );
// delete the links created
-- Working with soft links --
bool(true)
-int(%d)
+bool(true)
bool(true)
-- Working with hard links --
bool(true)
-int(%d)
+bool(true)
bool(false)
*** Testing symlink(), link(), linkinfo() and is_link() with linknames stored as members of an array ***
-- Working with soft links --
bool(true)
-int(%d)
+bool(true)
bool(true)
-- Working with hard links --
bool(true)
-int(%d)
+bool(true)
bool(false)
Done
--TEST--
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - hardlink to non-existent file
---SKIPIF--
-<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
- die('skip no symlinks on Windows');
-}
-?>
--FILE--
<?php
/* Prototype: bool symlink ( string $target, string $link );
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - access/update file through softlink
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
- die('skip no symlinks on Windows');
+if (PHP_OS_FAMILY === 'Windows') {
+ require_once __DIR__ . '/windows_links/common.inc';
+ skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
}
?>
--FILE--
--TEST--
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - access/update file through hard link
---SKIPIF--
-<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
- die('skip no symlinks on Windows');
-}
-?>
--FILE--
<?php
/* Prototype: bool symlink ( string $target, string $link );
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - work on deleted link
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
- die('skip no symlinks on Windows');
+if (PHP_OS_FAMILY === 'Windows') {
+ require_once __DIR__ . '/windows_links/common.inc';
+ skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
}
?>
--FILE--
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - link & dir perms.
--SKIPIF--
<?php
-if ( substr(PHP_OS, 0, 3) == 'WIN' ) {
- die('skip no symlinks on Windows');
-}
require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - try link to self
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
- die('skip no symlinks on Windows');
+if (PHP_OS_FAMILY === 'Windows') {
+ require_once __DIR__ . '/windows_links/common.inc';
+ skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
}
?>
--FILE--
// create another link to $dirname
var_dump( symlink($linkname, $linkname) );
// delete link
-unlink($linkname);
+if (PHP_OS_FAMILY === 'Windows') {
+ rmdir($linkname);
+} else {
+ unlink($linkname);
+}
echo "\n*** Create hard link to file and then to itself ***\n";
// create hard link to $filename
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - try link with same name in diff. dir
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
- die('skip no symlinks on Windows');
+if (PHP_OS_FAMILY === 'Windows') {
+ require_once __DIR__ . '/windows_links/common.inc';
+ skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
}
?>
--FILE--
*** Create soft link in different directory with same filename ***
-Warning: symlink(): File exists in %s on line %d
+Warning: symlink(): %rFile exists|Permission denied%r in %s on line %d
bool(false)
bool(true)
Done
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - link & lstat[dev] value
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
- die('skip no symlinks on Windows');
+if (PHP_OS_FAMILY === 'Windows') {
+ require_once __DIR__ . '/windows_links/common.inc';
+ skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
}
?>
--FILE--
// confirming that linkinfo() = lstat['dev'] , this should always match
$linkinfo = linkinfo($soft_link);
$s1 = lstat($soft_link);
-echo "linkinfo() returns : $linkinfo\n";
-echo "lstat() returns lstat['dev'] as $s1[0]\n";
+echo "linkinfo() returns integer !== -1: ";
+var_dump(is_int($linkinfo) && $linkinfo !== -1);
if( $s1[0] == $linkinfo )
echo "\nlinkinfo() value matches lstat['dev']\n";
else
// confirming that linkinfo() = lstat['dev'] , this should always match
$linkinfo = linkinfo($hard_link);
$s1 = lstat($hard_link);
-echo "linkinfo() returns : $linkinfo\n";
-echo "lstat() returns lstat['dev'] as $s1[0]\n";
+echo "linkinfo() returns integer !== -1: ";
+var_dump(is_int($linkinfo) && $linkinfo !== -1);
if( $s1[0] == $linkinfo )
echo "\nlinkinfo() value matches lstat['dev']\n";
else
// confirming that linkinfo() = lstat['dev'], this should always match
$linkinfo = linkinfo($soft_link);
$s1 = lstat($soft_link);
-echo "linkinfo() returns : $linkinfo\n";
-echo "lstat() returns lstat['dev'] as $s1[0]\n";
+echo "linkinfo() returns integer !== -1: ";
+var_dump(is_int($linkinfo) && $linkinfo !== -1);
if( $s1[0] == $linkinfo )
echo "\nlinkinfo() value matches lstat['dev']\n";
else
echo "\nWarning: linkinfo() value doesnt match lstat['dev']\n";
// delete link
-unlink($soft_link);
+if (PHP_OS_FAMILY === 'Windows') {
+ rmdir($soft_link);
+} else {
+ unlink($soft_link);
+}
echo "Done\n";
?>
--EXPECTF--
*** Checking lstat() on soft link ***
bool(true)
-linkinfo() returns : %d
-lstat() returns lstat['dev'] as %d
+linkinfo() returns integer !== -1: bool(true)
linkinfo() value matches lstat['dev']
*** Checking lstat() on hard link ***
bool(true)
-linkinfo() returns : %d
-lstat() returns lstat['dev'] as %d
+linkinfo() returns integer !== -1: bool(true)
linkinfo() value matches lstat['dev']
*** Checking lstat() on a soft link to directory ***
bool(true)
-linkinfo() returns : %d
-lstat() returns lstat['dev'] as %d
+linkinfo() returns integer !== -1: bool(true)
linkinfo() value matches lstat['dev']
Done