/** * @covers ::whereNested * @covers ::where */ public function testWhereNested() { $b = new WhereBuilder(); $b->whereNot(function ($q) { $q->where('a', 12)->orWhere('b', 14); })->orWhere(function ($q) { $q->where('a', 14)->andWhere('b', [12, 14]); }); $tmp[] = ['type' => 'Basic', 'table' => '', 'cols' => ['a'], 'op' => '=', 'val' => 12, 'logic' => 'AND', 'not' => false]; $tmp[] = ['type' => 'Basic', 'table' => '', 'cols' => ['b'], 'op' => '=', 'val' => 14, 'logic' => 'OR', 'not' => false]; $where[] = ['type' => 'Nested', 'nested' => $tmp, 'logic' => 'AND', 'not' => true]; $tmp = []; $tmp[] = ['type' => 'Basic', 'table' => '', 'cols' => ['a'], 'op' => '=', 'val' => 14, 'logic' => 'AND', 'not' => false]; $tmp[] = ['type' => 'In', 'table' => '', 'cols' => ['b'], 'val' => [12, 14], 'logic' => 'AND', 'not' => false]; $where[] = ['type' => 'Nested', 'nested' => $tmp, 'logic' => 'OR', 'not' => false]; $components = $b->getComponents(); $this->assertEquals($where, $components['where']); }