README.TESTING2 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. [IMPORTANT NOTICE]
  2. ------------------
  3. This is an addendum to README.TESTING with additional information
  4. specific to server-tests.php.
  5. server-tests.php is backward compatible with tests developed for
  6. the original run-tests.php script. server-tests is *not* used by
  7. 'make test'. server-tests was developed to provide support for
  8. testing PHP under it's primary environment, HTTP, and can run the
  9. PHP tests under any of the SAPI modules that are direct executables,
  10. or are accessible via HTTP.
  11. [New features]
  12. ----------------
  13. * Command line interface:
  14. You can run 'php server-tests.php -h' to get all the possible options.
  15. * Configuration file:
  16. the -c argument will allow you to use a configuration file. This is
  17. handy if you are testing multiple environments and need various options
  18. depending on the environment.
  19. see server-tests-config.php for details.
  20. * CGI Emulation:
  21. Will emulate a CGI environment when testing with the cgi sapi executable.
  22. * HTTP testing:
  23. can be configured to run test scripts through an HTTP server running
  24. on localhost. localhost is required since either the web server must
  25. alias a directory to the php source directory, or the test scripts
  26. must be copied to a directory under the web server
  27. (see config options TEST_WEB_BASE_URL, TEST_BASE_PATH, and TEST_WEB_EXT)
  28. * New sections supported for test files (see below)
  29. When running tests over http, tests that require ini settings different that what
  30. the web server runs under will be skipped. Since the test harness defines a number
  31. of ini settings by default, the web server may require special configuration to
  32. make testing work.
  33. [Example Usage]
  34. ----------------
  35. Some (but not all!) examples of usage:
  36. 1. run tests from the php source directory
  37. php server-tests.php -p /path/to/php-cli
  38. 2. run tests using cgi emulation
  39. php server-tests.php -p /path/to/php-cgi
  40. 3. run tests over http, copying test files into document root
  41. php server-tests.php -w -u http://localhost/test -m /path/to/htdocs/test
  42. 4. run tests over http, php sources have been aliased in web server
  43. php server-tests.php -w -u http://localhost/test
  44. 5. run tests using configuration file
  45. php server-tests.php -c /path/to/server-tests-config.php
  46. 6. run tests using configuration file, but overriding some settings:
  47. (config file must be first)
  48. php server-tests.php -c /path/to/server-tests-config.php -w -t 3 -d /path/to/testdir
  49. NOTE: configuration as described in README.TESTING still works.
  50. [New Test Sections]
  51. ----------------
  52. In addition to the traditional test sections
  53. (see http://qa.php.net/write-test.php), several new sections are available
  54. under server-tests.
  55. --POST--
  56. This is not a new section, but not multipart posts are supported for testing
  57. file uploads, or other types of POST data.
  58. --CGI--
  59. This section takes no value. It merely provides a simple marker for tests
  60. that MUST be run as CGI, even if there is no --POST-- or --GET-- sections
  61. in the test file.
  62. --DESCRIPTION--
  63. Not used for anything, just a section for documenting the test
  64. --ENV--
  65. This section get's eval()'d to help build an environment for the
  66. execution of the test. This can be used to change environment
  67. vars that are used for CGI emulation, or simply to set env vars
  68. for cli testing. A full example looks like:
  69. --ENV--
  70. return <<<END
  71. PATH_TRANSLATED=$filename
  72. PATH_INFO=$scriptname
  73. SCRIPT_NAME=$scriptname
  74. END;
  75. Some variables are made easily available for use in this section, they
  76. include:
  77. $filename full native path to file, will become PATH_TRANSLATED
  78. $filepath =dirname($filename)
  79. $scriptname this is what will become SCRIPT_NAME unless you override it
  80. $docroot the equivalent of DOCUMENT_ROOT under Apache
  81. $cwd the directory that the test is being initiated from
  82. $this->conf all server-tests configuration vars
  83. $this->env all environment variables that will get passed to the test
  84. --REQUEST--
  85. This section is also eval'd, and is similar in nature to --ENV--. However,
  86. this section is used to build the url used in an HTTP request. Valid values
  87. to set in this section would include:
  88. SCRIPT_NAME The initial part of the request url
  89. PATH_INFO The pathinfo part of a request url
  90. FRAGMENT The fragment section of a url (after #)
  91. QUERY_STRING The query part of a url (after ?)
  92. --REQUEST--
  93. return <<<END
  94. PATH_INFO=/path/info
  95. END;
  96. --HEADERS--
  97. This section is also eval'd. It is used to provide additional headers sent
  98. in an HTTP request, such as content type for multipart posts, cookies, etc.
  99. --HEADERS--
  100. return <<<END
  101. Content-Type=multipart/form-data; boundary=---------------------------240723202011929
  102. Content-Length=100
  103. END;
  104. --EXPECTHEADERS--
  105. This section can be used to define what headers are required to be
  106. received back from a request, and is checked in addition to the
  107. regular expect sections. For example:
  108. --EXPECTHEADERS--
  109. Status: 404