Created
February 16, 2020 19:49
-
-
Save devmsh/6376b4e6c030b3a9e0816ea2cb696b3e to your computer and use it in GitHub Desktop.
Write better Laravel tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class LoanTest extends TestCase{ | |
| public function test_can_log_a_loan() | |
| { | |
| $user = factory(User::class)->create(); | |
| $wallet = factory(Wallet::class)->create([ | |
| 'user_id' => $user->id | |
| ]); | |
| $this->passportAs($user) | |
| ->post('api/loans', [ | |
| 'total' => 1000, | |
| 'payoff_at' => Carbon::today()->addYear(), | |
| 'wallet_id' => $wallet->id, | |
| ]) | |
| ->assertSuccessful() | |
| ->assertJson([ | |
| 'id' => 1, | |
| 'total' => 1000, | |
| 'payoff_at' => Carbon::today()->addYear(), | |
| 'user_id' => $user->id, | |
| ]); | |
| /** @var Transaction $transaction */ | |
| // .. | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment