Skip to content

Commit

Permalink
adding basic functionality test
Browse files Browse the repository at this point in the history
  • Loading branch information
sajed-zarrinpour committed Sep 6, 2024
1 parent 3c0da0c commit 087e46d
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,42 @@

final class ModelTest extends TestCase
{
public function testInsert(): void
public static function setUpBeforeClass() : void
{
$_ENV['TEST'] = true;

create_test_table();

return;
}
public function testInsert(): void
{
$user = new User;
$user->name = 'testUser';
$user->name = 'testInsert';

$this->assertTrue($user->save());
$this->assertIsInt($user->id);
}

public function testUpdate() : void
{
$user = new User;
$user->name = 'testUpdate';
$user->save();

$user->is_admin = true;
$this->assertTrue($user->save());
}

public function testFind() : void
{
$user = new User;
$user->name = 'testFind';
$user->save();

$found = User::find($user->id);

$this->assertEquals($user->id, $found->id);
$this->assertInstanceOf(User::class, $found);
}
}

use function SajedZarinpour\DB\config as config;
Expand Down

0 comments on commit 087e46d

Please sign in to comment.