/** * Test for INSERT INTO clause with subquery. * * @return void * * @since 11.3 */ public function test__toStringInsert_subquery() { $q = new JDatabaseQueryPostgresql($this->dbo); $subq = new JDatabaseQueryPostgresql($this->dbo); $subq->select('col2')->where('a=1'); $q->insert('table')->columns('col')->values($subq); $this->assertEquals(PHP_EOL . "INSERT INTO table" . PHP_EOL . "(col)" . PHP_EOL . "(" . PHP_EOL . "SELECT col2" . PHP_EOL . "WHERE a=1)", (string) $q); $q->clear(); $q->insert('table')->columns('col')->values('3'); $this->assertEquals(PHP_EOL . "INSERT INTO table" . PHP_EOL . "(col) VALUES " . PHP_EOL . "(3)", (string) $q); }
/** * Test for SELECT clause. * * @return void * * @since 11.3 */ public function testSelect() { $q = new JDatabaseQueryPostgresql($this->dbo); $this->assertThat($q->select('foo'), $this->identicalTo($q), 'Tests chaining.'); $this->assertThat($q->type, $this->equalTo('select'), 'Tests the type property is set correctly.'); $this->assertThat(trim($q->select), $this->equalTo('SELECT foo'), 'Tests the select element is set correctly.'); $q->select('bar'); $this->assertThat(trim($q->select), $this->equalTo('SELECT foo,bar'), 'Tests the second use appends correctly.'); $q->select(array('goo', 'car')); $this->assertThat(trim($q->select), $this->equalTo('SELECT foo,bar,goo,car'), 'Tests the second use appends correctly.'); }