Skip to content

Commit ce79bfa

Browse files
add test for collection multiple wheres (#42908)
1 parent bb91c95 commit ce79bfa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/Support/SupportCollectionTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,17 @@ public function testWhere($collection)
10521052
[['v' => 1], ['v' => 2]],
10531053
$c->where('v')->values()->all()
10541054
);
1055+
1056+
$c = new $collection([
1057+
['v' => 1, 'g' => 3],
1058+
['v' => 2, 'g' => 2],
1059+
['v' => 2, 'g' => 3],
1060+
['v' => 2, 'g' => null],
1061+
]);
1062+
$this->assertEquals([['v' => 2, 'g' => 3]], $c->where('v', 2)->where('g', 3)->values()->all());
1063+
$this->assertEquals([['v' => 2, 'g' => 3]], $c->where('v', 2)->where('g', '>', 2)->values()->all());
1064+
$this->assertEquals([], $c->where('v', 2)->where('g', 4)->values()->all());
1065+
$this->assertEquals([['v' => 2, 'g' => null]], $c->where('v', 2)->whereNull('g')->values()->all());
10551066
}
10561067

10571068
/**
@@ -1085,6 +1096,8 @@ public function testWhereIn($collection)
10851096
{
10861097
$c = new $collection([['v' => 1], ['v' => 2], ['v' => 3], ['v' => '3'], ['v' => 4]]);
10871098
$this->assertEquals([['v' => 1], ['v' => 3], ['v' => '3']], $c->whereIn('v', [1, 3])->values()->all());
1099+
$this->assertEquals([], $c->whereIn('v', [2])->whereIn('v', [1, 3])->values()->all());
1100+
$this->assertEquals([['v' => 1]], $c->whereIn('v', [1])->whereIn('v', [1, 3])->values()->all());
10881101
}
10891102

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

11081122
/**

0 commit comments

Comments
 (0)