Skip to content

Commit bdcda50

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Enable symlink_link_linkinfo_is_link_* tests on Windows
2 parents bc68f10 + 68293b1 commit bdcda50

13 files changed

+74
-68
lines changed

ext/standard/tests/file/symlink_link_linkinfo_is_link_basic1.phpt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Test symlink(), linkinfo(), link() and is_link() functions: basic functionality - link to files
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
5+
if (PHP_OS_FAMILY === 'Windows') {
6+
require_once __DIR__ . '/windows_links/common.inc';
7+
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
78
}
89
?>
910
--FILE--
@@ -45,7 +46,8 @@ foreach($files as $file) {
4546
// create soft link
4647
var_dump( symlink($file, $sym_linkname) );
4748
// checking information of link with linkinfo()
48-
var_dump( linkinfo($sym_linkname) );
49+
$linkinfo = linkinfo($sym_linkname);
50+
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
4951
// checking if given file is soft link
5052
var_dump( is_link($sym_linkname) );
5153
// clear the cache
@@ -56,7 +58,8 @@ foreach($files as $file) {
5658
// creating hard link
5759
var_dump( link($file, $linkname) );
5860
// checking information of link with linkinfo()
59-
var_dump( linkinfo($linkname) );
61+
$linkinfo = linkinfo($sym_linkname);
62+
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
6063
// checking if given link is soft link; expected: false
6164
var_dump( is_link($linkname) );
6265
// clear the cache
@@ -82,20 +85,20 @@ rmdir($dirname);
8285
-- Iteration 1 --
8386
-- Testing on soft links --
8487
bool(true)
85-
int(%d)
88+
bool(true)
8689
bool(true)
8790
-- Testing on hard links --
8891
bool(true)
89-
int(%d)
92+
bool(true)
9093
bool(false)
9194

9295
-- Iteration 2 --
9396
-- Testing on soft links --
9497
bool(true)
95-
int(%d)
98+
bool(true)
9699
bool(true)
97100
-- Testing on hard links --
98101
bool(true)
99-
int(%d)
102+
bool(true)
100103
bool(false)
101104
Done

ext/standard/tests/file/symlink_link_linkinfo_is_link_basic2.phpt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Test symlink(), linkinfo(), link() and is_link() functions: basic functionality - link to dirs
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
5+
if (PHP_OS_FAMILY === 'Windows') {
6+
require_once __DIR__ . '/windows_links/common.inc';
7+
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
78
}
89
?>
910
--FILE--
@@ -31,7 +32,8 @@ echo "\n-- Testing on soft links --\n";
3132
// creating soft link to $dirname
3233
var_dump( symlink("$file_path/$dirname", $sym_linkname) ); // this works, expected true
3334
// gets information about soft link created to directory; expected: true
34-
var_dump( linkinfo($sym_linkname) );
35+
$linkinfo = linkinfo($sym_linkname);
36+
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
3537
// checks if link created is soft link; expected: true
3638
var_dump( is_link($sym_linkname) );
3739
// clear the cache
@@ -47,7 +49,11 @@ var_dump( is_link($linkname) ); // link doesn't exists as not created, expected
4749
clearstatcache();
4850

4951
// deleting the links
50-
unlink($sym_linkname);
52+
if (PHP_OS_FAMILY === 'Windows') {
53+
rmdir($sym_linkname);
54+
} else {
55+
unlink($sym_linkname);
56+
}
5157

5258
echo "Done\n";
5359
?>
@@ -63,7 +69,7 @@ rmdir($dirname);
6369

6470
-- Testing on soft links --
6571
bool(true)
66-
int(%d)
72+
bool(true)
6773
bool(true)
6874

6975
-- Testing on hard links --

ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
Test symlink(), linkinfo(), link() and is_link() functions : error conditions - symlink & linkinfo
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
7-
}
85
if (substr(PHP_OS, 0, 3) == 'SUN') {
96
die('skip Not valid for Sun Solaris');
107
}

ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Test symlink(), linkinfo(), link() and is_link() functions : error conditions - link & is_link
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
5+
if (PHP_OS_FAMILY === 'Windows' && PHP_ZTS) {
6+
die('xfail different handling of space as filename with ZTS/NTS on Windows');
77
}
88
?>
99
--FILE--

ext/standard/tests/file/symlink_link_linkinfo_is_link_variation1.phpt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - link name stored in an array/object
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
5+
if (PHP_OS_FAMILY === 'Windows') {
6+
require_once __DIR__ . '/windows_links/common.inc';
7+
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
78
}
89
?>
910
--FILE--
@@ -34,7 +35,8 @@ echo "\n-- Working with soft links --\n";
3435
// creating soft link
3536
var_dump( symlink($filename, $obj->linkname) );
3637
// check if the link exists
37-
var_dump( linkinfo($obj->linkname) );
38+
$linkinfo = linkinfo($obj->linkname);
39+
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
3840
// check if link is soft link
3941
var_dump( is_link($obj->linkname) );
4042
// delete the link created
@@ -47,7 +49,8 @@ echo "\n-- Working with hard links --\n";
4749
// creating hard link
4850
var_dump( link($filename, $obj->linkname) );
4951
// check if the link exists
50-
var_dump( linkinfo($obj->linkname) );
52+
$linkinfo = linkinfo($obj->linkname);
53+
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
5154
// check if link is soft link; expected: false as the link is a hardlink
5255
var_dump( is_link($obj->linkname) );
5356
// delete the link created
@@ -64,7 +67,8 @@ echo "\n-- Working with soft links --\n";
6467
// creating soft link
6568
var_dump( symlink($filename, $link_arr[0]) );
6669
// check if the link exist
67-
var_dump( linkinfo($link_arr[0]) );
70+
$linkinfo = linkinfo($link_arr[0]);
71+
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
6872
// check if link is soft link
6973
var_dump( is_link($link_arr[0]) );
7074
// delete the link created
@@ -77,7 +81,8 @@ echo "\n-- Working with hard links --\n";
7781
// creating hard link
7882
var_dump( link($filename, $link_arr[0]) );
7983
// check if the link exist
80-
var_dump( linkinfo($link_arr[0]) );
84+
$linkinfo = linkinfo($link_arr[0]);
85+
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
8186
// check if link is soft link; expected: false as this is a hardlink
8287
var_dump( is_link($link_arr[0]) );
8388
// delete the links created
@@ -101,23 +106,23 @@ rmdir($dirname);
101106

102107
-- Working with soft links --
103108
bool(true)
104-
int(%d)
109+
bool(true)
105110
bool(true)
106111

107112
-- Working with hard links --
108113
bool(true)
109-
int(%d)
114+
bool(true)
110115
bool(false)
111116

112117
*** Testing symlink(), link(), linkinfo() and is_link() with linknames stored as members of an array ***
113118

114119
-- Working with soft links --
115120
bool(true)
116-
int(%d)
121+
bool(true)
117122
bool(true)
118123

119124
-- Working with hard links --
120125
bool(true)
121-
int(%d)
126+
bool(true)
122127
bool(false)
123128
Done

ext/standard/tests/file/symlink_link_linkinfo_is_link_variation2.phpt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
--TEST--
22
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - hardlink to non-existent file
3-
--SKIPIF--
4-
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
7-
}
8-
?>
93
--FILE--
104
<?php
115
/* Variation 2 : Create hard link to non-existent file */

