Skip to content

Commit 856dffe

Browse files
author
Louis Kim
committed
Add test for find using array and where_key in eloquent builder
1 parent e9a8565 commit 856dffe

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/Integration/MutatorTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ public function test_find()
8888
$this->assertEquals($id, $p->id);
8989
}
9090

91+
public function test_array_of_find()
92+
{
93+
$id = Uuid::uuid1()->toString();
94+
$model = (new TestModel())->create(['id' => $id, 'name' => 'Name A']);
95+
$id2 = Uuid::uuid1()->toString();
96+
$model = (new TestModel())->create(['id' => $id2, 'name' => 'Name B']);
97+
$p = $model->find([$id, $id2]);
98+
$this->assertEquals(2, $p->count());
99+
$this->assertEquals($id, $p[0]->id);
100+
$this->assertEquals($id2, $p[1]->id);
101+
}
102+
91103
public function test_non_mutated_columns()
92104
{
93105
$id = Uuid::uuid1()->toString();
@@ -111,6 +123,18 @@ public function test_where_in()
111123
$this->assertEquals(2, $p->count());
112124
}
113125

126+
public function test_where_key()
127+
{
128+
$id = Uuid::uuid1()->toString();
129+
$id2 = Uuid::uuid1()->toString();
130+
$model = (new TestModel())->create(['id' => $id, 'name' => 'A chair']);
131+
$model2 = (new TestModel())->create(['id' => $id2, 'name' => 'A table']);
132+
$p = $model->whereKey([$id, $id2])->get();
133+
$this->assertEquals(2, $p->count());
134+
$this->assertEquals($id, $p[0]->id);
135+
$this->assertEquals($id2, $p[1]->id);
136+
}
137+
114138
public function test_update()
115139
{
116140
$id = Uuid::uuid1()->toString();

0 commit comments

Comments
 (0)