Skip to content

Commit

Permalink
test: add tests for Model::find() with casts
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Jun 5, 2024
1 parent 8c459cf commit fb816b1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/system/Models/DataConverterModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,28 @@ public function testFindAsEntity(): void
$this->assertInstanceOf(Time::class, $user->created_at);
}

public function testFindArrayAsEntity(): void
{
$id = $this->prepareOneRecord();

$users = $this->model->asObject(User::class)->find([$id, 999]);

$this->assertCount(1, $users);
$this->assertIsInt($users[0]->id);
$this->assertInstanceOf(Time::class, $users[0]->created_at);
}

public function testFindNullAsEntity(): void
{
$this->prepareOneRecord();

$users = $this->model->asObject(User::class)->find();

$this->assertCount(1, $users);
$this->assertIsInt($users[0]->id);
$this->assertInstanceOf(Time::class, $users[0]->created_at);
}

public function testFindAllAsArray(): void
{
$this->prepareTwoRecords();
Expand Down

0 comments on commit fb816b1

Please sign in to comment.