ext/standard/tests/file/symlink_link_linkinfo_is_link_variation3.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - access/update file through softlink
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
5+
if (PHP_OS_FAMILY === 'Windows') {
6+
require_once __DIR__ . '/windows_links/common.inc';
7+
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
78
}
89
?>
910
--FILE--

ext/standard/tests/file/symlink_link_linkinfo_is_link_variation4.phpt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
--TEST--
22
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - access/update file through hard link
3-
--SKIPIF--
4-
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
7-
}
8-
?>
93
--FILE--
104
<?php
115
/* Variation 4 : Create file and a hard link to the file

ext/standard/tests/file/symlink_link_linkinfo_is_link_variation5.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - work on deleted link
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
5+
if (PHP_OS_FAMILY === 'Windows') {
6+
require_once __DIR__ . '/windows_links/common.inc';
7+
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
78
}
89
?>
910
--FILE--

ext/standard/tests/file/symlink_link_linkinfo_is_link_variation6.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - link & dir perms.
33
--SKIPIF--
44
<?php
5-
if ( substr(PHP_OS, 0, 3) == 'WIN' ) {
6-
die('skip no symlinks on Windows');
7-
}
85
require __DIR__ . '/../skipif_root.inc';
96
?>
107
--FILE--

ext/standard/tests/file/symlink_link_linkinfo_is_link_variation7.phpt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - try link to self
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
5+
if (PHP_OS_FAMILY === 'Windows') {
6+
require_once __DIR__ . '/windows_links/common.inc';
7+
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
78
}
89
?>
910
--FILE--
@@ -38,7 +39,11 @@ var_dump( symlink($dirname, $linkname) );
3839
// create another link to $dirname
3940
var_dump( symlink($linkname, $linkname) );
4041
// delete link
41-
unlink($linkname);
42+
if (PHP_OS_FAMILY === 'Windows') {
43+
rmdir($linkname);
44+
} else {
45+
unlink($linkname);
46+
}
4247

4348
echo "\n*** Create hard link to file and then to itself ***\n";
4449
// create hard link to $filename

ext/standard/tests/file/symlink_link_linkinfo_is_link_variation8.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - try link with same name in diff. dir
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
5+
if (PHP_OS_FAMILY === 'Windows') {
6+
require_once __DIR__ . '/windows_links/common.inc';
7+
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
78
}
89
?>
910
--FILE--
@@ -64,7 +65,7 @@ bool(true)
6465

6566
*** Create soft link in different directory with same filename ***
6667

67-
Warning: symlink(): File exists in %s on line %d
68+
Warning: symlink(): %rFile exists|Permission denied%r in %s on line %d
6869
bool(false)
6970
bool(true)
7071
Done

ext/standard/tests/file/symlink_link_linkinfo_is_link_variation9.phpt

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - link & lstat[dev] value
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
5+
if (PHP_OS_FAMILY === 'Windows') {
6+
require_once __DIR__ . '/windows_links/common.inc';
7+
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
78
}
89
?>
910
--FILE--
@@ -32,8 +33,8 @@ var_dump( symlink($filename, $soft_link) );
3233
// confirming that linkinfo() = lstat['dev'] , this should always match
3334
$linkinfo = linkinfo($soft_link);
3435
$s1 = lstat($soft_link);
35-
echo "linkinfo() returns : $linkinfo\n";
36-
echo "lstat() returns lstat['dev'] as $s1[0]\n";
36+
echo "linkinfo() returns integer !== -1: ";
37+
var_dump(is_int($linkinfo) && $linkinfo !== -1);
3738
if( $s1[0] == $linkinfo )
3839
echo "\nlinkinfo() value matches lstat['dev']\n";
3940
else
@@ -47,8 +48,8 @@ var_dump( link($filename, $hard_link) );
4748
// confirming that linkinfo() = lstat['dev'] , this should always match
4849
$linkinfo = linkinfo($hard_link);
4950
$s1 = lstat($hard_link);
50-
echo "linkinfo() returns : $linkinfo\n";
51-
echo "lstat() returns lstat['dev'] as $s1[0]\n";
51+
echo "linkinfo() returns integer !== -1: ";
52+
var_dump(is_int($linkinfo) && $linkinfo !== -1);
5253
if( $s1[0] == $linkinfo )
5354
echo "\nlinkinfo() value matches lstat['dev']\n";
5455
else
@@ -64,15 +65,19 @@ var_dump( symlink($dirname, $soft_link) );
6465
// confirming that linkinfo() = lstat['dev'], this should always match
6566
$linkinfo = linkinfo($soft_link);
6667
$s1 = lstat($soft_link);
67-
echo "linkinfo() returns : $linkinfo\n";
68-
echo "lstat() returns lstat['dev'] as $s1[0]\n";
68+
echo "linkinfo() returns integer !== -1: ";
69+
var_dump(is_int($linkinfo) && $linkinfo !== -1);
6970
if( $s1[0] == $linkinfo )
7071
echo "\nlinkinfo() value matches lstat['dev']\n";
7172
else
7273
echo "\nWarning: linkinfo() value doesn't match lstat['dev']\n";
7374

7475
// delete link
75-
unlink($soft_link);
76+
if (PHP_OS_FAMILY === 'Windows') {
77+
rmdir($soft_link);
78+
} else {
79+
unlink($soft_link);
80+
}
7681

7782
echo "Done\n";
7883
?>
@@ -87,22 +92,19 @@ rmdir($dirname);
8792
--EXPECTF--
8893
*** Checking lstat() on soft link ***
8994
bool(true)
90-
linkinfo() returns : %d
91-
lstat() returns lstat['dev'] as %d
95+
linkinfo() returns integer !== -1: bool(true)
9296

9397
linkinfo() value matches lstat['dev']
9498

9599
*** Checking lstat() on hard link ***
96100
bool(true)
97-
linkinfo() returns : %d
98-
lstat() returns lstat['dev'] as %d
101+
linkinfo() returns integer !== -1: bool(true)
99102

100103
linkinfo() value matches lstat['dev']
101104

102105
*** Checking lstat() on a soft link to directory ***
103106
bool(true)
104-
linkinfo() returns : %d
105-
lstat() returns lstat['dev'] as %d
107+
linkinfo() returns integer !== -1: bool(true)
106108

107109
linkinfo() value matches lstat['dev']
108110
Done

0 commit comments

Comments
 (0)