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 RevenuesTest extends FeatureTestCase
public function testItShouldCreateRevenue()
{
$this->loginAs()
->post(route('revenues.store'), factory(Transaction::class)->raw())
->post(route('revenues.store'), $this->getRequest())
->assertStatus(200);
$this->assertFlashLevel('success');
@ -35,7 +35,7 @@ class RevenuesTest extends FeatureTestCase
public function testItShouldUpdateRevenue()
{
$request = factory(Transaction::class)->raw();
$request = $this->getRequest();
$revenue = $this->dispatch(new CreateTransaction($request));
@ -50,7 +50,7 @@ class RevenuesTest extends FeatureTestCase
public function testItShouldDeleteRevenue()
{
$revenue = $this->dispatch(new CreateTransaction(factory(Transaction::class)->raw()));
$revenue = $this->dispatch(new CreateTransaction($this->getRequest()));
$this->loginAs()
->delete(route('revenues.destroy', $revenue->id))
@ -58,4 +58,9 @@ class RevenuesTest extends FeatureTestCase
$this->assertFlashLevel('success');
}
public function getRequest()
{
return factory(Transaction::class)->states('income')->raw();
}
}