クラスのテストをそのファイルに書く

http://www.developer0000.jp/2008/10/09/2952/ から。
あまりやりたくないけど。。。

http://blog.bz2.jp/archives/2008/04/post-78.html の辺を参考に。

hoge.php
<?php

class Hoge {
  function say($a) {
    return false;
  }
}

if (!isset($argv[1]) || $argv[1] != '--test') {
    return;
}
// これ以降は引数 "--test" を指定して直接実行した場合
$h = new Hoge();
assert($h->say(1));
?>

実行は

php hoge.php --test


こういうときこそDocTest?
http://labs.unoh.net/2008/04/doctest-for-php.html