私はPHPUnitを使用した単体テストから始めたばかりで、その感触をつかむためにいくつかの簡単な方法で遊んでいます。一例はすぐに不可解です:
function setDelay($seconds)
{
if($seconds == 0)
{
$this->delay = 0;
}
else
{
$this->delay = time() + $seconds;
}
}
メソッドの外部でtime()が不明な場合、正しい期待される結果をどのように判断しますか?:
public function testSetDelayNonZero() {
$expected = [??];
$this->class->setDelay(100);
$actual = $this->class->delay;
$this->assertEquals($expected, $actual);
}