improved factories and tests

This commit is contained in:
denisdulici
2020-01-07 01:28:05 +03:00
parent 472a4e00df
commit 751344f11a
13 changed files with 152 additions and 81 deletions

View File

@ -27,7 +27,7 @@ class PaymentsTest extends FeatureTestCase
public function testItShouldCreatePayment()
{
$this->loginAs()
->post(route('payments.store'), factory(Transaction::class)->states('expense')->raw())
->post(route('payments.store'), $this->getRequest())
->assertStatus(200);
$this->assertFlashLevel('success');
@ -35,7 +35,7 @@ class PaymentsTest extends FeatureTestCase
public function testItShouldUpdatePayment()
{
$request = factory(Transaction::class)->states('expense')->raw();
$request = $this->getRequest();
$payment = $this->dispatch(new CreateTransaction($request));
@ -50,7 +50,7 @@ class PaymentsTest extends FeatureTestCase
public function testItShouldDeletePayment()
{
$payment = $this->dispatch(new CreateTransaction(factory(Transaction::class)->states('expense')->raw()));
$payment = $this->dispatch(new CreateTransaction($this->getRequest()));
$this->loginAs()
->delete(route('payments.destroy', $payment->id))
@ -58,4 +58,9 @@ class PaymentsTest extends FeatureTestCase
$this->assertFlashLevel('success');
}
public function getRequest()
{
return factory(Transaction::class)->states('expense')->raw();
}
}