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