好的,所以我正在看一個代碼,我正在做一個phpunit覆蓋測試。在該測試,我只得到2行未適當地工作:我getEarliestDateorNull內PHPUnit覆蓋測試elseif錯誤
private function getEarliestDateOrNull($snapshotDate = null, $preexistingEpisodeDate = null)
{
$date = null;
if ($snapshotDate instanceof DateTime && $preexistingEpisodeDate instanceof DateTime) {
$date = $snapshotDate < $preexistingEpisodeDate ? $snapshotDate : $preexistingEpisodeDate;
} elseif ($snapshotDate instanceof DateTime) {
$date = $snapshotDate;
} elseif ($preexistingEpisodeDate instanceof DateTime) {
$date = $preexistingEpisodeDate;
}
return ($date instanceof DateTime) ? $date->format('m/d/Y') : null;
}
的問題是,這兩個ELSEIF語句是測試出於某種原因不能讀取唯一的。有沒有辦法從elseif語句中改變它們?我的意思是說,如果可能有SWITCH的實施。該測試在PHP 7
你說你有沒有適當工作兩行,但你貼103線... –
@JoeC好的,我修改了它。我非常感激知道錯誤是什麼。我如何實現兩個elseif語句的替代方案? – OZTZ3
我也遇到了這個問題elseif被PHPUnit 5.6.2 –