Annotation of embedaddon/php/ext/phar/tests/fgc_edgecases.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Phar: test edge cases of file_get_contents() function interception
! 3: --SKIPIF--
! 4: <?php
! 5: if (!extension_loaded("phar")) die("skip");
! 6: if (version_compare(PHP_VERSION, "6.0", ">")) die("skip pre-unicode version of PHP required");
! 7: ?>
! 8: --INI--
! 9: phar.readonly=0
! 10: --FILE--
! 11: <?php
! 12:
! 13: Phar::interceptFileFuncs();
! 14:
! 15: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
! 16: $pname = 'phar://' . $fname;
! 17:
! 18: file_get_contents(array());
! 19: chdir(dirname(__FILE__));
! 20: file_put_contents($fname, "blah\n");
! 21: file_put_contents("foob", "test\n");
! 22: echo file_get_contents($fname);
! 23: unlink($fname);
! 24: mkdir($pname . '/oops');
! 25:
! 26: file_put_contents($pname . '/foo/hi', '<?php
! 27: echo file_get_contents("foo/" . basename(__FILE__));
! 28: $context = stream_context_create();
! 29: file_get_contents("./hi", 0, $context, 0, -1);
! 30: echo file_get_contents("foob");
! 31: set_include_path("' . addslashes(dirname(__FILE__)) . '");
! 32: echo file_get_contents("foob", true);
! 33: echo file_get_contents("./hi", 0, $context);
! 34: echo file_get_contents("../oops");
! 35: echo file_get_contents("./hi", 0, $context, 50000);
! 36: ini_set("magic_quotes_runtime", 1);
! 37: echo file_get_contents("./hi");
! 38: echo file_get_contents("./hi", 0, $context, 0, 0);
! 39: ?>
! 40: ');
! 41:
! 42: include $pname . '/foo/hi';
! 43:
! 44: ?>
! 45: ===DONE===
! 46: --CLEAN--
! 47: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
! 48: <?php rmdir(dirname(__FILE__) . '/poo'); ?>
! 49: <?php unlink(dirname(__FILE__) . '/foob'); ?>
! 50: --EXPECTF--
! 51: Warning: file_get_contents() expects parameter 1 to be string, array given in %sfgc_edgecases.php on line %d
! 52: blah
! 53: <?php
! 54: echo file_get_contents("foo/" . basename(__FILE__));
! 55: $context = stream_context_create();
! 56: file_get_contents("./hi", 0, $context, 0, -1);
! 57: echo file_get_contents("foob");
! 58: set_include_path("%stests");
! 59: echo file_get_contents("foob", true);
! 60: echo file_get_contents("./hi", 0, $context);
! 61: echo file_get_contents("../oops");
! 62: echo file_get_contents("./hi", 0, $context, 50000);
! 63: ini_set("magic_quotes_runtime", 1);
! 64: echo file_get_contents("./hi");
! 65: echo file_get_contents("./hi", 0, $context, 0, 0);
! 66: ?>
! 67:
! 68: Warning: file_get_contents(): length must be greater than or equal to zero in phar://%sfgc_edgecases.phar.php/foo/hi on line %d
! 69: test
! 70: test
! 71: <?php
! 72: echo file_get_contents("foo/" . basename(__FILE__));
! 73: $context = stream_context_create();
! 74: file_get_contents("./hi", 0, $context, 0, -1);
! 75: echo file_get_contents("foob");
! 76: set_include_path("%stests");
! 77: echo file_get_contents("foob", true);
! 78: echo file_get_contents("./hi", 0, $context);
! 79: echo file_get_contents("../oops");
! 80: echo file_get_contents("./hi", 0, $context, 50000);
! 81: ini_set("magic_quotes_runtime", 1);
! 82: echo file_get_contents("./hi");
! 83: echo file_get_contents("./hi", 0, $context, 0, 0);
! 84: ?>
! 85:
! 86: Warning: file_get_contents(phar://%sfgc_edgecases.phar.php/oops): failed to open stream: phar error: path "oops" is a directory in phar://%sfgc_edgecases.phar.php/foo/hi on line %d
! 87:
! 88: Warning: file_get_contents(): Failed to seek to position 50000 in the stream in phar://%sfgc_edgecases.phar.php/foo/hi on line %d
! 89: <?php
! 90: echo file_get_contents(\"foo/\" . basename(__FILE__));
! 91: $context = stream_context_create();
! 92: file_get_contents(\"./hi\", 0, $context, 0, -1);
! 93: echo file_get_contents(\"foob\");
! 94: set_include_path(\"%stests\");
! 95: echo file_get_contents(\"foob\", true);
! 96: echo file_get_contents(\"./hi\", 0, $context);
! 97: echo file_get_contents(\"../oops\");
! 98: echo file_get_contents(\"./hi\", 0, $context, 50000);
! 99: ini_set(\"magic_quotes_runtime\", 1);
! 100: echo file_get_contents(\"./hi\");
! 101: echo file_get_contents(\"./hi\", 0, $context, 0, 0);
! 102: ?>
! 103: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>