applied jobs to tests

This commit is contained in:
denisdulici 2019-11-17 15:06:00 +03:00
parent 272905decc
commit 58048a1979
25 changed files with 194 additions and 186 deletions

View File

@ -1,7 +1,7 @@
APP_NAME=Akaunting
APP_ENV=testing
APP_LOCALE=en-GB
APP_INSTALLED=false
APP_INSTALLED=true
APP_KEY=base64:xBC+BxlC7sXhYAtpTZv8TYAHqoPgsJaXL0S5Id6BbBc=
APP_DEBUG=true
APP_SCHEDULE_TIME="09:00"

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class ModifySkuQuantityColumnItemsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('items', function (Blueprint $table) {
$table->string('sku')->nullable()->change();
$table->integer('quantity')->default(1)->change();
$table->dropUnique('items_company_id_sku_deleted_at_unique');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('items', function (Blueprint $table) {
$table->string('sku')->change();
$table->integer('quantity')->change();
$table->unique(['company_id', 'sku', 'deleted_at']);
});
}
}

View File

@ -5,6 +5,7 @@ namespace Database\Seeds;
use App\Abstracts\Model;
use App\Models\Auth\User;
use App\Models\Common\Company;
use Artisan;
use Date;
use Illuminate\Database\Seeder;
@ -30,16 +31,9 @@ class TestCompany extends Seeder
private function createCompany()
{
$rows = [
[
'id' => '1',
'domain' => 'test.com',
],
];
foreach ($rows as $row) {
Company::create($row);
}
Company::create([
'domain' => 'test.com',
]);
setting()->setExtraColumns(['company_id' => '1']);
setting()->set([
@ -49,11 +43,14 @@ class TestCompany extends Seeder
'localisation.financial_start' => '01-01',
'default.currency' => 'USD',
'default.account' => '1',
'default.payment_method' => 'offline-paymentz.cash.1',
'default.payment_method' => 'offline-payments.cash.1',
'schedule.bill_days' => '10,5,3,1',
'schedule.invoice_days' => '1,3,5,10',
'schedule.send_invoice_reminder' => true,
'schedule.send_bill_reminder' => true,
'schedule.send_invoice_reminder' => '0',
'schedule.send_bill_reminder' => '0',
'wizard.completed' => '1',
'contact.type.customer' => 'customer',
'contact.type.vendor' => 'vendor',
]);
setting()->save();
@ -76,6 +73,11 @@ class TestCompany extends Seeder
// Attach company
$user->companies()->attach(1);
Artisan::call('user:seed', [
'user' => $user->id,
'company' => 1,
]);
$this->command->info('Admin user created.');
}
}

View File

