summaryrefslogtreecommitdiff
path: root/README.TESTING
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2002-10-25 11:17:45 +0000
committerMarcus Boerger <helly@php.net>2002-10-25 11:17:45 +0000
commit9307fa750ec17f53bef7856cb8c5685c32249c99 (patch)
tree255c6e12675669cba3d79a51b72e61c1024263f0 /README.TESTING
parent0a7653263d863ac87d8b2489d6ea61d8a2421cf4 (diff)
downloadphp-git-9307fa750ec17f53bef7856cb8c5685c32249c99.tar.gz
update
Diffstat (limited to 'README.TESTING')
-rw-r--r--README.TESTING150
1 files changed, 82 insertions, 68 deletions
diff --git a/README.TESTING b/README.TESTING
index a2624b74b3..4e2e00eb1f 100644
--- a/README.TESTING
+++ b/README.TESTING
@@ -140,90 +140,56 @@ advised to test for non-zero, rather then a specific value.
[Creating new test files]
-------------------------
- Writing test file is very easy if you are used to PHP. Test file
-has following format. Here is a actual test file from iconv module.
+ Writing test file is very easy if you are used to PHP.
-===== ext/iconv/002.phpt =======
+Here is an actual test file from standard module.
+
+===== ext/standard/tests/strings/strtr.phpt =======
--TEST--
-UCS4BE to ASCII
---SKIPIF--
-<?php include('skipif.inc'); ?>
+strtr() function
--FILE--
-<?php include('002.inc'); ?>
+<?php
+/* Do not change this test it is a REATME.TESTING example. */
+$trans = array("hello"=>"hi", "hi"=>"hello", "a"=>"A", "world"=>"planet");
+var_dump(strtr("# hi all, I said hello world! #", $trans));
+?>
--EXPECT--
-&#97;&#98;&#99;&#100;
-abcd
-===== end of ext/iconv/002.phpt =======
+string(32) "# hello All, I sAid hi planet! #"
+===== ext/standard/tests/strings/strtr.phpt =======
- As you can see the file has the following sections:
+As you can see the file is devided into several sections. Below is a
+list of all possible sections:
-"--TEST--" is title of the test.
+"--TEST--" is title of the test (required).
"--SKIPIF--" is condition when to skip this test (optional).
"--POST--" is POST variable passed to test script (optional).
"--GET--" is GET variable passed to test script (optional).
"--INI--" each line contains an ini setting e.g. foo=bar (optional).
-"--FILE--" is the test script.
-"--EXPECT--" is the expected output from the test script.
-"--EXPECTF--" this is the alternate form of --EXPECT--. The difference
- is is that this form uses sscanf for output validation.
-
-ext/iconv/002.phpt uses 2 files. "skipif.inc" is used to skip
-test when test cannot be performed such as iconv module is not
-compiled or loaded.
-
-==== ext/iconv/skipif.inc ====
-<?php
-// This script prints "skip" if condition does not meet.
-
-if (!extension_loaded("iconv") && ini_get("enable_dl")) {
- $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so";
- @dl("iconv$dlext");
-}
-if (!extension_loaded("iconv")) {
- die("skip\n");
-}
-?>
-==== end of ext/iconv/skipif.inc ====
-
-ext/inconv/002.inc is the test script. "run-tests.php" script
-executes test script with CGI executable.
-
-==== ext/iconv/002.inc ===
-<?php
-/*
-Expected output:
-&#97;&#98;&#99;&#100;
-abcd
-*/
-
- $s = unpack("V*", iconv("ascii","UCS-4LE", "abcd"));
- foreach($s as $c) { print "&#$c;"; } print "\n";
-
- $s = pack("NNNN", 97, 98, 99, 100);
- $q = iconv("UCS-4BE", "ascii", $s);
- print $q; print "\n";
-?>
-=== end of ext/iconv/002.inc ===
-
-Test script and SKIPIF code should be directly written into *.phpt.
-However, it is recommended to use include files when more test scripts
-depend on the same SKIPIF code or when certain test files need the same
-values for some input. But no file used by any test should have one of
-the following extensions: ".php", ".log", ".exp", ".out" or ".diff".
-
-
-/ext/standard/tests/strings 003.phpt is a good example for using EXPECTF
-instead of EXPECT. From time to time the algorithm used for shuffle
+"--FILE--" is the test script (required).
+"--EXPECT--" is the expected output from the test script (required).
+"--EXPECTF--" this is the alternative of --EXPECT--. The difference is
+ that this form uses sscanf for output validation (alternative).
+
+A test must at least contain the sections TEST, FILE and either EXPECT
+or EXPECTF. When a test is called run-test.php takes the name from the
+TEST section and writes the FILE section into a ".php" file with the
+same name as the ".phpt" file. This ".php" file will then be executed
+and its output compared to the contents of the EXPECT section. It is a
+good idea to generate output with var_dump() calls.
+
+/ext/standard/tests/strings/str_shuffle.phpt is a good example for using
+EXPECTF instead of EXPECT. From time to time the algorithm used for shuffle
changed and sometimes the machine used to execute the code has influence
on the result of shuffle. But it always returns a three character string
-detectable by %s. Other scan-able forms are %i for integers, %f for
-floating point values and %x for hexadecimal values.
+detectable by %s. Other scan-able forms are %i for integers, %d for numbers
+only, %f for floating point values and %x for hexadecimal values.
-==== /ext/standard/tests/strings 003.phpt ===
+==== /ext/standard/tests/strings/str_shuffle.phpt ===
--TEST--
Testing str_shuffle.
--FILE--
<?php
+/* Do not change this test it is a REATME.TESTING example. */
$s = '123';
var_dump(str_shuffle($s));
var_dump($s);
@@ -231,7 +197,55 @@ var_dump($s);
--EXPECTF--
string(3) %s
string(3) "123"
-==== end of /ext/standard/tests/strings 003.phpt ===
+==== end of /ext/standard/tests/strings/str_shuffle.phpt ===
+
+Some tests depend on modules or functions available only in certain versions
+or they even require minimum version of php or zend. These tests should be
+skipped when the requirement cannot be fullfilled. To achieve this you can
+use the SKIPIF section. To tell run-test.php that your test should be skipped
+the SKIPIF section must print out the word "skip" followed by a reason why
+the test should skip.
+
+==== /ext/exif/tests/exif005.phpt ===
+--TEST--
+Check for exif_read_data, unusual IFD start
+--SKIPIF--
+<?php
+ if (!extension_loaded('exif')) print 'skip exif extension not available';
+?>
+--FILE--
+<?php
+/* Do not change this test it is a REATME.TESTING example.
+ * test5.jpg is a 1*1 image that contains an Exif section with ifd = 00000009h
+ */
+$image = exif_read_data('./ext/exif/tests/test5.jpg','',true,false);
+var_dump($image['IFD0']);
+?>
+--EXPECT--
+array(2) {
+ ["ImageDescription"]=>
+ string(11) "Ifd00000009"
+ ["DateTime"]=>
+ string(19) "2002:10:18 20:06:00"
+}
+==== end of /ext/exif/tests/exif005.phpt ===
+
+Test script and SKIPIF code should be directly written into *.phpt. However,
+it is recommended to use include files when more test scripts depend on the
+same SKIPIF code or when certain test files need the same values for some
+input. But no file used by any test should have one of the following
+extensions: ".php", ".log", ".exp", ".out" or ".diff".
+
+Tests should be named according to the following list:
+
+Class: Name: Example:
+Tests for bugs bug<bugid>.phpt bug17123.phpt
+Tests for functions <functionname>.phpt dba_open.phpt
+General tests for extensions <extname><no>.phpt dba3.phpt
+
+When you use an include file for the SKIPIF section it should be named
+"skipif.inc" and an include file used in the FILE section of many tests
+should be named "test.inc".
[How to help us]
----------------