public function testAll() { $users = My_ShantyMongo_User::all(); $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $users); $this->assertEquals('Shanty_Mongo_Iterator_Cursor', get_class($users)); $this->assertEquals(3, $users->count()); $this->assertEquals('4c04516a1f5f5e21361e3ab0', $users->getNext()->getId()->__toString()); $this->assertEquals('4c04516f1f5f5e21361e3ab1', $users->getNext()->getId()->__toString()); $this->assertEquals('4c0451791f5f5e21361e3ab2', $users->getNext()->getId()->__toString()); $males = My_ShantyMongo_User::all(array('sex' => 'M')); $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $males); $this->assertEquals('Shanty_Mongo_Iterator_Cursor', get_class($males)); $this->assertEquals(2, $males->count()); $this->assertEquals('4c04516a1f5f5e21361e3ab0', $males->getNext()->getId()->__toString()); $this->assertEquals('4c0451791f5f5e21361e3ab2', $males->getNext()->getId()->__toString()); // Test inheritance $students = My_ShantyMongo_Student::all(); $this->assertEquals(2, $students->count()); $this->assertEquals('4c04516f1f5f5e21361e3ab1', $students->getNext()->getId()->__toString()); $this->assertEquals('4c0451791f5f5e21361e3ab2', $students->getNext()->getId()->__toString()); $artstudents = My_ShantyMongo_ArtStudent::all(); $this->assertEquals(1, $artstudents->count()); $this->assertEquals('4c0451791f5f5e21361e3ab2', $artstudents->getNext()->getId()->__toString()); // Test loading of partial documents $users = My_ShantyMongo_User::all(array(), array('name' => 1, 'email' => 1)); $firstUser = $users->getNext(); $this->assertEquals(array('_id', '_type', 'name', 'email'), $firstUser->getPropertyKeys()); $this->assertNull($firstUser->sex); }
public function testAll() { $users = My_ShantyMongo_User::all(); $this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $users); $this->assertEquals('Shanty_Mongo_Iterator_Cursor', get_class($users)); $this->assertEquals(3, $users->count()); $this->assertEquals('4c04516a1f5f5e21361e3ab0', $users->getNext()->getId()->__toString()); $this->assertEquals('4c04516f1f5f5e21361e3ab1', $users->getNext()->getId()->__toString()); $this->assertEquals('4c0451791f5f5e21361e3ab2', $users->getNext()->getId()->__toString()); $males = My_ShantyMongo_User::all(array('sex' => 'M')); $this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $males); $this->assertEquals('Shanty_Mongo_Iterator_Cursor', get_class($males)); $this->assertEquals(2, $males->count()); $this->assertEquals('4c04516a1f5f5e21361e3ab0', $males->getNext()->getId()->__toString()); $this->assertEquals('4c0451791f5f5e21361e3ab2', $males->getNext()->getId()->__toString()); // Test inheritance $students = My_ShantyMongo_Student::all(); $this->assertEquals(2, $students->count()); $this->assertEquals('4c04516f1f5f5e21361e3ab1', $students->getNext()->getId()->__toString()); $this->assertEquals('4c0451791f5f5e21361e3ab2', $students->getNext()->getId()->__toString()); $artstudents = My_ShantyMongo_ArtStudent::all(); $this->assertEquals(1, $artstudents->count()); $this->assertEquals('4c0451791f5f5e21361e3ab2', $artstudents->getNext()->getId()->__toString()); }