/** * Tests the quoteName method. * * @param bool $quoted The value of the quoted argument. * @param string $expected The expected result. * * @return void * * @since 11.1 * @dataProvider dataTestNullDate */ public function testNullDate($quoted, $expected) { $q = new JDatabaseQueryInspector($this->dbo); $this->assertThat($q->nullDate($quoted), $this->equalTo($expected), 'The nullDate method should be a proxy for the JDatabase::getNullDate method.'); }
/** * Tests the JDatabaseQuery::format method. * * @return void * * @since 12.3 */ public function testFormat() { $q = new JDatabaseQueryInspector($this->dbo); $result = $q->format('SELECT %n FROM %n WHERE %n = %a', 'foo', '#__bar', 'id', 10); $expected = 'SELECT ' . $q->qn('foo') . ' FROM ' . $q->qn('#__bar') . ' WHERE ' . $q->qn('id') . ' = 10'; $this->assertThat($result, $this->equalTo($expected), 'Line: ' . __LINE__ . '.'); $result = $q->format('SELECT %n FROM %n WHERE %n = %t OR %3$n = %Z', 'id', '#__foo', 'date'); $expected = 'SELECT ' . $q->qn('id') . ' FROM ' . $q->qn('#__foo') . ' WHERE ' . $q->qn('date') . ' = ' . $q->currentTimestamp() . ' OR ' . $q->qn('date') . ' = ' . $q->nullDate(true); $this->assertThat($result, $this->equalTo($expected), 'Line: ' . __LINE__ . '.'); }
/** * Tests the JDatabaseQuery::nullDate method for an expected exception. * * @return void * * @expectedException JDatabaseException * @since 11.3 */ public function testNullDateException() { $q = new JDatabaseQueryInspector($this->dbo); // Override the internal database for testing. $q->db = new stdClass(); $q->nullDate(); }