public function setUp() { if (!$this->modelClass) { throw new Exception("modelClass needs to be defined in the constructor."); } if (!class_exists($this->modelClass) || !is_subclass_of($this->modelClass, 'Dbi_Model')) { throw new Exception("'{$this->modelClass}' is not a valid Dbi_Model."); } self::$OldSource = Dbi_Source::GetGlobalSource(); // Mock source self::$Source = new MockDbi_Source(); $cls = $this->modelClass; self::$Source->returns('select', array(new Dbi_Record(new $cls(), $this->mockRecordData()))); self::$Source->returns('insert', $this->mockRecordData()); // Replace the configured global source with the mock Dbi_Source::SetGlobalSource(self::$Source); }
/** * Get a reference to the global database interface. * @return Dbi_Source */ public static function Database() { return Dbi_Source::GetGlobalSource(); }