/** * Tests the \Joomla\Database\DatabaseQuery::andWhere method. * * @return void * * @since 1.3.0 */ public function testAndWhere() { $this->assertThat($this->instance->where('foo = 1')->andWhere('bar = 2'), $this->identicalTo($this->instance), 'Tests chaining.'); $this->assertThat(trim(TestHelper::getValue($this->instance, 'where')), $this->equalTo('WHERE ' . PHP_EOL . '(foo = 1) AND ' . PHP_EOL . '(bar = 2)'), 'Tests rendered value.'); // Add another set of where conditions. $this->instance->andWhere(array('baz = 3', 'goo = 4')); $this->assertThat(trim(TestHelper::getValue($this->instance, 'where')), $this->equalTo('WHERE ' . PHP_EOL . '(' . PHP_EOL . '(foo = 1) AND ' . PHP_EOL . '(bar = 2)) AND ' . PHP_EOL . '(baz = 3 OR goo = 4)'), 'Tests rendered value after second use and array input.'); // Add another set of where conditions with some different glue. $this->instance->andWhere(array('faz = 5', 'gaz = 6'), 'XOR'); $this->assertThat(trim(TestHelper::getValue($this->instance, 'where')), $this->equalTo('WHERE ' . PHP_EOL . '(' . PHP_EOL . '(' . PHP_EOL . '(foo = 1) AND ' . PHP_EOL . '(bar = 2)) AND ' . PHP_EOL . '(baz = 3 OR goo = 4)) AND ' . PHP_EOL . '(faz = 5 XOR gaz = 6)'), 'Tests rendered value after third use, array input and different glue.'); }