Notes on writing phpt tests

Notes to self for writing phpt tests (so far):

  • Doc page on writing phpt tests – http://qa.php.net/write-test.php
  • basic format of a phpt:
  • [php]– TEST –
    One line only description of test
    – FILE –
    < ?php
    ?>
    – EXPECT –[/php]

  • try to break the function. That is the purpose of the tests after all.
  • use var_dump instead of print_r – it shows the differences between null, empty strings and what nots.
  • if you are using the latest cvs checkouts (have unicode support) – in the — INI– part set unicode-semantics=1
  • in cases where you are expecting to generate an error – use the — EXPECTF– instead of the — EXPECT–
  • add a marker (Ex:’===DONE===’) after the closing ?> to catch if the script continues after it