示例#1
0
 /**
  * Tests the JDatabaseQuery::extendWhere method.
  *
  * @return  void
  *
  * @since   3.6
  */
 public function testExtendWhere()
 {
     $this->assertThat($this->_instance->where('foo = 1')->extendWhere('ABC', 'bar = 2'), $this->identicalTo($this->_instance), 'Tests chaining.');
     $this->assertThat(trim(TestReflection::getValue($this->_instance, 'where')), $this->equalTo('WHERE ' . PHP_EOL . '(foo = 1) ABC ' . PHP_EOL . '(bar = 2)'), 'Tests rendered value.');
     // Add another set of where conditions.
     $this->_instance->extendWhere('XYZ', array('baz = 3', 'goo = 4'));
     $this->assertThat(trim(TestReflection::getValue($this->_instance, 'where')), $this->equalTo('WHERE ' . PHP_EOL . '(' . PHP_EOL . '(foo = 1) ABC ' . PHP_EOL . '(bar = 2)) XYZ ' . PHP_EOL . '(baz = 3 AND goo = 4)'), 'Tests rendered value after second use and array input.');
     // Add another set of where conditions with some different glue.
     $this->_instance->extendWhere('STU', array('faz = 5', 'gaz = 6'), 'VWX');
     $this->assertThat(trim(TestReflection::getValue($this->_instance, 'where')), $this->equalTo('WHERE ' . PHP_EOL . '(' . PHP_EOL . '(' . PHP_EOL . '(foo = 1) ABC ' . PHP_EOL . '(bar = 2)) XYZ ' . PHP_EOL . '(baz = 3 AND goo = 4)) STU ' . PHP_EOL . '(faz = 5 VWX gaz = 6)'), 'Tests rendered value after third use, array input and different glue.');
 }