/** * Test for the JDatabaseQuery::__call method. * * @return void * * @since 11.1 */ public function test__call() { $q = new JDatabaseQueryInspector($this->dbo); $this->assertThat($q->e('foo'), $this->equalTo($q->escape('foo')), 'Tests the e alias of escape.'); $this->assertThat($q->q('foo'), $this->equalTo($q->quote('foo')), 'Tests the q alias of quote.'); $this->assertThat($q->qn('foo'), $this->equalTo($q->quoteName('foo')), 'Tests the qn alias of quoteName.'); $this->assertThat($q->foo(), $this->isNull(), 'Tests for an unknown 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__ . '.'); }