php-src/tests
2002-08-21 23:10:44 +00:00
..
basic Test argument passing for CLI 2002-08-21 23:10:44 +00:00
classes
func Fix the levels. (php.ini-dist has output_buffering OFF) 2002-08-01 12:02:22 +00:00
lang @- Added set_exception_handler() function for registering a global, 2002-08-16 00:41:37 +00:00
strings - Add test for sprintf()'s zero'th argument 2002-03-22 09:09:36 +00:00
bin-info.inc Fix PHP version and sapi printed so that it does not print bogus 2002-03-12 06:43:15 +00:00
dirname.phpt dirname() checks that work for both Unix and Win32. 2002-05-16 15:59:39 +00:00
foo
foo2
foo3
foo4
odbc-display.php
odbc-t1.php
odbc-t2.php
odbc-t3.php
odbc-t4.php
odbc-t5.php
quicktester.inc - Fixed the bz2 tests. (and changed the usage comment to be correct) 2002-03-20 02:16:34 +00:00
README
recurse
run.html
run.php
scan_cases
test_class_inheritance
test.php4
test.pl
testarray
testarray2
testarray2.pl
testarray.pl
testclassfunc
testcom
testcpdf
testcpdfclock
testdom
testfe
testfunc
testfunc2
testfunc2.pl
testfunc.pl
testfuncref
testhyperwave
testinclude
testobj
testpfpro.php
tests.dsp Win32 project and makefile used to invoke run-tests.php 2002-05-15 23:56:04 +00:00
tests.mak Add TEST_PHP_DETAILED usage for verbose test runs. 2002-05-16 21:46:32 +00:00
testscanf.php
testswf

PHP Regression Tests
====================

To run the tests, go to the top-level directory and
run "./php -q run-tests.php".

Without parameters, "run-tests.php" will recursively scan through the
file tree looking for directories called "tests", and run all the
tests (.phpt files) within (recursively).

To run tests in a single directory, pass the directory as a parameter:
"./php -q run-tests.php tests/lang".

To run one or more single tests, pass them as parameters:
"./php -q run-tests.php tests/lang/015.phpt".

The format of the .phpt files is quite simple.  There are 6 possible
sections.  Test, Skipif, Post, Get, File and Expect.  The Test section
contains the description of the test.  The Skipif section contains
code that should print "skip" if this test should be skipped for some
reason (such as an extension that is not compiled in).  The Post
section contains any post data that the script might need.  The Get
section contains any Get data.  Note that both the Post and the Get
sections need to have this data in url-encoded format.  The File
section contains the actual script and the Expect section is the
expected output, sans headers.  Blank lines are ignored in the
expected output.

A simple example which takes one argument through the POST method
and one through the GET and displays these would be:

--TEST--
Simple GET and POST test
--SKIPIF--
--POST--
a=Hello
--GET--
b=There
--FILE--
<?php echo "$a $b">
--EXPECT--
Hello There

Another simple example that only runs if the PCRE extension is loaded:

--TEST--
Simple Perl regexp test
--SKIPIF--
<?php if (!extension_loaded("pcre")) print "skip"; ?>
--POST--
--GET--
--FILE--
<?php
$str="Hello 42 World";
if (pcre_match('/^([a-z]+)\s+(\d+)\s+([a-z]+)/i', $str, $matches)) {
    printf("%s %s: %d\n", $matches[1], $matches[3], $matches[2]);
}
?>
--EXPECT--
Hello World: 42