/**
  * Uses the static method approach if our DI var is null
  *
  * @return Object
  * @author Dan Cox
  */
 public function __get($service)
 {
     if (is_null($this->DI)) {
         return DI::get($service);
     }
     return $this->DI->get($service);
 }
Beispiel #2
0
 /**
  * Returns a database object loaded with the model name
  *
  * @return Database
  * @author Dan Cox
  */
 public static function db()
 {
     $entity = get_called_class();
     $db = DI::get('database');
     $db->setModel($entity);
     return $db;
 }
Beispiel #3
0
 /**
  * Test the delete function
  *
  * @return void
  * @author Dan Cox
  */
 public function test_removeModel()
 {
     DI::addMock('database', $this->database);
     $this->database->shouldReceive('getEntity')->andReturn($this->database);
     $this->database->shouldReceive('remove');
     $this->database->shouldReceive('flush');
     $this->entity->delete();
 }