Exemple #1
0
 public function testFromMongo()
 {
     $mongoDoc = array('myInt' => 123, 'myArray' => array(1, 2, 3, 4, 5), 'myOwnSelf' => array('myString' => 'world'), 'myExtraField' => 'is allowed');
     $doc = new TestDocument();
     $doc->fromMongo($mongoDoc);
     $this->assertEquals($doc->myInt, 123);
     $this->assertEquals($doc->myOwnSelf->myString, 'world');
     $this->assertEquals($doc->myArray[0], 1);
     $this->assertEquals($doc->myExtraField, 'is allowed');
     $this->expectValidationFailure($doc);
     $doc->myOwnSelf->myInt = 100;
     $this->expectValidationSuccess($doc);
 }