public function testPostOrderBy() { $posts = Post::orderBy('post_date', 'asc')->take(5)->get(); $lastDate = null; foreach ($posts as $post) { if (!is_null($lastDate)) { $this->assertGreaterThanOrEqual(0, strcmp($post->post_date, $lastDate)); } $lastDate = $post->post_date; } $posts = Post::orderBy('post_date', 'desc')->take(5)->get(); $lastDate = null; foreach ($posts as $post) { if (!is_null($lastDate)) { $this->assertLessThanOrEqual(0, strcmp($post->post_date, $lastDate)); } $lastDate = $post->post_date; } }