Commit bc686c93 authored by Jens Segers's avatar Jens Segers

Adding tests for issue #27

parent 27293757
...@@ -146,6 +146,19 @@ class ModelTest extends PHPUnit_Framework_TestCase { ...@@ -146,6 +146,19 @@ class ModelTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('John Doe', $user->name); $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 * @expectedException Illuminate\Database\Eloquent\ModelNotFoundException
*/ */
......
...@@ -29,6 +29,18 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase { ...@@ -29,6 +29,18 @@ class QueryBuilderTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(1, count($users)); $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() public function testInsert()
{ {
DB::collection('users')->insert(array( DB::collection('users')->insert(array(
......
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