Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: review-fix
  • Loading branch information
zigzagdev committed Jun 25, 2025
commit 6ecd5279422805597c2caa1713672ca4bf35f133
25 changes: 7 additions & 18 deletions tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,22 @@ public function testQualifyColumn(): void
$this->assertEquals('users.name', $sqlUser->qualifyColumn('name'));
}

private function makeUser(array $overrides = []): User
private function makeUser(): User
{
$defaults = [
'name' => 'John Doe',
'title' => 'admin',
'age' => 35,
];

$user = new User();
foreach (array_merge($defaults, $overrides) as $key => $value) {
$user->$key = $value;
}
$user->name = 'John Doe';
$user->title = 'admin';
$user->age = 35;

$user->save();

return $user;
}

public function testInsert(): void
{
$user = $this->makeUser();

$user->save();

$this->assertTrue($user->exists);
$this->assertEquals(1, User::count());

Expand All @@ -127,7 +122,6 @@ public function testInsert(): void
public function testUpdate(): void
{
$user = $this->makeUser();
$user->save();

$raw = $user->getAttributes();
$this->assertInstanceOf(ObjectID::class, $raw['id']);
Expand Down Expand Up @@ -243,7 +237,6 @@ public function testManualIntId(): void
public function testDelete(): void
{
$user = $this->makeUser();
$user->save();

$this->assertTrue($user->exists);
$this->assertEquals(1, User::count());
Expand All @@ -256,7 +249,6 @@ public function testDelete(): void
public function testAll(): void
{
$user = $this->makeUser();
$user->save();

$user = new User();
$user->name = 'Jane Doe';
Expand All @@ -274,7 +266,6 @@ public function testAll(): void
public function testFind(): void
{
$user = $this->makeUser();
$user->save();

$check = User::find($user->id);
$this->assertInstanceOf(User::class, $check);
Expand Down Expand Up @@ -354,7 +345,6 @@ public function testCreate(): void
public function testDestroy(): void
{
$user = $this->makeUser();
$user->save();

User::destroy((string) $user->id);

Expand All @@ -364,7 +354,6 @@ public function testDestroy(): void
public function testTouch(): void
{
$user = $this->makeUser();
$user->save();

$old = $user->updated_at;
sleep(1);
Expand Down
Loading