Commit e3f8c872 authored by Jens Segers's avatar Jens Segers

More tests

parent fb259e92
......@@ -284,21 +284,6 @@ class ModelQueryTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(5, count($users));
}
public function testUpdate()
{
User::where('name', 'John Doe')
->update(array('age' => 100));
$user = User::where('name', 'John Doe')->first();
$this->assertEquals(100, $user->age);
}
public function testDelete()
{
User::where('age', '>', 30)->delete();
$this->assertEquals(3, User::count());
}
public function testInsert()
{
User::insert(
......
......@@ -18,11 +18,22 @@ class QueryTest extends PHPUnit_Framework_TestCase {
$this->assertInstanceOf('Jenssegers\Mongodb\Builder', DB::collection('users'));
}
public function testGet()
{
$users = DB::collection('users')->get();
$this->assertEquals(0, count($users));
DB::collection('users')->insert(array('name' => 'John Doe'));
$users = DB::collection('users')->get();
$this->assertEquals(1, count($users));
}
public function testInsert()
{
$user = array(
'tags' => array('tag1', 'tag2'),
'name' => 'John Doe',
'tags' => array('tag1', 'tag2')
);
DB::collection('users')->insert($user);
......@@ -38,12 +49,12 @@ class QueryTest extends PHPUnit_Framework_TestCase {
{
$users = array(
array(
'tags' => array('tag1', 'tag2'),
'name' => 'Jane Doe',
'tags' => array('tag1', 'tag2')
),
array(
'tags' => array('tag3'),
'name' => 'John Doe',
'tags' => array('tag3')
),
);
DB::collection('users')->insert($users);
......@@ -68,6 +79,33 @@ class QueryTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('John Doe', $user['name']);
}
public function testUpdate()
{
DB::collection('users')->insert(array('name' => 'John Doe', 'age' => 10));
DB::collection('users')->where('name', 'John Doe')->update(array('age' => 100));
$user = User::where('name', 'John Doe')->first();
$this->assertEquals(100, $user->age);
}
public function testDelete()
{
DB::collection('users')->insert(array('name' => 'John Doe', 'age' => 100));
DB::collection('users')->where('age', '<', 30)->delete();
$this->assertEquals(1, DB::collection('users')->count());
DB::collection('users')->where('age', '>', 30)->delete();
$this->assertEquals(0, DB::collection('users')->count());
}
public function testTruncate()
{
DB::collection('users')->insert(array('name' => 'John Doe', 'age' => 100));
DB::collection('users')->truncate();
$this->assertEquals(0, DB::collection('users')->count());
}
public function testSubKey()
{
$user1 = 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