diff --git a/tests/ModelTest.php b/tests/ModelTest.php index 5e67931ec..5b5a2af8a 100644 --- a/tests/ModelTest.php +++ b/tests/ModelTest.php @@ -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 */ diff --git a/tests/QueryBuilderTest.php b/tests/QueryBuilderTest.php index a3e362906..0492934d0 100644 --- a/tests/QueryBuilderTest.php +++ b/tests/QueryBuilderTest.php @@ -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(