Exemplo n.º 1
0
 public function testOne()
 {
     $roger = My_ShantyMongo_User::one(array('name.first' => 'Roger'));
     $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $roger);
     $this->assertEquals('My_ShantyMongo_ArtStudent', get_class($roger));
     $this->assertEquals('Roger', $roger->name->first);
     $this->assertEquals($this->_users['roger'], $roger->export());
     // Find only rodger's name and email
     $roger = My_ShantyMongo_User::one(array('name.first' => 'Roger'), array('name' => 1, 'email' => 1));
     $this->assertEquals('My_ShantyMongo_ArtStudent', get_class($roger));
     $this->assertEquals(4, count($roger));
     $this->assertEquals(array('_id', '_type', 'name', 'email'), $roger->getPropertyKeys());
     $this->assertEquals('Roger', $roger->name->first);
     $this->assertNull($roger->sex);
     // No teacher by the name of roger exists
     $roger = My_ShantyMongo_Teacher::fetchOne(array('name.first' => 'Roger'));
     $this->assertNull($roger);
 }
Exemplo n.º 2
0
 public function testOne()
 {
     $roger = My_ShantyMongo_User::one(array('name.first' => 'Roger'));
     $this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $roger);
     $this->assertEquals('My_ShantyMongo_ArtStudent', get_class($roger));
     $this->assertEquals('Roger', $roger->name->first);
     $this->assertEquals($this->_users['roger'], $roger->export());
 }