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:
    1. -- TEST --
    2. One line only description of test
    3. -- FILE --
    4. <?php
    5. ?>
    6. -- EXPECT --

  • 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
del.icio.us:Notes on writing phpt tests  digg:Notes on writing phpt tests  furl:Notes on writing phpt tests  reddit:Notes on writing phpt tests

Leave a Reply