/**
  * 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);
 }
示例#2
0
文件: Entity.php 项目: danzabar/alice
 /**
  * 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;
 }
示例#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();
 }