added more db asserts

This commit is contained in:
Denis Duliçi 2020-07-25 17:22:50 +03:00
parent d8ea08643a
commit a3077d445d
15 changed files with 211 additions and 47 deletions

View File

@ -26,7 +26,11 @@ class DateFormat
continue; continue;
} }
$new_date = Date::parse($date)->format('Y-m-d') . ' ' . Date::now()->format('H:i:s'); if (Date::parse($date)->format('H:i:s') == '00:00:00') {
$new_date = Date::parse($date)->format('Y-m-d') . ' ' . Date::now()->format('H:i:s');
} else {
$new_date = Date::parse($date)->toDateTimeString();
}
$request->request->set($field, $new_date); $request->request->set($field, $new_date);
} }

View File

@ -20,8 +20,8 @@ $factory->define(Bill::class, function (Faker $faker) use ($company) {
session(['company_id' => $company->id]); session(['company_id' => $company->id]);
setting()->setExtraColumns(['company_id' => $company->id]); setting()->setExtraColumns(['company_id' => $company->id]);
$billed_at = $faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d'); $billed_at = $faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d H:i:s');
$due_at = Date::parse($billed_at)->addDays(10)->format('Y-m-d'); $due_at = Date::parse($billed_at)->addDays(10)->format('Y-m-d H:i:s');
$contacts = Contact::vendor()->enabled()->get(); $contacts = Contact::vendor()->enabled()->get();

View File

@ -21,8 +21,8 @@ $factory->define(Invoice::class, function (Faker $faker) use ($company) {
session(['company_id' => $company->id]); session(['company_id' => $company->id]);
setting()->setExtraColumns(['company_id' => $company->id]); setting()->setExtraColumns(['company_id' => $company->id]);
$invoiced_at = $faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d'); $invoiced_at = $faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d H:i:s');
$due_at = Date::parse($invoiced_at)->addDays(setting('invoice.payment_terms'))->format('Y-m-d'); $due_at = Date::parse($invoiced_at)->addDays(setting('invoice.payment_terms'))->format('Y-m-d H:i:s');
$contacts = Contact::customer()->enabled()->get(); $contacts = Contact::customer()->enabled()->get();

View File

@ -17,10 +17,10 @@ $factory->define(Transaction::class, function (Faker $faker) use ($company) {
'company_id' => $company->id, 'company_id' => $company->id,
'type' => $type, 'type' => $type,
'account_id' => setting('default.account'), 'account_id' => setting('default.account'),
'paid_at' => $faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d'), 'paid_at' => $faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d H:i:s'),
'amount' => $faker->randomFloat(2, 1, 1000), 'amount' => $faker->randomFloat(2, 1, 1000),
'currency_code' => setting('default.currency'), 'currency_code' => setting('default.currency'),
'currency_rate' => '1', 'currency_rate' => '1.0',
'description' => $faker->text(5), 'description' => $faker->text(5),
'category_id' => $company->categories()->type($type)->get()->random(1)->pluck('id')->first(), 'category_id' => $company->categories()->type($type)->get()->random(1)->pluck('id')->first(),
'reference' => $faker->text(5), 'reference' => $faker->text(5),

View File

@ -26,25 +26,39 @@ class BillsTest extends FeatureTestCase
public function testItShouldCreateBill() public function testItShouldCreateBill()
{ {
$request = $this->getRequest();
$this->loginAs() $this->loginAs()
->post(route('bills.store'), $this->getRequest()) ->post(route('bills.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('bills', [
'bill_number' => $request['bill_number'],
]);
} }
public function testItShouldCreateBillWithRecurring() public function testItShouldCreateBillWithRecurring()
{ {
$request = $this->getRequest(true);
$this->loginAs() $this->loginAs()
->post(route('bills.store'), $this->getRequest(true)) ->post(route('bills.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('bills', [
'bill_number' => $request['bill_number'],
]);
} }
public function testItShouldSeeBillUpdatePage() public function testItShouldSeeBillUpdatePage()
{ {
$bill = $this->dispatch(new CreateBill($this->getRequest())); $request = $this->getRequest();
$bill = $this->dispatch(new CreateBill($request));
$this->loginAs() $this->loginAs()
->get(route('bills.edit', $bill->id)) ->get(route('bills.edit', $bill->id))
@ -66,17 +80,28 @@ class BillsTest extends FeatureTestCase
->assertSee($request['contact_email']); ->assertSee($request['contact_email']);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('bills', [
'bill_number' => $request['bill_number'],
'contact_email' => $request['contact_email'],
]);
} }
public function testItShouldDeleteBill() public function testItShouldDeleteBill()
{ {
$bill = $this->dispatch(new CreateBill($this->getRequest())); $request = $this->getRequest();
$bill = $this->dispatch(new CreateBill($request));
$this->loginAs() $this->loginAs()
->delete(route('bills.destroy', $bill->id)) ->delete(route('bills.destroy', $bill->id))
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertSoftDeleted('bills', [
'bill_number' => $request['bill_number'],
]);
} }
public function getRequest($recurring = false) public function getRequest($recurring = false)

View File

@ -26,16 +26,22 @@ class PaymentsTest extends FeatureTestCase
public function testItShouldCreatePayment() public function testItShouldCreatePayment()
{ {
$request = $this->getRequest();
$this->loginAs() $this->loginAs()
->post(route('payments.store'), $this->getRequest()) ->post(route('payments.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('transactions', $request);
} }
public function testItShouldSeePaymentUpdatePage() public function testItShouldSeePaymentUpdatePage()
{ {
$payment = $this->dispatch(new CreateTransaction($this->getRequest())); $request = $this->getRequest();
$payment = $this->dispatch(new CreateTransaction($request));
$this->loginAs() $this->loginAs()
->get(route('payments.edit', $payment->id)) ->get(route('payments.edit', $payment->id))
@ -57,17 +63,23 @@ class PaymentsTest extends FeatureTestCase
->assertSee($request['amount']); ->assertSee($request['amount']);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('transactions', $request);
} }
public function testItShouldDeletePayment() public function testItShouldDeletePayment()
{ {
$payment = $this->dispatch(new CreateTransaction($this->getRequest())); $request = $this->getRequest();
$payment = $this->dispatch(new CreateTransaction($request));
$this->loginAs() $this->loginAs()
->delete(route('payments.destroy', $payment->id)) ->delete(route('payments.destroy', $payment->id))
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertSoftDeleted('transactions', $request);
} }
public function getRequest() public function getRequest()

View File

@ -26,16 +26,22 @@ class VendorsTest extends FeatureTestCase
public function testItShouldCreateVendor() public function testItShouldCreateVendor()
{ {
$request = $this->getRequest();
$this->loginAs() $this->loginAs()
->post(route('vendors.store'), $this->getRequest()) ->post(route('vendors.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('contacts', $request);
} }
public function testItShouldSeeVendorDetailPage() public function testItShouldSeeVendorDetailPage()
{ {
$vendor = $this->dispatch(new CreateContact($this->getRequest())); $request = $this->getRequest();
$vendor = $this->dispatch(new CreateContact($request));
$this->loginAs() $this->loginAs()
->get(route('vendors.show', $vendor->id)) ->get(route('vendors.show', $vendor->id))
@ -45,12 +51,16 @@ class VendorsTest extends FeatureTestCase
public function testItShouldSeeVendorUpdatePage() public function testItShouldSeeVendorUpdatePage()
{ {
$vendor = $this->dispatch(new CreateContact($this->getRequest())); $request = $this->getRequest();
$vendor = $this->dispatch(new CreateContact($request));
$this->loginAs() $this->loginAs()
->get(route('vendors.edit', $vendor->id)) ->get(route('vendors.edit', $vendor->id))
->assertStatus(200) ->assertStatus(200)
->assertSee($vendor->email); ->assertSee($vendor->email);
$this->assertDatabaseHas('contacts', $request);
} }
public function testItShouldUpdateVendor() public function testItShouldUpdateVendor()
@ -67,17 +77,23 @@ class VendorsTest extends FeatureTestCase
->assertSee($request['email']); ->assertSee($request['email']);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('contacts', $request);
} }
public function testItShouldDeleteVendor() public function testItShouldDeleteVendor()
{ {
$vendor = $this->dispatch(new CreateContact($this->getRequest())); $request = $this->getRequest();
$vendor = $this->dispatch(new CreateContact($request));
$this->loginAs() $this->loginAs()
->delete(route('vendors.destroy', $vendor->id)) ->delete(route('vendors.destroy', $vendor->id))
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertSoftDeleted('contacts', $request);
} }
public function getRequest() public function getRequest()

View File

@ -25,34 +25,40 @@ class CustomersTest extends FeatureTestCase
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.customers', 1)])); ->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.customers', 1)]));
} }
public function testItShouldCreateOnlyCustomerWithoutUser() public function testItShouldCreateCustomer()
{ {
$request = $this->getRequest();
$this->loginAs() $this->loginAs()
->post(route('customers.store'), $this->getRequest()) ->post(route('customers.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('contacts', $request);
} }
public function testItShouldCreateCustomerWithUser() public function testItShouldCreateCustomerWithUser()
{ {
$customer = $this->getRequestWithUser(); $request = $this->getRequestWithUser();
$this->loginAs() $this->loginAs()
->post(route('customers.store'), $customer) ->post(route('customers.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$user = User::where('email', $customer['email'])->first(); $user = User::where('email', $request['email'])->first();
$this->assertNotNull($user); $this->assertNotNull($user);
$this->assertEquals($customer['email'], $user->email); $this->assertEquals($request['email'], $user->email);
} }
public function testItShouldSeeCustomerDetailPage() public function testItShouldSeeCustomerDetailPage()
{ {
$customer = $this->dispatch(new CreateContact($this->getRequest())); $request = $this->getRequest();
$customer = $this->dispatch(new CreateContact($request));
$this->loginAs() $this->loginAs()
->get(route('customers.show', $customer->id)) ->get(route('customers.show', $customer->id))
@ -62,7 +68,9 @@ class CustomersTest extends FeatureTestCase
public function testItShouldSeeCustomerUpdatePage() public function testItShouldSeeCustomerUpdatePage()
{ {
$customer = $this->dispatch(new CreateContact($this->getRequest())); $request = $this->getRequest();
$customer = $this->dispatch(new CreateContact($request));
$this->loginAs() $this->loginAs()
->get(route('customers.edit', $customer->id)) ->get(route('customers.edit', $customer->id))
@ -84,11 +92,15 @@ class CustomersTest extends FeatureTestCase
->assertSee($request['email']); ->assertSee($request['email']);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('contacts', $request);
} }
public function testItShouldDeleteCustomer() public function testItShouldDeleteCustomer()
{ {
$customer = $this->dispatch(new CreateContact($this->getRequest())); $request = $this->getRequest();
$customer = $this->dispatch(new CreateContact($request));
$this->loginAs() $this->loginAs()
->delete(route('customers.destroy', $customer->id)) ->delete(route('customers.destroy', $customer->id))
@ -96,6 +108,8 @@ class CustomersTest extends FeatureTestCase
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertSoftDeleted('contacts', $request);
} }
public function testItShouldNotDeleteCustomerIfHasRelations() public function testItShouldNotDeleteCustomerIfHasRelations()

View File

@ -26,25 +26,39 @@ class InvoicesTest extends FeatureTestCase
public function testItShouldCreateInvoice() public function testItShouldCreateInvoice()
{ {
$request = $this->getRequest();
$this->loginAs() $this->loginAs()
->post(route('invoices.store'), $this->getRequest()) ->post(route('invoices.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('invoices', [
'invoice_number' => $request['invoice_number'],
]);
} }
public function testItShouldCreateInvoiceWithRecurring() public function testItShouldCreateInvoiceWithRecurring()
{ {
$request = $this->getRequest(true);
$this->loginAs() $this->loginAs()
->post(route('invoices.store'), $this->getRequest(true)) ->post(route('invoices.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('invoices', [
'invoice_number' => $request['invoice_number'],
]);
} }
public function testItShouldSeeInvoiceUpdatePage() public function testItShouldSeeInvoiceUpdatePage()
{ {
$invoice = $this->dispatch(new CreateInvoice($this->getRequest())); $request = $this->getRequest();
$invoice = $this->dispatch(new CreateInvoice($request));
$this->loginAs() $this->loginAs()
->get(route('invoices.edit', $invoice->id)) ->get(route('invoices.edit', $invoice->id))
@ -66,17 +80,28 @@ class InvoicesTest extends FeatureTestCase
->assertSee($request['contact_email']); ->assertSee($request['contact_email']);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('invoices', [
'invoice_number' => $request['invoice_number'],
'contact_email' => $request['contact_email'],
]);
} }
public function testItShouldDeleteInvoice() public function testItShouldDeleteInvoice()
{ {
$invoice = $this->dispatch(new CreateInvoice($this->getRequest())); $request = $this->getRequest();
$invoice = $this->dispatch(new CreateInvoice($request));
$this->loginAs() $this->loginAs()
->delete(route('invoices.destroy', $invoice->id)) ->delete(route('invoices.destroy', $invoice->id))
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertSoftDeleted('invoices', [
'invoice_number' => $request['invoice_number'],
]);
} }
public function getRequest($recurring = false) public function getRequest($recurring = false)

View File

@ -26,16 +26,22 @@ class RevenuesTest extends FeatureTestCase
public function testItShouldCreateRevenue() public function testItShouldCreateRevenue()
{ {
$request = $this->getRequest();
$this->loginAs() $this->loginAs()
->post(route('revenues.store'), $this->getRequest()) ->post(route('revenues.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('transactions', $request);
} }
public function testItShouldSeeRevenueUpdatePage() public function testItShouldSeeRevenueUpdatePage()
{ {
$revenue = $this->dispatch(new CreateTransaction($this->getRequest())); $request = $this->getRequest();
$revenue = $this->dispatch(new CreateTransaction($request));
$this->loginAs() $this->loginAs()
->get(route('revenues.edit', $revenue->id)) ->get(route('revenues.edit', $revenue->id))
@ -57,17 +63,23 @@ class RevenuesTest extends FeatureTestCase
->assertSee($request['amount']); ->assertSee($request['amount']);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('transactions', $request);
} }
public function testItShouldDeleteRevenue() public function testItShouldDeleteRevenue()
{ {
$revenue = $this->dispatch(new CreateTransaction($this->getRequest())); $request = $this->getRequest();
$revenue = $this->dispatch(new CreateTransaction($request));
$this->loginAs() $this->loginAs()
->delete(route('revenues.destroy', $revenue->id)) ->delete(route('revenues.destroy', $revenue->id))
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertSoftDeleted('transactions', $request);
} }
public function getRequest() public function getRequest()

View File

@ -26,16 +26,22 @@ class CategoriesTest extends FeatureTestCase
public function testItShouldCreateCategory() public function testItShouldCreateCategory()
{ {
$request = $this->getRequest();
$this->loginAs() $this->loginAs()
->post(route('categories.store'), $this->getRequest()) ->post(route('categories.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('categories', $request);
} }
public function testItShouldSeeCategoryUpdatePage() public function testItShouldSeeCategoryUpdatePage()
{ {
$category = $this->dispatch(new CreateCategory($this->getRequest())); $request = $this->getRequest();
$category = $this->dispatch(new CreateCategory($request));
$this->loginAs() $this->loginAs()
->get(route('categories.edit', $category->id)) ->get(route('categories.edit', $category->id))
@ -57,17 +63,23 @@ class CategoriesTest extends FeatureTestCase
->assertSee($request['name']); ->assertSee($request['name']);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('categories', $request);
} }
public function testItShouldDeleteCategory() public function testItShouldDeleteCategory()
{ {
$category = $this->dispatch(new CreateCategory($this->getRequest())); $request = $this->getRequest();
$category = $this->dispatch(new CreateCategory($request));
$this->loginAs() $this->loginAs()
->delete(route('categories.destroy', $category->id)) ->delete(route('categories.destroy', $category->id))
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertSoftDeleted('categories', $request);
} }
public function getRequest() public function getRequest()

View File

@ -26,16 +26,22 @@ class CurrenciesTest extends FeatureTestCase
public function testItShouldCreateCurrency() public function testItShouldCreateCurrency()
{ {
$request = $this->getRequest();
$this->loginAs() $this->loginAs()
->post(route('currencies.store'), $this->getRequest()) ->post(route('currencies.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('currencies', $request);
} }
public function testItShouldSeeCurrencyUpdatePage() public function testItShouldSeeCurrencyUpdatePage()
{ {
$currency = $this->dispatch(new CreateCurrency($this->getRequest())); $request = $this->getRequest();
$currency = $this->dispatch(new CreateCurrency($request));
$this->loginAs() $this->loginAs()
->get(route('currencies.edit', $currency->id)) ->get(route('currencies.edit', $currency->id))
@ -57,17 +63,23 @@ class CurrenciesTest extends FeatureTestCase
->assertSee($request['name']); ->assertSee($request['name']);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('currencies', $request);
} }
public function testItShouldDeleteCurrency() public function testItShouldDeleteCurrency()
{ {
$currency = $this->dispatch(new CreateCurrency($this->getRequest())); $request = $this->getRequest();
$currency = $this->dispatch(new CreateCurrency($request));
$this->loginAs() $this->loginAs()
->delete(route('currencies.destroy', $currency->id)) ->delete(route('currencies.destroy', $currency->id))
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertSoftDeleted('currencies', $request);
} }
public function getRequest() public function getRequest()

View File

@ -26,16 +26,22 @@ class TaxesTest extends FeatureTestCase
public function testItShouldCreateTax() public function testItShouldCreateTax()
{ {
$request = $this->getRequest();
$this->loginAs() $this->loginAs()
->post(route('taxes.store'), $this->getRequest()) ->post(route('taxes.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('taxes', $request);
} }
public function testItShouldSeeTaxUpdatePage() public function testItShouldSeeTaxUpdatePage()
{ {
$tax = $this->dispatch(new CreateTax($this->getRequest())); $request = $this->getRequest();
$tax = $this->dispatch(new CreateTax($request));
$this->loginAs() $this->loginAs()
->get(route('taxes.edit', $tax->id)) ->get(route('taxes.edit', $tax->id))
@ -57,17 +63,23 @@ class TaxesTest extends FeatureTestCase
->assertSee($request['name']); ->assertSee($request['name']);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('taxes', $request);
} }
public function testItShouldDeleteTax() public function testItShouldDeleteTax()
{ {
$tax = $this->dispatch(new CreateTax($this->getRequest())); $request = $this->getRequest();
$tax = $this->dispatch(new CreateTax($request));
$this->loginAs() $this->loginAs()
->delete(route('taxes.destroy', $tax->id)) ->delete(route('taxes.destroy', $tax->id))
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('taxes', $request);
} }
public function getRequest() public function getRequest()

View File

@ -17,11 +17,15 @@ class CurrenciesTest extends FeatureTestCase
public function testItShouldCreateCurrency() public function testItShouldCreateCurrency()
{ {
$request = $this->getRequest();
$this->loginAs() $this->loginAs()
->post(route('wizard.currencies.store'), $this->getRequest()) ->post(route('wizard.currencies.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('currencies', $request);
} }
public function testItShouldUpdateCurrency() public function testItShouldUpdateCurrency()
@ -37,17 +41,23 @@ class CurrenciesTest extends FeatureTestCase
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('currencies', $request);
} }
public function testItShouldDeleteCurrency() public function testItShouldDeleteCurrency()
{ {
$currency = $this->dispatch(new CreateCurrency($this->getRequest())); $request = $this->getRequest();
$currency = $this->dispatch(new CreateCurrency($request));
$this->loginAs() $this->loginAs()
->delete(route('wizard.currencies.destroy', $currency->id)) ->delete(route('wizard.currencies.destroy', $currency->id))
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertSoftDeleted('currencies', $request);
} }
public function getRequest() public function getRequest()

View File

@ -17,11 +17,15 @@ class TaxesTest extends FeatureTestCase
public function testItShouldCreateTax() public function testItShouldCreateTax()
{ {
$request = $this->getRequest();
$this->loginAs() $this->loginAs()
->post(route('wizard.taxes.store'), $this->getRequest()) ->post(route('wizard.taxes.store'), $request)
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('taxes', $request);
} }
public function testItShouldUpdateTax() public function testItShouldUpdateTax()
@ -37,17 +41,23 @@ class TaxesTest extends FeatureTestCase
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('taxes', $request);
} }
public function testItShouldDeleteTax() public function testItShouldDeleteTax()
{ {
$tax = $this->dispatch(new CreateTax($this->getRequest())); $request = $this->getRequest();
$tax = $this->dispatch(new CreateTax($request));
$this->loginAs() $this->loginAs()
->delete(route('wizard.taxes.destroy', $tax->id)) ->delete(route('wizard.taxes.destroy', $tax->id))
->assertStatus(200); ->assertStatus(200);
$this->assertFlashLevel('success'); $this->assertFlashLevel('success');
$this->assertDatabaseHas('taxes', $request);
} }
public function getRequest() public function getRequest()