Skip to content

Commit

Permalink
add test for collection multiple wheres (#42908)
Browse files Browse the repository at this point in the history
  • Loading branch information
imanghafoori1 authored Jun 22, 2022
1 parent bb91c95 commit ce79bfa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,17 @@ public function testWhere($collection)
[['v' => 1], ['v' => 2]],
$c->where('v')->values()->all()
);

$c = new $collection([
['v' => 1, 'g' => 3],
['v' => 2, 'g' => 2],
['v' => 2, 'g' => 3],
['v' => 2, 'g' => null],
]);
$this->assertEquals([['v' => 2, 'g' => 3]], $c->where('v', 2)->where('g', 3)->values()->all());
$this->assertEquals([['v' => 2, 'g' => 3]], $c->where('v', 2)->where('g', '>', 2)->values()->all());
$this->assertEquals([], $c->where('v', 2)->where('g', 4)->values()->all());
$this->assertEquals([['v' => 2, 'g' => null]], $c->where('v', 2)->whereNull('g')->values()->all());
}

/**
Expand Down Expand Up @@ -1085,6 +1096,8 @@ public function testWhereIn($collection)
{
$c = new $collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]);
$this->assertEquals([['v' => 1], ['v' => 3], ['v' => '3']], $c->whereIn('v', [1, 3])->values()->all());
$this->assertEquals([], $c->whereIn('v', [2])->whereIn('v', [1, 3])->values()->all());
$this->assertEquals([['v' => 1]], $c->whereIn('v', [1])->whereIn('v', [1, 3])->values()->all());
}

/**
Expand All @@ -1103,6 +1116,7 @@ public function testWhereNotIn($collection)
{
$c = new $collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]);
$this->assertEquals([['v' => 2], ['v' => 4]], $c->whereNotIn('v', [1, 3])->values()->all());
$this->assertEquals([['v' => 4]], $c->whereNotIn('v', [2])->whereNotIn('v', [1, 3])->values()->all());
}

/**
Expand Down

0 comments on commit ce79bfa

Please sign in to comment.