Annotation of embedaddon/php/ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test symlink(), linkinfo(), link() and is_link() functions : error conditions - link & is_link
! 3: --SKIPIF--
! 4: <?php
! 5: if (substr(PHP_OS, 0, 3) == 'WIN') {
! 6: die('skip no symlinks on Windows');
! 7: }
! 8: if (PHP_INT_SIZE != 4) {
! 9: die("skip this test is for 32bit platform only");
! 10: }
! 11: ?>
! 12: --FILE--
! 13: <?php
! 14: /* Prototype: bool symlink ( string $target, string $link );
! 15: Description: creates a symbolic link to the existing target with the specified name link
! 16:
! 17: Prototype: bool is_link ( string $filename );
! 18: Description: Tells whether the given file is a symbolic link.
! 19:
! 20: Prototype: bool link ( string $target, string $link );
! 21: Description: Create a hard link
! 22:
! 23: Prototype: int linkinfo ( string $path );
! 24: Description: Gets information about a link
! 25: */
! 26:
! 27: // create temp $filename and create link $linkname to it
! 28: $filename = dirname(__FILE__)."/symlink_link_linkinfo_is_link_error2.tmp";
! 29: $fp = fopen($filename, "w"); // create temp file
! 30: fclose($fp);
! 31:
! 32: // linkname used to create soft/hard link
! 33: $linkname = dirname(__FILE__)."/symlink_link_linkinfo_is_link_link_error2.tmp";
! 34:
! 35: echo "*** Testing link() for error conditions ***\n";
! 36: //zero arguments
! 37: var_dump( link() );
! 38:
! 39: //more than expected
! 40: var_dump( link($filename, $linkname, false) );
! 41:
! 42: //invalid arguments
! 43: var_dump( link(NULL, $linkname) ); // NULL as filename
! 44: var_dump( link('', $linkname) ); // empty string as filename
! 45: var_dump( link(' ', $linkname) ); // space as filename
! 46: var_dump( link(false, $linkname) ); // boolean false as filename
! 47: var_dump( link($filename, NULL) ); // NULL as linkname
! 48: var_dump( link($filename, '') ); // '' as linkname
! 49: var_dump( link($filename, false) ); // false as linkname
! 50:
! 51: echo "\n*** Testing is_link() for error conditions ***\n";
! 52: //zero arguments
! 53: var_dump( is_link() );
! 54:
! 55: //more than expected
! 56: var_dump( is_link($linkname, "/") );
! 57:
! 58: //invalid arguments
! 59: var_dump( is_link(NULL) ); // NULL as linkname
! 60: var_dump( is_link('') ); // empty string as linkname
! 61: var_dump( is_link(' ') ); // space as linkname
! 62: var_dump( is_link(false) ); // boolean false as linkname
! 63: var_dump( is_link($filename) ); // file given to is_link
! 64:
! 65: echo "Done\n";
! 66: ?>
! 67: --CLEAN--
! 68: <?php
! 69: unlink(dirname(__FILE__)."/symlink_link_linkinfo_is_link_error2.tmp");
! 70: ?>
! 71: --EXPECTF--
! 72: *** Testing link() for error conditions ***
! 73:
! 74: Warning: link() expects exactly 2 parameters, 0 given in %s on line %d
! 75: NULL
! 76:
! 77: Warning: link() expects exactly 2 parameters, 3 given in %s on line %d
! 78: NULL
! 79:
! 80: Warning: link(): No such file or directory in %s on line %d
! 81: bool(false)
! 82:
! 83: Warning: link(): No such file or directory in %s on line %d
! 84: bool(false)
! 85:
! 86: Warning: link(): No such file or directory in %s on line %d
! 87: bool(false)
! 88:
! 89: Warning: link(): No such file or directory in %s on line %d
! 90: bool(false)
! 91:
! 92: Warning: link(): No such file or directory in %s on line %d
! 93: bool(false)
! 94:
! 95: Warning: link(): No such file or directory in %s on line %d
! 96: bool(false)
! 97:
! 98: Warning: link(): No such file or directory in %s on line %d
! 99: bool(false)
! 100:
! 101: *** Testing is_link() for error conditions ***
! 102:
! 103: Warning: is_link() expects exactly 1 parameter, 0 given in %s on line %d
! 104: NULL
! 105:
! 106: Warning: is_link() expects exactly 1 parameter, 2 given in %s on line %d
! 107: NULL
! 108: bool(false)
! 109: bool(false)
! 110: bool(false)
! 111: bool(false)
! 112: bool(false)
! 113: Done
! 114:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>