Skip to content

Commit fb816b1

Browse files
committed
test: add tests for Model::find() with casts
1 parent 8c459cf commit fb816b1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/system/Models/DataConverterModelTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,28 @@ public function testFindAsEntity(): void
100100
$this->assertInstanceOf(Time::class, $user->created_at);
101101
}
102102

103+
public function testFindArrayAsEntity(): void
104+
{
105+
$id = $this->prepareOneRecord();
106+
107+
$users = $this->model->asObject(User::class)->find([$id, 999]);
108+
109+
$this->assertCount(1, $users);
110+
$this->assertIsInt($users[0]->id);
111+
$this->assertInstanceOf(Time::class, $users[0]->created_at);
112+
}
113+
114+
public function testFindNullAsEntity(): void
115+
{
116+
$this->prepareOneRecord();
117+
118+
$users = $this->model->asObject(User::class)->find();
119+
120+
$this->assertCount(1, $users);
121+
$this->assertIsInt($users[0]->id);
122+
$this->assertInstanceOf(Time::class, $users[0]->created_at);
123+
}
124+
103125
public function testFindAllAsArray(): void
104126
{
105127
$this->prepareTwoRecords();

0 commit comments

Comments
 (0)