好的,所以我正在看一个代码,我正在做一个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 –