Esempio n. 1
0
 public function testShouldThrowExceptionForInvalidId()
 {
     $exception = null;
     try {
         $child = new Child();
         $child->name = 'Child';
         $child->parent = DbRef::create('Parental', 'fake');
         $child->save();
     } catch (\Exception $e) {
         $exception = $e;
     }
     $this->assertInstanceOf('\\MongoException', $exception);
 }
Esempio n. 2
0
 public function testShouldThrowExceptionForInvalidMongoDBRef()
 {
     $parent = new Parental();
     $parent->name = 'Parent';
     $parent->save();
     $child = new Child();
     $child->name = 'Child';
     $child->parent = DbRef::create($parent);
     $child->save();
     $exception = null;
     try {
         $child->readRef('name');
     } catch (\Exception $e) {
         $exception = $e;
     }
     $this->assertInstanceOf('\\Vegas\\Db\\Adapter\\Mongo\\Exception\\InvalidReferenceException', $exception);
     $exception = null;
     try {
         $child->readRef('fake.nested');
     } catch (\Exception $e) {
         $exception = $e;
     }
     $this->assertInstanceOf('\\Vegas\\Db\\Adapter\\Mongo\\Exception\\InvalidReferenceException', $exception);
 }