Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
imanghafoori1 committed Sep 2, 2023
1 parent d31e0ac commit c178cda
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ public function test_basic()
{
config()->set('database.default', 'my_test_connection');

// ::Arrange:: (Setup Sample Data)
# ::Arrange:: (Setup Sample Data)
FakeDB::addRow('users', ['id' => 1, 'username' => 'faky', 'password' => '...']);
FakeDB::addRow('users', ['id' => 1, 'username' => 'maky', 'password' => '...']);

// ::Act:: (This query resides in your controller)
# ::Act:: (This query resides in your controller)
$user = User::where('username', 'faky')->first(); # <=== This does NOT connect to a real DB.

// ::Assert::
# ::Assert::
$this->assert($user->id === 1);
$this->assert($user->username === 'faky');
}
Expand All @@ -65,18 +65,17 @@ public function test_basic()
```php
public function test_basic()
{
# ::Arrange::
# In setUp:
FakeDB::mockEloquentBuilder();

# ::Act::
// In your controller:
// $user = User::create(['username' => 'iman', 'email' => 'iman@gmail.com']); # <=== This does NOT connect to DB.
$this->post('/create-url', ['some' => 'data' ])

// ::Assert::
# ::Assert::
$user = User::first();
$this->assertEquals('iman', $user->username);


# In tearDown
FakeDB::dontMockEloquentBuilder();
}
```
Expand Down

0 comments on commit c178cda

Please sign in to comment.