diff --git a/tests/system/Database/Live/WhereTest.php b/tests/system/Database/Live/WhereTest.php index af015d686858..82208d924e6d 100644 --- a/tests/system/Database/Live/WhereTest.php +++ b/tests/system/Database/Live/WhereTest.php @@ -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); + } + + //-------------------------------------------------------------------- + }