/** * Gets a mock database object. * * @return JDatabase * * @since 12.1 */ public function getMockDatabase() { // Attempt to load the real class first. class_exists('JDatabaseDriver'); return TestMockDatabaseDriver::create($this); }
/** * Tests the setDb method. * * @return void * * @since 12.1 */ public function testSetDb() { $db = TestMockDatabaseDriver::create($this); $this->_instance->setDb($db); $this->assertAttributeSame($db, 'db', $this->_instance); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { $this->dbo = TestMockDatabaseDriver::create($this, '1970-01-01 00:00:00', 'Y-m-d H:i:s'); // Mock the escape method to ensure the API is calling the DBO's escape method. $this->assignMockCallbacks($this->dbo, array('escape' => array($this, 'mockEscape'))); }
/** * Gets a mock database object. * * @param string $driver Optional driver to create a sub-class of JDatabaseDriver * @param array $extraMethods An array of additional methods to add to the mock * @param string $nullDate A null date string for the driver. * @param string $dateFormat A date format for the driver. * * @return JDatabaseDriver * * @since 12.1 */ public function getMockDatabase($driver = '', array $extraMethods = array(), $nullDate = '0000-00-00 00:00:00', $dateFormat = 'Y-m-d H:i:s') { // Attempt to load the real class first. class_exists('JDatabaseDriver'); return TestMockDatabaseDriver::create($this, $driver, $extraMethods, $nullDate, $dateFormat); }
/** * Setup the tests. * * @return void * * @since 12.1 */ protected function setUp() { parent::setUp(); $this->saveFactoryState(); JFactory::$database = TestMockDatabaseDriver::create($this); $this->_instance = new DatabaseModel(); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { parent::setUp(); $this->dbo = TestMockDatabaseDriver::create($this, '1970-01-01 00:00:00', 'Y-m-d H:i:s'); $this->_instance = new JDatabaseQueryPostgresqlInspector($this->dbo); // Mock the escape method to ensure the API is calling the DBO's escape method. $this->assignMockCallbacks($this->dbo, array('escape' => array($this, 'mockEscape'))); }