Created
February 16, 2020 20:22
-
-
Save devmsh/8761c360eeac8f4f15a42f6445ecad1a to your computer and use it in GitHub Desktop.
Write better Laravel tests
This file contains 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_loan_generate_corresponding_transaction() | |
{ | |
$wallet = factory(Wallet::class)->create(); | |
$loan = Loan::log(factory(Loan::class)->make([ | |
'wallet_id' => $wallet->id | |
])->toArray()); | |
$transaction = $loan->transaction; | |
$this->assertEquals($loan->id, $transaction->causedby->id); | |
$this->assertEquals($loan->total, $transaction->amount); | |
$this->assertEquals($loan->user_id, $transaction->user_id); | |
} | |
public function test_loan_generate_corresponding_goal() | |
{ | |
$wallet = factory(Wallet::class)->create(); | |
$loan = Loan::log(factory(Loan::class)->make([ | |
'wallet_id' => $wallet->id | |
])->toArray()); | |
$goal = $loan->goal; | |
$this->assertEquals($loan->total, $goal->total); | |
$this->assertEquals($loan->user_id, $goal->user_id); | |
$this->assertEquals($loan->payoff_at, $goal->due_date); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment