From: Greg Beaver Date: Fri, 31 Oct 2003 01:17:04 +0000 (+0000) Subject: start on unit test for PEAR_Common X-Git-Tag: php-5.0.0b3RC1~828 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f244e77f6b027bf3e4b9012d87de00c6e6615447;p=php start on unit test for PEAR_Common --- diff --git a/pear/tests/pear_common_analyzeSC.phpt b/pear/tests/pear_common_analyzeSC.phpt new file mode 100644 index 0000000000..8a70096d07 --- /dev/null +++ b/pear/tests/pear_common_analyzeSC.phpt @@ -0,0 +1,128 @@ +--TEST-- +PEAR_Common::analyzeSourceCode test +--SKIPIF-- + +--FILE-- + +'; +$fp = fopen($testdir . DIRECTORY_SEPARATOR . 'test1.php', 'w'); +fwrite($fp, $test1); +fclose($fp); + +$ret = PEAR_Common::analyzeSourceCode($testdir . DIRECTORY_SEPARATOR . 'test1.php'); +echo "second test: returns false with invalid PHP? "; +echo $ret ? "no\n" : "yes\n"; +unlink($testdir . DIRECTORY_SEPARATOR . 'test1.php'); + +$test3 = ' + +'; +$fp = fopen($testdir . DIRECTORY_SEPARATOR . 'test3.php', 'w'); +fwrite($fp, $test3); +fclose($fp); + +$ret = PEAR_Common::analyzeSourceCode($testdir . DIRECTORY_SEPARATOR . 'test3.php'); +echo "fourth test: returns false with invalid PHP? "; +echo $ret ? "no\n" : "yes\n"; +unlink($testdir . DIRECTORY_SEPARATOR . 'test3.php'); + +$test4 = ' + +'; +$fp = fopen($testdir . DIRECTORY_SEPARATOR . 'test4.php', 'w'); +fwrite($fp, $test4); +fclose($fp); + +$ret = PEAR_Common::analyzeSourceCode($testdir . DIRECTORY_SEPARATOR . 'test4.php'); +echo "fifth test: returns false with invalid PHP? "; +echo $ret ? "no\n" : "yes\n"; +unlink($testdir . DIRECTORY_SEPARATOR . 'test4.php'); + +$test5 = ' + +'; +$fp = fopen($testdir . DIRECTORY_SEPARATOR . 'test5.php', 'w'); +fwrite($fp, $test5); +fclose($fp); + +$ret = PEAR_Common::analyzeSourceCode($testdir . DIRECTORY_SEPARATOR . 'test5.php'); +echo "sixth test: returns false with valid PHP? "; +echo $ret ? "no\n" : "yes\n"; +var_dump($ret); +unlink($testdir . DIRECTORY_SEPARATOR . 'test5.php'); + +rmdir($testdir); +?> +--GET-- +--POST-- +--EXPECT-- +first test: returns false with non-existing filename? yes +second test: returns false with invalid PHP? yes +fourth test: returns false with invalid PHP? yes +fifth test: returns false with invalid PHP? yes +sixth test: returns false with valid PHP? no +array(5) { + ["declared_classes"]=> + array(1) { + [0]=> + string(5) "test2" + } + ["declared_methods"]=> + array(1) { + ["test2"]=> + array(1) { + [0]=> + string(5) "test2" + } + } + ["declared_functions"]=> + array(1) { + [0]=> + string(4) "test" + } + ["used_classes"]=> + array(0) { + } + ["inheritance"]=> + array(0) { + } +} \ No newline at end of file