Skip to content

Commit

Permalink
Added tests for batch insert
Browse files Browse the repository at this point in the history
  • Loading branch information
coen-hyde committed May 14, 2011
1 parent 31765be commit 48e5b0d
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/Shanty/Mongo/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ public function testInsert()
'sex' => 'M'
);

My_ShantyMongo_User::insert($sarah);
My_ShantyMongo_User::insert($sarah, array('safe' => true));

$user = My_ShantyMongo_User::find('4c04d5101f5f5e21361e3ab5');

Expand All @@ -371,6 +371,34 @@ public function testInsert()
$users = My_ShantyMongo_User::all();
$this->assertEquals(4, $users->count());
}

public function testInsertBatch()
{
$data = array(
array(
'_id' => new MongoId('4c04d5101f5f5e21361e3ab6'),
'name' => 'green',
'hex' => '006600'
),
array(
'_id' => new MongoId('4c04d5101f5f5e21361e3ab7'),
'name' => 'blue',
'hex' => '0000CC'
),
array(
'_id' => new MongoId('4c04d5101f5f5e21361e3ab8'),
'name' => 'red',
'hex' => 'FF0000'
),
);

My_ShantyMongo_Simple::insertBatch($data, array('safe' => true));
$colours = My_ShantyMongo_Simple::all();

$colour = $colours->getNext();
$this->assertEquals('green', $colour->name);
$this->assertEquals(3, $colours->count());
}

/**
* @depends testFind
Expand Down

0 comments on commit 48e5b0d

Please sign in to comment.