Commit 8ea8b96f authored by Jens Segers's avatar Jens Segers

Merge pull request #144 from neoxia/master-test-robustness

Make test cases more robust by not using natural ordering
parents b23b59ee f9f8f375
...@@ -104,8 +104,8 @@ class ModelTest extends PHPUnit_Framework_TestCase { ...@@ -104,8 +104,8 @@ class ModelTest extends PHPUnit_Framework_TestCase {
$all = User::all(); $all = User::all();
$this->assertEquals(2, count($all)); $this->assertEquals(2, count($all));
$this->assertEquals('John Doe', $all[0]->name); $this->assertContains('John Doe', $all->lists('name'));
$this->assertEquals('Jane Doe', $all[1]->name); $this->assertContains('Jane Doe', $all->lists('name'));
} }
public function testFind() public function testFind()
......
...@@ -312,9 +312,9 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase { ...@@ -312,9 +312,9 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase {
array('name' => 'spoon', 'type' => 'round', 'amount' => 14) array('name' => 'spoon', 'type' => 'round', 'amount' => 14)
)); ));
$items = DB::collection('items')->take(2)->get(); $items = DB::collection('items')->orderBy('name')->take(2)->get();
$this->assertEquals(2, count($items)); $this->assertEquals(2, count($items));
$this->assertEquals('knife', $items[0]['name']); $this->assertEquals('fork', $items[0]['name']);
} }
public function testSkip() public function testSkip()
...@@ -352,8 +352,9 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase { ...@@ -352,8 +352,9 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase {
)); ));
$list = DB::collection('items')->lists('name'); $list = DB::collection('items')->lists('name');
sort($list);
$this->assertEquals(4, count($list)); $this->assertEquals(4, count($list));
$this->assertEquals(array('knife', 'fork', 'spoon', 'spoon'), $list); $this->assertEquals(array('fork', 'knife', 'spoon', 'spoon'), $list);
$list = DB::collection('items')->lists('type', 'name'); $list = DB::collection('items')->lists('type', 'name');
$this->assertEquals(3, count($list)); $this->assertEquals(3, count($list));
......
...@@ -70,18 +70,18 @@ class QueryTest extends PHPUnit_Framework_TestCase { ...@@ -70,18 +70,18 @@ class QueryTest extends PHPUnit_Framework_TestCase {
public function testSelect() public function testSelect()
{ {
$user = User::select('name')->first(); $user = User::where('name', 'John Doe')->select('name')->first();
$this->assertEquals('John Doe', $user->name); $this->assertEquals('John Doe', $user->name);
$this->assertEquals(null, $user->age); $this->assertEquals(null, $user->age);
$user = User::select('name', 'title')->first(); $user = User::where('name', 'John Doe')->select('name', 'title')->first();
$this->assertEquals('John Doe', $user->name); $this->assertEquals('John Doe', $user->name);
$this->assertEquals('admin', $user->title); $this->assertEquals('admin', $user->title);
$this->assertEquals(null, $user->age); $this->assertEquals(null, $user->age);
$user = User::get(array('name'))->first(); $user = User::where('name', 'John Doe')->get(array('name'))->first();
$this->assertEquals('John Doe', $user->name); $this->assertEquals('John Doe', $user->name);
$this->assertEquals(null, $user->age); $this->assertEquals(null, $user->age);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment