public function testForgetModel()
 {
     $a = new A();
     $a->a = 1;
     $a->uniqueRequiredEmail = '*****@*****.**';
     $this->assertTrue($a->save());
     $modelIdentifier = $a->getModelIdentifier();
     $modelFromCache = RedBeanModelsCache::getModel($modelIdentifier);
     $this->assertEquals(1, $modelFromCache->a);
     $this->assertEquals('*****@*****.**', $modelFromCache->uniqueRequiredEmail);
     RedBeanModelsCache::forgetModel($a);
     try {
         RedBeanModelsCache::getModel($modelIdentifier);
         $this->fail('NotFoundException exception is not thrown.');
     } catch (NotFoundException $e) {
         $this->assertTrue(true);
     }
 }
예제 #2
0
 /**
  * Forgets about the object so that if it is retrieved
  * again it will be recreated from the database. For use in testing.
  */
 public function forget()
 {
     self::forgetBeanModel(get_called_class());
     RedBeanModelsCache::forgetModel($this);
     RedBeansCache::forgetBean(self::getTableName(get_called_class()) . $this->id);
 }