/** * Tests the JDatabaseQuery::having method. * * @return void * * @since 11.3 */ public function testHaving() { $q = new JDatabaseQueryInspector($this->dbo); $this->assertThat($q->having('COUNT(foo) > 1'), $this->identicalTo($q), 'Tests chaining.'); $this->assertThat(trim($q->having), $this->equalTo('HAVING COUNT(foo) > 1'), 'Tests rendered value.'); // Add another column. $q->having('COUNT(bar) > 2'); $this->assertThat(trim($q->having), $this->equalTo('HAVING COUNT(foo) > 1 AND COUNT(bar) > 2'), 'Tests rendered value after second use.'); // Reset the field to test the glue. $q->having = null; $q->having('COUNT(foo) > 1', 'OR'); $q->having('COUNT(bar) > 2'); $this->assertThat(trim($q->having), $this->equalTo('HAVING COUNT(foo) > 1 OR COUNT(bar) > 2'), 'Tests rendered value with OR glue.'); }