【发布时间】:2017-03-13 15:28:45
【问题描述】:
我已经定义了一个范围,该范围通过发布的时间戳对我的实体进行排序。我想写一个测试来确保正确的排序。
但是我不知何故未能找到一种“好”的方法来做到这一点。
$novels = Novel::published()->get();
这是我最好的猜测
for($i = 1; $i < count($novels); $i++)
{
$this->assertGreaterThanOrEqual(
$novels->toArray()[$i - 1]['published_at'],
$novels->toArray()[$i]['published_at']
);
}
谁能提供更好的方法?
【问题讨论】:
标签: php laravel testing phpunit