Skip to content

Commit

Permalink
Merge pull request #1906 from atishamte/subquery
Browse files Browse the repository at this point in the history
SubQuery related test cases w.r.t #1775
  • Loading branch information
lonnieezell authored Apr 3, 2019
2 parents 1c87d56 + 3e6e06e commit ac5fb10
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/system/Database/Live/WhereTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,42 @@ public function testWhereNotIn()

//--------------------------------------------------------------------

public function testSubQuery()
{
$subQuery = $this->db->table('job')
->select('id')
->where('name', 'Developer')
->getCompiledSelect();

$jobs = $this->db->table('job')
->where('id not in (' . $subQuery . ')', null, false)
->get()
->getResult();

$this->assertCount(3, $jobs);
$this->assertEquals('Politician', $jobs[0]->name);
$this->assertEquals('Accountant', $jobs[1]->name);
$this->assertEquals('Musician', $jobs[2]->name);
}

//--------------------------------------------------------------------

public function testSubQueryAnotherType()
{
$subQuery = $this->db->table('job')
->select('id')
->where('name', 'Developer')
->getCompiledSelect();

$jobs = $this->db->table('job')
->where('id = (' . $subQuery . ')', null, false)
->get()
->getResult();

$this->assertCount(1, $jobs);
$this->assertEquals('Developer', $jobs[0]->name);
}

//--------------------------------------------------------------------

}

0 comments on commit ac5fb10

Please sign in to comment.