Skip to content

Commit

Permalink
Adding tests for issue mongodb#27
Browse files Browse the repository at this point in the history
  • Loading branch information
mnphpexpert committed Aug 26, 2013
1 parent c02ad8d commit 620e5b3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ public function testFirst()
$this->assertEquals('John Doe', $user->name);
}

public function testNoDocument()
{
$items = Item::where('name', 'nothing')->get();
$this->assertInstanceOf('Illuminate\Database\Eloquent\Collection', $items);
$this->assertEquals(0, $items->count());

$item =Item::where('name', 'nothing')->first();
$this->assertEquals(null, $item);

$item = Item::find('51c33d8981fec6813e00000a');
$this->assertEquals(null, $item);
}

/**
* @expectedException Illuminate\Database\Eloquent\ModelNotFoundException
*/
Expand Down
12 changes: 12 additions & 0 deletions tests/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ public function testGet()
$this->assertEquals(1, count($users));
}

public function testNoDocument()
{
$items = DB::collection('items')->where('name', 'nothing')->get();
$this->assertEquals(array(), $items);

$item = DB::collection('items')->where('name', 'nothing')->first();
$this->assertEquals(null, $item);

$item = DB::collection('items')->where('_id', '51c33d8981fec6813e00000a')->first();
$this->assertEquals(null, $item);
}

public function testInsert()
{
DB::collection('users')->insert(array(
Expand Down

0 comments on commit 620e5b3

Please sign in to comment.