solve unit tests

This commit is contained in:
harshjagad20
2021-12-01 13:25:24 +05:30
parent f57fa41640
commit 88bfb38b56
33 changed files with 205 additions and 219 deletions

View File

@ -8,10 +8,10 @@ beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
});
test('company has one customer', function () {
$company = Company::factory()->hasCustomer()->create();
test('company has many customers', function () {
$company = Company::factory()->hasCustomers()->create();
$this->assertTrue($company->customer()->exists());
$this->assertTrue($company->customers()->exists());
});
test('company has many company setings', function () {

View File

@ -16,7 +16,7 @@ test('an exchange rate log belongs to company', function () {
test('add exchange rate log', function () {
$expense = Expense::factory()->create();
$response = ExchangeRateLog::addExchangeRateLog($expense, $expense->currency_id);
$response = ExchangeRateLog::addExchangeRateLog($expense);
$this->assertDatabaseHas('exchange_Rate_logs', [
'exchange_rate' => $response->exchange_rate,

View File

@ -10,8 +10,6 @@ use Illuminate\Support\Facades\Artisan;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'UnitSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'PaymentMethodSeeder', '--force' => true]);
});
test('invoice has many invoice items', function () {
@ -114,7 +112,7 @@ test('update invoice', function () {
array_push($newInvoice['items'], $item);
array_push($newInvoice['taxes'], $tax);
$request = new Request();
$request = new InvoicesRequest();
$request->replace($newInvoice);
@ -161,7 +159,7 @@ test('create items', function () {
$request->replace(['items' => $items ]);
Invoice::createItems($invoice, $request, $invoice->exchange_rate);
Invoice::createItems($invoice, $request->items);
$this->assertDatabaseHas('invoice_items', [
'invoice_id' => $invoice->id,
@ -188,7 +186,7 @@ test('create taxes', function () {
$request->replace(['taxes' => $taxes ]);
Invoice::createTaxes($invoice, $request, $invoice->exchange_rate);
Invoice::createTaxes($invoice, $request->taxes);
$this->assertDatabaseHas('taxes', [
'invoice_id' => $invoice->id,

View File

@ -10,7 +10,6 @@ use Illuminate\Support\Facades\Artisan;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'UnitSeeder', '--force' => true]);
});
test('an item belongs to unit', function () {

View File

@ -6,8 +6,6 @@ use Illuminate\Support\Facades\Artisan;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'UnitSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'PaymentMethodSeeder', '--force' => true]);
});
test('payment method has many payment', function () {

View File

@ -6,8 +6,6 @@ use Illuminate\Support\Facades\Artisan;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'UnitSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'PaymentMethodSeeder', '--force' => true]);
});
test('payment belongs to invoice', function () {

View File

@ -8,7 +8,6 @@ use Laravel\Sanctum\Sanctum;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'UnitSeeder', '--force' => true]);
$user = User::where('role', 'super admin')->first();
$this->withHeaders([