@ -1,63 +0,0 @@
<?php
namespace Tests\Feature\Auth;
use App\Models\Auth\Role;
use App\Models\Auth\User;
use Tests\Feature\FeatureTestCase;
class LoginTest extends FeatureTestCase
{
public function testItShouldSeeLoginPage()
{
$this->get(route('login'))
->assertStatus(200)
->assertSeeText(trans('auth.login_to'));
}
public function testItShouldLoginUser()
{
$this->post(route('login'), ['email' => $this->user->email, 'password' => $this->user->password])
->assertStatus(200);
$this->isAuthenticated($this->user->user);
}
public function testItShouldNotLoginUser()
{
$user = factory(User::class)->create([
'password' => bcrypt($password = 'correct-password'),
]);
$this->post(route('login'), ['email' => $user->email, 'password' != $user->password = $password])
->assertStatus(302);
$this->dontSeeIsAuthenticated();
}
public function testItShouldLogoutUser()
{
$user = User::create($this->getLoginRequest());
$this->loginAs()
->get(route('logout',$user->id))
->assertStatus(302)
->assertRedirect(route('login'));
$this->dontSeeIsAuthenticated();
}
private function getLoginRequest()
{
$password = $this->faker->password();
return[
'name' => $this->faker->name,
'email' => $this->faker->email,
'password' => $password,
'companies' => [session('company_id')],
'roles' => Role::take(1)->pluck('id')->toArray(),
'enabled' => $this->faker->boolean ? 1 : 0,
];
}
}

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Auth;
use App\Models\Auth\Permission;
use App\Jobs\Auth\CreatePermission;
use Tests\Feature\FeatureTestCase;
class PermissionsTest extends FeatureTestCase
@ -35,7 +35,7 @@ class PermissionsTest extends FeatureTestCase
public function testItShouldSeePermissionUpdatePage()
{
$permission = Permission::create($this->getPermissionRequest());
$permission = $this->dispatch(new CreatePermission($this->getPermissionRequest()));
$this->loginAs()
->get(route('permissions.edit', ['permission' => $permission->id]))
@ -47,7 +47,7 @@ class PermissionsTest extends FeatureTestCase
{
$request = $this->getPermissionRequest();
$permission = Permission::create($request);
$permission = $this->dispatch(new CreatePermission($request));
$request['name'] = $this->faker->name;
@ -60,7 +60,7 @@ class PermissionsTest extends FeatureTestCase
public function testItShouldDeletePermission()
{
$permission = Permission::create($this->getPermissionRequest());
$permission = $this->dispatch(new CreatePermission($this->getPermissionRequest()));
$this->loginAs()
->delete(route('permissions.destroy', $permission->id))

View File

@ -2,8 +2,8 @@
namespace Tests\Feature\Auth;
use App\Jobs\Auth\CreateRole;
use App\Models\Auth\Permission;
use App\Models\Auth\Role;
use Tests\Feature\FeatureTestCase;
class RolesTest extends FeatureTestCase
@ -36,7 +36,7 @@ class RolesTest extends FeatureTestCase
public function testItShouldSeeRoleUpdatePage()
{
$role = Role::create($this->getRoleRequest());
$role = $this->dispatch(new CreateRole($this->getRoleRequest()));
$this->loginAs()
->get(route('roles.edit', ['role' => $role->id]))
@ -48,7 +48,7 @@ class RolesTest extends FeatureTestCase
{
$request = $this->getRoleRequest();
$role = Role::create($request);
$role = $this->dispatch(new CreateRole($request));
$request['name'] = $this->faker->name;
@ -61,7 +61,7 @@ class RolesTest extends FeatureTestCase
public function testItShouldDeleteRole()
{
$role = Role::create($this->getRoleRequest());
$role = $this->dispatch(new CreateRole($this->getRoleRequest()));
$this->loginAs()
->delete(route('roles.destroy', $role->id))

View File

@ -2,13 +2,12 @@
namespace Tests\Feature\Auth;
use App\Jobs\Auth\CreateUser;
use App\Models\Auth\Role;
use App\Models\Auth\User;
use Tests\Feature\FeatureTestCase;
class UsersTest extends FeatureTestCase
{
public function testItShouldSeeUserListPage()
{
$this->loginAs()
@ -36,7 +35,7 @@ class UsersTest extends FeatureTestCase
public function testItShouldSeeUserUpdatePage()
{
$user = User::create($this->getUserRequest());
$user = $this->dispatch(new CreateUser($this->getUserRequest()));
$this->loginAs()
->get(route('users.edit', ['user' => $user->id]))
@ -48,7 +47,7 @@ class UsersTest extends FeatureTestCase
{
$request = $this->getUserRequest();
$user = User::create($request);
$user = $this->dispatch(new CreateUser($request));
$request['name'] = $this->faker->name;
@ -61,7 +60,7 @@ class UsersTest extends FeatureTestCase
public function testItShouldDeleteUser()
{
$user = User::create($this->getUserRequest());
$user = $this->dispatch(new CreateUser($this->getUserRequest()));
$this->loginAs()
->delete(route('users.destroy', $user->id))
@ -70,6 +69,45 @@ class UsersTest extends FeatureTestCase
$this->assertFlashLevel('success');
}
public function testItShouldSeeLoginPage()
{
$this->get(route('login'))
->assertStatus(200)
->assertSeeText(trans('auth.login_to'));
}
public function testItShouldLoginUser()
{
$user = $this->dispatch(new CreateUser($this->getUserRequest()));
$this->post(route('login'), ['email' => $user->email, 'password' => $user->password])
->assertStatus(200);
$this->isAuthenticated($user->user);
}
public function testItShouldNotLoginUser()
{
$user = $this->dispatch(new CreateUser($this->getUserRequest()));
$this->post(route('login'), ['email' => $user->email, $this->faker->password()])
->assertStatus(302);
$this->assertGuest();
}
public function testItShouldLogoutUser()
{
$user = $this->dispatch(new CreateUser($this->getUserRequest()));
$this->loginAs()
->get(route('logout', $user->id))
->assertStatus(302)
->assertRedirect(route('login'));
$this->assertGuest();
}
private function getUserRequest()
{
$password = $this->faker->password();
@ -80,7 +118,7 @@ class UsersTest extends FeatureTestCase
'password' => $password,
'password_confirmation' => $password,
'locale' => 'en-GB',
'companies' => [session('company_id')],
'companies' => [$this->company->id],
'roles' => Role::take(1)->pluck('id')->toArray(),
'enabled' => $this->faker->boolean ? 1 : 0,
];

View File

@ -2,6 +2,7 @@
namespace Tests\Feature\Banking;
use App\Jobs\Banking\CreateAccount;
use App\Models\Banking\Account;
use Tests\Feature\FeatureTestCase;
@ -34,7 +35,7 @@ class AccountsTest extends FeatureTestCase
public function testItShouldSeeAccountUpdatePage()
{
$account = Account::create($this->getAccountRequest());
$account = $this->dispatch(new CreateAccount($this->getAccountRequest()));
$this->loginAs()
->get(route('accounts.edit', ['account' => $account->id]))

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Banking;
use App\Models\Banking\Reconciliation;
use App\Jobs\Banking\CreateReconciliation;
use Tests\Feature\FeatureTestCase;
class ReconciliationsTest extends FeatureTestCase
@ -34,7 +34,7 @@ class ReconciliationsTest extends FeatureTestCase
public function testItShouldSeeReconciliationUpdatePage()
{
$reconciliation = Reconciliation::create($this->getReconciliationRequest());
$reconciliation = $this->dispatch(new CreateReconciliation($this->getReconciliationRequest()));
$this->loginAs()
->get(route('reconciliations.edit', ['reconciliation' => $reconciliation->id]))
@ -46,7 +46,7 @@ class ReconciliationsTest extends FeatureTestCase
{
$request = $this->getReconciliationRequest();
$reconciliation= Reconciliation::create($request);
$reconciliation= $this->dispatch(new CreateReconciliation($request));
$request['description'] = $this->faker->text(10);
@ -59,7 +59,7 @@ class ReconciliationsTest extends FeatureTestCase
public function testItShouldDeleteReconciliation()
{
$reconciliation = Reconciliation::create($this->getReconciliationRequest());
$reconciliation = $this->dispatch(new CreateReconciliation($this->getReconciliationRequest()));
$this->loginAs()
->delete(route('reconciliations.destroy', ['reconciliation' => $reconciliation]))

View File

@ -2,8 +2,8 @@
namespace Tests\Feature\Banking;
use App\Models\Banking\Transfer;
use App\Models\Banking\Transaction;
use App\Jobs\Banking\CreateTransaction;
use App\Jobs\Banking\CreateTransfer;
use Illuminate\Http\UploadedFile;
use Tests\Feature\FeatureTestCase;
@ -28,10 +28,10 @@ class TransfersTest extends FeatureTestCase
public function testItShouldCreateTransfer()
{
// Create income
$income_transaction = Transaction::create($this->getIncomeRequest());
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
// Create expense
$expense_transaction = Transaction::create($this->getExpenseRequest());
$expense_transaction = $this->dispatch(new CreateTransaction($this->getExpenseRequest()));
$this->loginAs()
->post(route('transfers.store'), $this->getTransferRequest($income_transaction, $expense_transaction))
@ -43,12 +43,12 @@ class TransfersTest extends FeatureTestCase
public function testItShouldSeeTransferUpdatePage()
{
// Create income
$income_transaction = Transaction::create($this->getIncomeRequest());
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
// Create expense
$expense_transaction = Transaction::create($this->getExpenseRequest());
$expense_transaction = $this->dispatch(new CreateTransaction($this->getExpenseRequest()));
$transfer = Transfer::create($this->getTransferRequest($income_transaction, $expense_transaction));
$transfer = $this->dispatch(new CreateTransfer($this->getTransferRequest($income_transaction, $expense_transaction)));
$this->loginAs()
->get(route('transfers.edit', ['transfer' => $transfer->id]))
@ -59,14 +59,14 @@ class TransfersTest extends FeatureTestCase
public function testItShouldUpdateTransfer()
{
// Create income
$income_transaction = Transaction::create($this->getIncomeRequest());
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
// Create expense
$expense_transaction = Transaction::create($this->getExpenseRequest());
$expense_transaction = $this->dispatch(new CreateTransaction($this->getExpenseRequest()));
$request = $this->getTransferRequest($income_transaction, $expense_transaction);
$transfer = Transfer::create($request);
$transfer = $this->dispatch(new CreateTransfer($request));
$request['description'] = $this->faker->text(10);
@ -80,12 +80,12 @@ class TransfersTest extends FeatureTestCase
public function testItShouldDeleteTransfer()
{
// Create income
$income_transaction = Transaction::create($this->getIncomeRequest());
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
// Create expense
$expense_transaction = Transaction::create($this->getExpenseRequest());
$expense_transaction = $this->dispatch(new CreateTransaction($this->getExpenseRequest()));
$transfer = Transfer::create($this->getTransferRequest($income_transaction, $expense_transaction));
$transfer = $this->dispatch(new CreateTransfer($this->getTransferRequest($income_transaction, $expense_transaction)));
$this->loginAs()
->delete(route('transfers.destroy', ['transfer' => $transfer->id]))

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Commands;
use App\Models\Expense\Bill;
use App\Jobs\Expense\CreateBill;
use App\Notifications\Expense\Bill as BillNotification;
use Illuminate\Support\Facades\Notification;
use Jenssegers\Date\Date;
@ -23,7 +23,7 @@ class BillReminderTest extends FeatureTestCase
{
Notification::fake();
$bill = Bill::create($this->getBillRequest());
$bill = $this->dispatch(new CreateBill($this->getBillRequest()));
Date::setTestNow(Date::now()->subDays($this->addDay));
@ -39,7 +39,7 @@ class BillReminderTest extends FeatureTestCase
}
/**
* Copied in InvoicesTest
* Bill request
*
* @param int $recurring
* @return array
@ -58,7 +58,7 @@ class BillReminderTest extends FeatureTestCase
'order_number' => '1',
'currency_code' => setting('default.currency'),
'currency_rate' => '1',
'item' => $items,
'items' => $items,
'discount' => '0',
'notes' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('income')->first()->id,

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Commands;
use App\Models\Income\Invoice;
use App\Jobs\Income\CreateInvoice;
use App\Notifications\Income\Invoice as InvoiceNotification;
use Illuminate\Support\Facades\Notification;
use Jenssegers\Date\Date;
@ -23,7 +23,7 @@ class InvoiceReminderTest extends FeatureTestCase
{
Notification::fake();
$invoice = Invoice::create($this->getInvoiceRequest());
$invoice = $this->dispatch(new CreateInvoice($this->getInvoiceRequest()));
Date::setTestNow(Date::now()->addDay($this->addDay));
@ -39,12 +39,11 @@ class InvoiceReminderTest extends FeatureTestCase
}
/**
* Copied in InvoicesTest
* Invoice request
*
* @param int $recurring
* @return array
*/
private function getInvoiceRequest($recurring = 0)
private function getInvoiceRequest()
{
$amount = $this->faker->randomFloat(2, 2);
@ -58,7 +57,7 @@ class InvoiceReminderTest extends FeatureTestCase
'order_number' => '1',
'currency_code' => setting('default.currency'),
'currency_rate' => '1',
'item' => $items,
'items' => $items,
'discount' => '0',
'notes' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('income')->first()->id,
@ -73,13 +72,6 @@ class InvoiceReminderTest extends FeatureTestCase
'company_id' => $this->company->id,
];
if ($recurring) {
$data['recurring_frequency'] = 'yes';
$data['recurring_interval'] = '1';
$data['recurring_custom_frequency'] = $this->faker->randomElement(['monthly', 'weekly']);
$data['recurring_count'] = '1';
}
return $data;
}
}

View File

@ -9,7 +9,7 @@ class DashboardTest extends FeatureTestCase
public function testItShouldSeeDashboard()
{
$this->loginAs()
->get(url('/'))
->get(route('dashboard'))
->assertStatus(200)
->assertSeeText(trans('general.dashboard'));
}

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Common;
use App\Models\Common\Item;
use App\Jobs\Common\CreateItem;
use Illuminate\Http\UploadedFile;
use Tests\Feature\FeatureTestCase;
@ -35,7 +35,7 @@ class ItemsTest extends FeatureTestCase
public function testItShouldSeeItemUpdatePage()
{
$item = Item::create($this->getItemRequest());
$item = $this->dispatch(new CreateItem($this->getItemRequest()));
$this->loginAs()
->get(route('items.edit', ['item' => $item->id]))
@ -47,7 +47,7 @@ class ItemsTest extends FeatureTestCase
{
$request = $this->getItemRequest();
$item = Item::create($request);
$item = $this->dispatch(new CreateItem($request));
$request['name'] = $this->faker->text(15);
@ -60,7 +60,7 @@ class ItemsTest extends FeatureTestCase
public function testItShouldDeleteItem()
{
$item = Item::create($this->getItemRequest());
$item = $this->dispatch(new CreateItem($this->getItemRequest()));
$this->loginAs()
->delete(route('items.destroy', ['item' => $item]))
@ -80,7 +80,7 @@ class ItemsTest extends FeatureTestCase
'description' => $this->faker->text(100),
'purchase_price' => $this->faker->randomFloat(2, 10, 20),
'sale_price' => $this->faker->randomFloat(2, 10, 20),
'category_id' => $this->company->categories()->type('item')->first()->id,
'category_id' => $this->company->categories()->type('item')->pluck('id')->first(),
'tax_id' => '',
'enabled' => $this->faker->boolean ? 1 : 0
];

View File

@ -35,7 +35,7 @@ class BillsTest extends FeatureTestCase
public function testItShouldCreateBillWithRecurring()
{
$this->loginAs()
->post(route('bills.store'), $this->getBillRequest(1))
->post(route('bills.store'), $this->getBillRequest(true))
->assertStatus(200);
$this->assertFlashLevel('success');
@ -43,7 +43,7 @@ class BillsTest extends FeatureTestCase
public function testItShouldSeeBillUpdatePage()
{
$bill = dispatch_now(new CreateBill($this->getBillRequest()));
$bill = $this->dispatch(new CreateBill($this->getBillRequest()));
$this->loginAs()
->get(route('bills.edit', ['bill' => $bill->id]))
@ -54,35 +54,35 @@ class BillsTest extends FeatureTestCase
public function testItShouldUpdateBill()
{
$bill = dispatch_now(new CreateBill($this->getBillRequest()));
$request = $this->getBillRequest();
$bill = $this->dispatch(new CreateBill($request));
$request['contact_name'] = $this->faker->name;
$this->loginAs()
->patch(route('bills.update', $bill->id), $request)
->assertStatus(302);
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldDeleteBill()
{
$bill = dispatch_now(new CreateBill($this->getBillRequest()));
$bill = $this->dispatch(new CreateBill($this->getBillRequest()));
$this->loginAs()
->delete(route('bills.destroy', $bill->id))
->assertStatus(302)
->assertRedirect(route('bills.index'));
->assertStatus(200);
$this->assertFlashLevel('success');
}
private function getBillRequest($recurring = 0)
private function getBillRequest($recurring = false)
{
$amount = $this->faker->randomFloat(2, 2);
$items = [['name' => $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD', 'tax_id' => null]];
$items = [['name' => $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD', 'tax_id' => null]];
$data = [
'company_id' => $this->company->id,
@ -95,7 +95,7 @@ class BillsTest extends FeatureTestCase
'items' => $items,
'discount' => '0',
'notes' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('expense')->first()->id,
'category_id' => $this->company->categories()->type('expense')->pluck('id')->first(),
'recurring_frequency' => 'no',
'contact_id' => '0',
'contact_name' => $this->faker->name,

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Expenses;
use App\Models\Banking\Transaction;
use App\Jobs\Banking\CreateTransaction;
use Illuminate\Http\UploadedFile;
use Tests\Feature\FeatureTestCase;
@ -37,7 +37,7 @@ class PaymentsTest extends FeatureTestCase
{
$request = $this->getPaymentRequest();
$payment = Transaction::create($request);
$payment = $this->dispatch(new CreateTransaction($request));
$request['name'] = $this->faker->text(15);
@ -50,7 +50,7 @@ class PaymentsTest extends FeatureTestCase
public function testItShouldDeletePayment()
{
$payment = Transaction::create($this->getPaymentRequest());
$payment = $this->dispatch(new CreateTransaction($this->getPaymentRequest()));
$this->loginAs()
->delete(route('payments.destroy', $payment->id))

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Expenses;
use App\Models\Common\Contact;
use App\Jobs\Common\CreateContact;
use Tests\Feature\FeatureTestCase;
class VendorsTest extends FeatureTestCase
@ -34,7 +34,7 @@ class VendorsTest extends FeatureTestCase
public function testItShouldSeeVendorDetailPage()
{
$vendor = Contact::create($this->getVendorRequest());
$vendor = $this->dispatch(new CreateContact($this->getVendorRequest()));
$this->loginAs()
->get(route('vendors.show', ['vendor' => $vendor->id]))
@ -44,7 +44,7 @@ class VendorsTest extends FeatureTestCase
public function testItShouldSeeVendorUpdatePage()
{
$vendor = Contact::create($this->getVendorRequest());
$vendor = $this->dispatch(new CreateContact($this->getVendorRequest()));
$this->loginAs()
->get(route('vendors.edit', ['vendor' => $vendor->id]))
@ -57,7 +57,7 @@ class VendorsTest extends FeatureTestCase
{
$request = $this->getVendorRequest();
$vendor = Contact::create($request);
$vendor = $this->dispatch(new CreateContact($request));
$request['name'] = $this->faker->name;
@ -70,7 +70,7 @@ class VendorsTest extends FeatureTestCase
public function testItShouldDeleteVendor()
{
$vendor = Contact::create($this->getVendorRequest());
$vendor = $this->dispatch(new CreateContact($this->getVendorRequest()));
$this->loginAs()
->delete(route('vendors.destroy', $vendor->id))

View File

@ -26,7 +26,7 @@ abstract class FeatureTestCase extends TestCase
$this->faker = Factory::create();
$this->user = User::first();
$this->company = $this->user->first()->companies()->first();
$this->company = $this->user->companies()->first();
// Set Company settings
setting()->forgetAll();
@ -48,7 +48,7 @@ abstract class FeatureTestCase extends TestCase
}
if (!$company) {
$company = $user->companies()->first();
$company = $this->company;
}
$this->startSession();

View File

@ -2,8 +2,8 @@
namespace Tests\Feature\Incomes;
use App\Jobs\Common\CreateContact;
use App\Models\Auth\User;
use App\Models\Common\Contact;
use Tests\Feature\FeatureTestCase;
class CustomersTest extends FeatureTestCase
@ -62,7 +62,7 @@ class CustomersTest extends FeatureTestCase
public function testItShouldSeeCustomerDetailPage()
{
$customer = Contact::create($this->getCustomerRequest());
$customer = $this->dispatch(new CreateContact($this->getCustomerRequest()));
$this->loginAs()
->get(route('customers.show', ['customer' => $customer->id]))
@ -72,7 +72,7 @@ class CustomersTest extends FeatureTestCase
public function testItShouldSeeCustomerUpdatePage()
{
$customer = Contact::create($this->getCustomerRequest());
$customer = $this->dispatch(new CreateContact($this->getCustomerRequest()));
$this->loginAs()
->get(route('customers.edit', ['customer' => $customer->id]))
@ -85,7 +85,7 @@ class CustomersTest extends FeatureTestCase
{
$request = $this->getCustomerRequest();
$customer = Contact::create($request);
$customer = $this->dispatch(new CreateContact($request));
$request['name'] = $this->faker->name;
@ -98,7 +98,7 @@ class CustomersTest extends FeatureTestCase
public function testItShouldDeleteCustomer()
{
$customer = Contact::create($this->getCustomerRequest());
$customer = $this->dispatch(new CreateContact($this->getCustomerRequest()));
$this->loginAs()
->delete(route('customers.destroy', $customer->id))
@ -135,10 +135,10 @@ class CustomersTest extends FeatureTestCase
$password = $this->faker->password;
return $this->getCustomerRequest() + [
'create_user' => 1,
'locale' => 'en-GB',
'password' => $password,
'password_confirmation' => $password
];
'create_user' => 1,
'locale' => 'en-GB',
'password' => $password,
'password_confirmation' => $password
];
}
}

View File

@ -20,7 +20,7 @@ class InvoicesTest extends FeatureTestCase
$this->loginAs()
->get(route('invoices.create'))
->assertStatus(200)
->assertSeeText(trans( trans_choice('general.invoices', 1)));
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.invoices', 1)]));
}
public function testItShouldCreateInvoice()
@ -35,7 +35,7 @@ class InvoicesTest extends FeatureTestCase
public function testItShouldCreateInvoiceWithRecurring()
{
$this->loginAs()
->post(route('invoices.store'), $this->getInvoiceRequest(1))
->post(route('invoices.store'), $this->getInvoiceRequest(true))
->assertStatus(200);
$this->assertFlashLevel('success');
@ -43,7 +43,7 @@ class InvoicesTest extends FeatureTestCase
public function testItShouldSeeInvoiceUpdatePage()
{
$invoice = dispatch_now(new CreateInvoice($this->getInvoiceRequest()));
$invoice = $this->dispatch(new CreateInvoice($this->getInvoiceRequest()));
$this->loginAs()
->get(route('invoices.edit', ['invoice' => $invoice->id]))
@ -54,7 +54,9 @@ class InvoicesTest extends FeatureTestCase
public function testItShouldUpdateInvoice()
{
$invoice = dispatch_now(new CreateInvoice($this->getInvoiceRequest()));
$request = $this->getInvoiceRequest();
$invoice = $this->dispatch(new CreateInvoice($request));
$request['contact_name'] = $this->faker->name;
@ -67,7 +69,7 @@ class InvoicesTest extends FeatureTestCase
public function testItShouldDeleteInvoice()
{
$invoice = dispatch_now(new CreateInvoice($this->getInvoiceRequest()));
$invoice = $this->dispatch(new CreateInvoice($this->getInvoiceRequest()));
$this->loginAs()
->delete(route('invoices.destroy', $invoice->id))
@ -76,11 +78,11 @@ class InvoicesTest extends FeatureTestCase
$this->assertFlashLevel('success');
}
private function getInvoiceRequest($recurring = 0)
private function getInvoiceRequest($recurring = false)
{
$amount = $this->faker->randomFloat(2, 2);
$items = [['name' => $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD']];
$items = [['name' => $this->faker->text(5), 'item_id' => null, 'quantity' => '1', 'price' => $amount, 'currency' => 'USD']];
$data = [
'company_id' => $this->company->id,
@ -93,7 +95,7 @@ class InvoicesTest extends FeatureTestCase
'items' => $items,
'discount' => '0',
'notes' => $this->faker->text(5),
'category_id' => $this->company->categories()->type('income')->first()->id,
'category_id' => $this->company->categories()->type('income')->pluck('id')->first(),
'recurring_frequency' => 'no',
'contact_id' => '0',
'contact_name' => $this->faker->name,

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Incomes;
use App\Models\Banking\Transaction;
use App\Jobs\Banking\CreateTransaction;
use Illuminate\Http\UploadedFile;
use Tests\Feature\FeatureTestCase;
@ -37,7 +37,7 @@ class RevenuesTest extends FeatureTestCase
{
$request = $this->getRevenueRequest();
$revenue = Transaction::create($request);
$revenue = $this->dispatch(new CreateTransaction($request));
$request['name'] = $this->faker->text(15);
@ -50,7 +50,7 @@ class RevenuesTest extends FeatureTestCase
public function testItShouldDeleteRevenue()
{
$revenue = Transaction::create($this->getRevenueRequest());
$revenue = $this->dispatch(new CreateTransaction($this->getRevenueRequest()));
$this->loginAs()
->delete(route('revenues.destroy', $revenue->id))

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Settings;
use App\Models\Setting\Category;
use App\Jobs\Setting\CreateCategory;
use Tests\Feature\FeatureTestCase;
class CategoriesTest extends FeatureTestCase
@ -34,7 +34,7 @@ class CategoriesTest extends FeatureTestCase
public function testItShouldSeeCategoryUpdatePage()
{
$category = Category::create($this->getCategoryRequest());
$category = $this->dispatch(new CreateCategory($this->getCategoryRequest()));
$this->loginAs()
->get(route('categories.edit', ['category' => $category->id]))
@ -46,7 +46,7 @@ class CategoriesTest extends FeatureTestCase
{
$request = $this->getCategoryRequest();
$category = Category::create($request);
$category = $this->dispatch(new CreateCategory($request));
$request['name'] = $this->faker->text(15);
@ -59,7 +59,7 @@ class CategoriesTest extends FeatureTestCase
public function testItShouldDeleteCategory()
{
$category = Category::create($this->getCategoryRequest());
$category = $this->dispatch(new CreateCategory($this->getCategoryRequest()));
$this->loginAs()
->delete(route('categories.destroy', $category->id))
@ -73,7 +73,7 @@ class CategoriesTest extends FeatureTestCase
return [
'company_id' => $this->company->id,
'name' => $this->faker->text(15),
'type' => 'other',
'type' => 'item',
'color' => $this->faker->text(15),
'enabled' => $this->faker->boolean ? 1 : 0
];

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Settings;
use App\Models\Setting\Currency;
use App\Jobs\Setting\CreateCurrency;
use Tests\Feature\FeatureTestCase;
class CurrenciesTest extends FeatureTestCase
@ -36,7 +36,7 @@ class CurrenciesTest extends FeatureTestCase
{
$request = $this->getCurrencyRequest();
$currency = Currency::create($request);
$currency = $this->dispatch(new CreateCurrency($request));
$request['name'] = $this->faker->text(15);
@ -49,7 +49,7 @@ class CurrenciesTest extends FeatureTestCase
public function testItShouldDeleteCurrency()
{
$currency = Currency::create($this->getCurrencyRequest());
$currency = $this->dispatch(new CreateCurrency($this->getCurrencyRequest()));
$this->loginAs()
->delete(route('currencies.destroy', $currency->id))

View File

@ -2,7 +2,7 @@
namespace Tests\Feature\Settings;
use App\Models\Setting\Tax;
use App\Jobs\Setting\CreateTax;
use Tests\Feature\FeatureTestCase;
class TaxesTest extends FeatureTestCase
@ -36,7 +36,7 @@ class TaxesTest extends FeatureTestCase
{
$request = $this->getTaxRequest();
$tax = Tax::create($request);
$tax = $this->dispatch(new CreateTax($request));
$request['name'] = $this->faker->text(15);
@ -49,7 +49,7 @@ class TaxesTest extends FeatureTestCase
public function testItShouldDeleteTax()
{
$tax = Tax::create($this->getTaxRequest());
$tax = $this->dispatch(new CreateTax($this->getTaxRequest()));
$this->loginAs()
->delete(route('taxes.destroy', $tax->id))

View File

@ -2,6 +2,7 @@
namespace Tests;
use App\Traits\Jobs;
use Artisan;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
@ -9,7 +10,7 @@ use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication, DatabaseMigrations;
use CreatesApplication, DatabaseMigrations, Jobs;
protected function setUp(): void
{