/** * Test for HAVING clause using a simple condition and with glue for second one. * * @return void * * @since 11.3 */ public function testHaving() { $q = new JDatabaseQueryPostgresql($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. TestReflection::setValue($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.'); }