applied jobs to tests
This commit is contained in:
parent
272905decc
commit
58048a1979
@ -1,7 +1,7 @@
|
|||||||
APP_NAME=Akaunting
|
APP_NAME=Akaunting
|
||||||
APP_ENV=testing
|
APP_ENV=testing
|
||||||
APP_LOCALE=en-GB
|
APP_LOCALE=en-GB
|
||||||
APP_INSTALLED=false
|
APP_INSTALLED=true
|
||||||
APP_KEY=base64:xBC+BxlC7sXhYAtpTZv8TYAHqoPgsJaXL0S5Id6BbBc=
|
APP_KEY=base64:xBC+BxlC7sXhYAtpTZv8TYAHqoPgsJaXL0S5Id6BbBc=
|
||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
APP_SCHEDULE_TIME="09:00"
|
APP_SCHEDULE_TIME="09:00"
|
||||||
|
@ -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']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ namespace Database\Seeds;
|
|||||||
use App\Abstracts\Model;
|
use App\Abstracts\Model;
|
||||||
use App\Models\Auth\User;
|
use App\Models\Auth\User;
|
||||||
use App\Models\Common\Company;
|
use App\Models\Common\Company;
|
||||||
|
use Artisan;
|
||||||
use Date;
|
use Date;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
@ -30,16 +31,9 @@ class TestCompany extends Seeder
|
|||||||
|
|
||||||
private function createCompany()
|
private function createCompany()
|
||||||
{
|
{
|
||||||
$rows = [
|
Company::create([
|
||||||
[
|
'domain' => 'test.com',
|
||||||
'id' => '1',
|
]);
|
||||||
'domain' => 'test.com',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($rows as $row) {
|
|
||||||
Company::create($row);
|
|
||||||
}
|
|
||||||
|
|
||||||
setting()->setExtraColumns(['company_id' => '1']);
|
setting()->setExtraColumns(['company_id' => '1']);
|
||||||
setting()->set([
|
setting()->set([
|
||||||
@ -49,11 +43,14 @@ class TestCompany extends Seeder
|
|||||||
'localisation.financial_start' => '01-01',
|
'localisation.financial_start' => '01-01',
|
||||||
'default.currency' => 'USD',
|
'default.currency' => 'USD',
|
||||||
'default.account' => '1',
|
'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.bill_days' => '10,5,3,1',
|
||||||
'schedule.invoice_days' => '1,3,5,10',
|
'schedule.invoice_days' => '1,3,5,10',
|
||||||
'schedule.send_invoice_reminder' => true,
|
'schedule.send_invoice_reminder' => '0',
|
||||||
'schedule.send_bill_reminder' => true,
|
'schedule.send_bill_reminder' => '0',
|
||||||
|
'wizard.completed' => '1',
|
||||||
|
'contact.type.customer' => 'customer',
|
||||||
|
'contact.type.vendor' => 'vendor',
|
||||||
]);
|
]);
|
||||||
setting()->save();
|
setting()->save();
|
||||||
|
|
||||||
@ -76,6 +73,11 @@ class TestCompany extends Seeder
|
|||||||
// Attach company
|
// Attach company
|
||||||
$user->companies()->attach(1);
|
$user->companies()->attach(1);
|
||||||
|
|
||||||
|
Artisan::call('user:seed', [
|
||||||
|
'user' => $user->id,
|
||||||
|
'company' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
$this->command->info('Admin user created.');
|
$this->command->info('Admin user created.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Auth;
|
namespace Tests\Feature\Auth;
|
||||||
|
|
||||||
use App\Models\Auth\Permission;
|
use App\Jobs\Auth\CreatePermission;
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
class PermissionsTest extends FeatureTestCase
|
class PermissionsTest extends FeatureTestCase
|
||||||
@ -35,7 +35,7 @@ class PermissionsTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldSeePermissionUpdatePage()
|
public function testItShouldSeePermissionUpdatePage()
|
||||||
{
|
{
|
||||||
$permission = Permission::create($this->getPermissionRequest());
|
$permission = $this->dispatch(new CreatePermission($this->getPermissionRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('permissions.edit', ['permission' => $permission->id]))
|
->get(route('permissions.edit', ['permission' => $permission->id]))
|
||||||
@ -47,7 +47,7 @@ class PermissionsTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
$request = $this->getPermissionRequest();
|
$request = $this->getPermissionRequest();
|
||||||
|
|
||||||
$permission = Permission::create($request);
|
$permission = $this->dispatch(new CreatePermission($request));
|
||||||
|
|
||||||
$request['name'] = $this->faker->name;
|
$request['name'] = $this->faker->name;
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ class PermissionsTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldDeletePermission()
|
public function testItShouldDeletePermission()
|
||||||
{
|
{
|
||||||
$permission = Permission::create($this->getPermissionRequest());
|
$permission = $this->dispatch(new CreatePermission($this->getPermissionRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('permissions.destroy', $permission->id))
|
->delete(route('permissions.destroy', $permission->id))
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Auth;
|
namespace Tests\Feature\Auth;
|
||||||
|
|
||||||
|
use App\Jobs\Auth\CreateRole;
|
||||||
use App\Models\Auth\Permission;
|
use App\Models\Auth\Permission;
|
||||||
use App\Models\Auth\Role;
|
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
class RolesTest extends FeatureTestCase
|
class RolesTest extends FeatureTestCase
|
||||||
@ -36,7 +36,7 @@ class RolesTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldSeeRoleUpdatePage()
|
public function testItShouldSeeRoleUpdatePage()
|
||||||
{
|
{
|
||||||
$role = Role::create($this->getRoleRequest());
|
$role = $this->dispatch(new CreateRole($this->getRoleRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('roles.edit', ['role' => $role->id]))
|
->get(route('roles.edit', ['role' => $role->id]))
|
||||||
@ -48,7 +48,7 @@ class RolesTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
$request = $this->getRoleRequest();
|
$request = $this->getRoleRequest();
|
||||||
|
|
||||||
$role = Role::create($request);
|
$role = $this->dispatch(new CreateRole($request));
|
||||||
|
|
||||||
$request['name'] = $this->faker->name;
|
$request['name'] = $this->faker->name;
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class RolesTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldDeleteRole()
|
public function testItShouldDeleteRole()
|
||||||
{
|
{
|
||||||
$role = Role::create($this->getRoleRequest());
|
$role = $this->dispatch(new CreateRole($this->getRoleRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('roles.destroy', $role->id))
|
->delete(route('roles.destroy', $role->id))
|
||||||
|
@ -2,13 +2,12 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Auth;
|
namespace Tests\Feature\Auth;
|
||||||
|
|
||||||
|
use App\Jobs\Auth\CreateUser;
|
||||||
use App\Models\Auth\Role;
|
use App\Models\Auth\Role;
|
||||||
use App\Models\Auth\User;
|
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
class UsersTest extends FeatureTestCase
|
class UsersTest extends FeatureTestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
public function testItShouldSeeUserListPage()
|
public function testItShouldSeeUserListPage()
|
||||||
{
|
{
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
@ -36,7 +35,7 @@ class UsersTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldSeeUserUpdatePage()
|
public function testItShouldSeeUserUpdatePage()
|
||||||
{
|
{
|
||||||
$user = User::create($this->getUserRequest());
|
$user = $this->dispatch(new CreateUser($this->getUserRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('users.edit', ['user' => $user->id]))
|
->get(route('users.edit', ['user' => $user->id]))
|
||||||
@ -48,7 +47,7 @@ class UsersTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
$request = $this->getUserRequest();
|
$request = $this->getUserRequest();
|
||||||
|
|
||||||
$user = User::create($request);
|
$user = $this->dispatch(new CreateUser($request));
|
||||||
|
|
||||||
$request['name'] = $this->faker->name;
|
$request['name'] = $this->faker->name;
|
||||||
|
|
||||||
@ -61,7 +60,7 @@ class UsersTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldDeleteUser()
|
public function testItShouldDeleteUser()
|
||||||
{
|
{
|
||||||
$user = User::create($this->getUserRequest());
|
$user = $this->dispatch(new CreateUser($this->getUserRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('users.destroy', $user->id))
|
->delete(route('users.destroy', $user->id))
|
||||||
@ -70,6 +69,45 @@ class UsersTest extends FeatureTestCase
|
|||||||
$this->assertFlashLevel('success');
|
$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()
|
private function getUserRequest()
|
||||||
{
|
{
|
||||||
$password = $this->faker->password();
|
$password = $this->faker->password();
|
||||||
@ -80,7 +118,7 @@ class UsersTest extends FeatureTestCase
|
|||||||
'password' => $password,
|
'password' => $password,
|
||||||
'password_confirmation' => $password,
|
'password_confirmation' => $password,
|
||||||
'locale' => 'en-GB',
|
'locale' => 'en-GB',
|
||||||
'companies' => [session('company_id')],
|
'companies' => [$this->company->id],
|
||||||
'roles' => Role::take(1)->pluck('id')->toArray(),
|
'roles' => Role::take(1)->pluck('id')->toArray(),
|
||||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||||
];
|
];
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Banking;
|
namespace Tests\Feature\Banking;
|
||||||
|
|
||||||
|
use App\Jobs\Banking\CreateAccount;
|
||||||
use App\Models\Banking\Account;
|
use App\Models\Banking\Account;
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ class AccountsTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldSeeAccountUpdatePage()
|
public function testItShouldSeeAccountUpdatePage()
|
||||||
{
|
{
|
||||||
$account = Account::create($this->getAccountRequest());
|
$account = $this->dispatch(new CreateAccount($this->getAccountRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('accounts.edit', ['account' => $account->id]))
|
->get(route('accounts.edit', ['account' => $account->id]))
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Banking;
|
namespace Tests\Feature\Banking;
|
||||||
|
|
||||||
use App\Models\Banking\Reconciliation;
|
use App\Jobs\Banking\CreateReconciliation;
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
class ReconciliationsTest extends FeatureTestCase
|
class ReconciliationsTest extends FeatureTestCase
|
||||||
@ -34,7 +34,7 @@ class ReconciliationsTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldSeeReconciliationUpdatePage()
|
public function testItShouldSeeReconciliationUpdatePage()
|
||||||
{
|
{
|
||||||
$reconciliation = Reconciliation::create($this->getReconciliationRequest());
|
$reconciliation = $this->dispatch(new CreateReconciliation($this->getReconciliationRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('reconciliations.edit', ['reconciliation' => $reconciliation->id]))
|
->get(route('reconciliations.edit', ['reconciliation' => $reconciliation->id]))
|
||||||
@ -46,7 +46,7 @@ class ReconciliationsTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
$request = $this->getReconciliationRequest();
|
$request = $this->getReconciliationRequest();
|
||||||
|
|
||||||
$reconciliation= Reconciliation::create($request);
|
$reconciliation= $this->dispatch(new CreateReconciliation($request));
|
||||||
|
|
||||||
$request['description'] = $this->faker->text(10);
|
$request['description'] = $this->faker->text(10);
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ class ReconciliationsTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldDeleteReconciliation()
|
public function testItShouldDeleteReconciliation()
|
||||||
{
|
{
|
||||||
$reconciliation = Reconciliation::create($this->getReconciliationRequest());
|
$reconciliation = $this->dispatch(new CreateReconciliation($this->getReconciliationRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('reconciliations.destroy', ['reconciliation' => $reconciliation]))
|
->delete(route('reconciliations.destroy', ['reconciliation' => $reconciliation]))
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Banking;
|
namespace Tests\Feature\Banking;
|
||||||
|
|
||||||
use App\Models\Banking\Transfer;
|
use App\Jobs\Banking\CreateTransaction;
|
||||||
use App\Models\Banking\Transaction;
|
use App\Jobs\Banking\CreateTransfer;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
@ -28,10 +28,10 @@ class TransfersTest extends FeatureTestCase
|
|||||||
public function testItShouldCreateTransfer()
|
public function testItShouldCreateTransfer()
|
||||||
{
|
{
|
||||||
// Create income
|
// Create income
|
||||||
$income_transaction = Transaction::create($this->getIncomeRequest());
|
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
|
||||||
|
|
||||||
// Create expense
|
// Create expense
|
||||||
$expense_transaction = Transaction::create($this->getExpenseRequest());
|
$expense_transaction = $this->dispatch(new CreateTransaction($this->getExpenseRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->post(route('transfers.store'), $this->getTransferRequest($income_transaction, $expense_transaction))
|
->post(route('transfers.store'), $this->getTransferRequest($income_transaction, $expense_transaction))
|
||||||
@ -43,12 +43,12 @@ class TransfersTest extends FeatureTestCase
|
|||||||
public function testItShouldSeeTransferUpdatePage()
|
public function testItShouldSeeTransferUpdatePage()
|
||||||
{
|
{
|
||||||
// Create income
|
// Create income
|
||||||
$income_transaction = Transaction::create($this->getIncomeRequest());
|
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
|
||||||
|
|
||||||
// Create expense
|
// 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()
|
$this->loginAs()
|
||||||
->get(route('transfers.edit', ['transfer' => $transfer->id]))
|
->get(route('transfers.edit', ['transfer' => $transfer->id]))
|
||||||
@ -59,14 +59,14 @@ class TransfersTest extends FeatureTestCase
|
|||||||
public function testItShouldUpdateTransfer()
|
public function testItShouldUpdateTransfer()
|
||||||
{
|
{
|
||||||
// Create income
|
// Create income
|
||||||
$income_transaction = Transaction::create($this->getIncomeRequest());
|
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
|
||||||
|
|
||||||
// Create expense
|
// Create expense
|
||||||
$expense_transaction = Transaction::create($this->getExpenseRequest());
|
$expense_transaction = $this->dispatch(new CreateTransaction($this->getExpenseRequest()));
|
||||||
|
|
||||||
$request = $this->getTransferRequest($income_transaction, $expense_transaction);
|
$request = $this->getTransferRequest($income_transaction, $expense_transaction);
|
||||||
|
|
||||||
$transfer = Transfer::create($request);
|
$transfer = $this->dispatch(new CreateTransfer($request));
|
||||||
|
|
||||||
$request['description'] = $this->faker->text(10);
|
$request['description'] = $this->faker->text(10);
|
||||||
|
|
||||||
@ -80,12 +80,12 @@ class TransfersTest extends FeatureTestCase
|
|||||||
public function testItShouldDeleteTransfer()
|
public function testItShouldDeleteTransfer()
|
||||||
{
|
{
|
||||||
// Create income
|
// Create income
|
||||||
$income_transaction = Transaction::create($this->getIncomeRequest());
|
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
|
||||||
|
|
||||||
// Create expense
|
// 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()
|
$this->loginAs()
|
||||||
->delete(route('transfers.destroy', ['transfer' => $transfer->id]))
|
->delete(route('transfers.destroy', ['transfer' => $transfer->id]))
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Commands;
|
namespace Tests\Feature\Commands;
|
||||||
|
|
||||||
use App\Models\Expense\Bill;
|
use App\Jobs\Expense\CreateBill;
|
||||||
use App\Notifications\Expense\Bill as BillNotification;
|
use App\Notifications\Expense\Bill as BillNotification;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
use Jenssegers\Date\Date;
|
use Jenssegers\Date\Date;
|
||||||
@ -23,7 +23,7 @@ class BillReminderTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
Notification::fake();
|
Notification::fake();
|
||||||
|
|
||||||
$bill = Bill::create($this->getBillRequest());
|
$bill = $this->dispatch(new CreateBill($this->getBillRequest()));
|
||||||
|
|
||||||
Date::setTestNow(Date::now()->subDays($this->addDay));
|
Date::setTestNow(Date::now()->subDays($this->addDay));
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ class BillReminderTest extends FeatureTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copied in InvoicesTest
|
* Bill request
|
||||||
*
|
*
|
||||||
* @param int $recurring
|
* @param int $recurring
|
||||||
* @return array
|
* @return array
|
||||||
@ -58,7 +58,7 @@ class BillReminderTest extends FeatureTestCase
|
|||||||
'order_number' => '1',
|
'order_number' => '1',
|
||||||
'currency_code' => setting('default.currency'),
|
'currency_code' => setting('default.currency'),
|
||||||
'currency_rate' => '1',
|
'currency_rate' => '1',
|
||||||
'item' => $items,
|
'items' => $items,
|
||||||
'discount' => '0',
|
'discount' => '0',
|
||||||
'notes' => $this->faker->text(5),
|
'notes' => $this->faker->text(5),
|
||||||
'category_id' => $this->company->categories()->type('income')->first()->id,
|
'category_id' => $this->company->categories()->type('income')->first()->id,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Commands;
|
namespace Tests\Feature\Commands;
|
||||||
|
|
||||||
use App\Models\Income\Invoice;
|
use App\Jobs\Income\CreateInvoice;
|
||||||
use App\Notifications\Income\Invoice as InvoiceNotification;
|
use App\Notifications\Income\Invoice as InvoiceNotification;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
use Jenssegers\Date\Date;
|
use Jenssegers\Date\Date;
|
||||||
@ -23,7 +23,7 @@ class InvoiceReminderTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
Notification::fake();
|
Notification::fake();
|
||||||
|
|
||||||
$invoice = Invoice::create($this->getInvoiceRequest());
|
$invoice = $this->dispatch(new CreateInvoice($this->getInvoiceRequest()));
|
||||||
|
|
||||||
Date::setTestNow(Date::now()->addDay($this->addDay));
|
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
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getInvoiceRequest($recurring = 0)
|
private function getInvoiceRequest()
|
||||||
{
|
{
|
||||||
$amount = $this->faker->randomFloat(2, 2);
|
$amount = $this->faker->randomFloat(2, 2);
|
||||||
|
|
||||||
@ -58,7 +57,7 @@ class InvoiceReminderTest extends FeatureTestCase
|
|||||||
'order_number' => '1',
|
'order_number' => '1',
|
||||||
'currency_code' => setting('default.currency'),
|
'currency_code' => setting('default.currency'),
|
||||||
'currency_rate' => '1',
|
'currency_rate' => '1',
|
||||||
'item' => $items,
|
'items' => $items,
|
||||||
'discount' => '0',
|
'discount' => '0',
|
||||||
'notes' => $this->faker->text(5),
|
'notes' => $this->faker->text(5),
|
||||||
'category_id' => $this->company->categories()->type('income')->first()->id,
|
'category_id' => $this->company->categories()->type('income')->first()->id,
|
||||||
@ -73,13 +72,6 @@ class InvoiceReminderTest extends FeatureTestCase
|
|||||||
'company_id' => $this->company->id,
|
'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;
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ class DashboardTest extends FeatureTestCase
|
|||||||
public function testItShouldSeeDashboard()
|
public function testItShouldSeeDashboard()
|
||||||
{
|
{
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(url('/'))
|
->get(route('dashboard'))
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->assertSeeText(trans('general.dashboard'));
|
->assertSeeText(trans('general.dashboard'));
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Common;
|
namespace Tests\Feature\Common;
|
||||||
|
|
||||||
use App\Models\Common\Item;
|
use App\Jobs\Common\CreateItem;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ class ItemsTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldSeeItemUpdatePage()
|
public function testItShouldSeeItemUpdatePage()
|
||||||
{
|
{
|
||||||
$item = Item::create($this->getItemRequest());
|
$item = $this->dispatch(new CreateItem($this->getItemRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('items.edit', ['item' => $item->id]))
|
->get(route('items.edit', ['item' => $item->id]))
|
||||||
@ -47,7 +47,7 @@ class ItemsTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
$request = $this->getItemRequest();
|
$request = $this->getItemRequest();
|
||||||
|
|
||||||
$item = Item::create($request);
|
$item = $this->dispatch(new CreateItem($request));
|
||||||
|
|
||||||
$request['name'] = $this->faker->text(15);
|
$request['name'] = $this->faker->text(15);
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ class ItemsTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldDeleteItem()
|
public function testItShouldDeleteItem()
|
||||||
{
|
{
|
||||||
$item = Item::create($this->getItemRequest());
|
$item = $this->dispatch(new CreateItem($this->getItemRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('items.destroy', ['item' => $item]))
|
->delete(route('items.destroy', ['item' => $item]))
|
||||||
@ -80,7 +80,7 @@ class ItemsTest extends FeatureTestCase
|
|||||||
'description' => $this->faker->text(100),
|
'description' => $this->faker->text(100),
|
||||||
'purchase_price' => $this->faker->randomFloat(2, 10, 20),
|
'purchase_price' => $this->faker->randomFloat(2, 10, 20),
|
||||||
'sale_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' => '',
|
'tax_id' => '',
|
||||||
'enabled' => $this->faker->boolean ? 1 : 0
|
'enabled' => $this->faker->boolean ? 1 : 0
|
||||||
];
|
];
|
||||||
|
@ -35,7 +35,7 @@ class BillsTest extends FeatureTestCase
|
|||||||
public function testItShouldCreateBillWithRecurring()
|
public function testItShouldCreateBillWithRecurring()
|
||||||
{
|
{
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->post(route('bills.store'), $this->getBillRequest(1))
|
->post(route('bills.store'), $this->getBillRequest(true))
|
||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
|
|
||||||
$this->assertFlashLevel('success');
|
$this->assertFlashLevel('success');
|
||||||
@ -43,7 +43,7 @@ class BillsTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldSeeBillUpdatePage()
|
public function testItShouldSeeBillUpdatePage()
|
||||||
{
|
{
|
||||||
$bill = dispatch_now(new CreateBill($this->getBillRequest()));
|
$bill = $this->dispatch(new CreateBill($this->getBillRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('bills.edit', ['bill' => $bill->id]))
|
->get(route('bills.edit', ['bill' => $bill->id]))
|
||||||
@ -54,35 +54,35 @@ class BillsTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldUpdateBill()
|
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;
|
$request['contact_name'] = $this->faker->name;
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->patch(route('bills.update', $bill->id), $request)
|
->patch(route('bills.update', $bill->id), $request)
|
||||||
->assertStatus(302);
|
->assertStatus(200);
|
||||||
|
|
||||||
$this->assertFlashLevel('success');
|
$this->assertFlashLevel('success');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItShouldDeleteBill()
|
public function testItShouldDeleteBill()
|
||||||
{
|
{
|
||||||
$bill = dispatch_now(new CreateBill($this->getBillRequest()));
|
$bill = $this->dispatch(new CreateBill($this->getBillRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('bills.destroy', $bill->id))
|
->delete(route('bills.destroy', $bill->id))
|
||||||
->assertStatus(302)
|
->assertStatus(200);
|
||||||
->assertRedirect(route('bills.index'));
|
|
||||||
|
|
||||||
$this->assertFlashLevel('success');
|
$this->assertFlashLevel('success');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getBillRequest($recurring = 0)
|
private function getBillRequest($recurring = false)
|
||||||
{
|
{
|
||||||
$amount = $this->faker->randomFloat(2, 2);
|
$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 = [
|
$data = [
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
@ -95,7 +95,7 @@ class BillsTest extends FeatureTestCase
|
|||||||
'items' => $items,
|
'items' => $items,
|
||||||
'discount' => '0',
|
'discount' => '0',
|
||||||
'notes' => $this->faker->text(5),
|
'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',
|
'recurring_frequency' => 'no',
|
||||||
'contact_id' => '0',
|
'contact_id' => '0',
|
||||||
'contact_name' => $this->faker->name,
|
'contact_name' => $this->faker->name,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Expenses;
|
namespace Tests\Feature\Expenses;
|
||||||
|
|
||||||
use App\Models\Banking\Transaction;
|
use App\Jobs\Banking\CreateTransaction;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ class PaymentsTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
$request = $this->getPaymentRequest();
|
$request = $this->getPaymentRequest();
|
||||||
|
|
||||||
$payment = Transaction::create($request);
|
$payment = $this->dispatch(new CreateTransaction($request));
|
||||||
|
|
||||||
$request['name'] = $this->faker->text(15);
|
$request['name'] = $this->faker->text(15);
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class PaymentsTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldDeletePayment()
|
public function testItShouldDeletePayment()
|
||||||
{
|
{
|
||||||
$payment = Transaction::create($this->getPaymentRequest());
|
$payment = $this->dispatch(new CreateTransaction($this->getPaymentRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('payments.destroy', $payment->id))
|
->delete(route('payments.destroy', $payment->id))
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Expenses;
|
namespace Tests\Feature\Expenses;
|
||||||
|
|
||||||
use App\Models\Common\Contact;
|
use App\Jobs\Common\CreateContact;
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
class VendorsTest extends FeatureTestCase
|
class VendorsTest extends FeatureTestCase
|
||||||
@ -34,7 +34,7 @@ class VendorsTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldSeeVendorDetailPage()
|
public function testItShouldSeeVendorDetailPage()
|
||||||
{
|
{
|
||||||
$vendor = Contact::create($this->getVendorRequest());
|
$vendor = $this->dispatch(new CreateContact($this->getVendorRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('vendors.show', ['vendor' => $vendor->id]))
|
->get(route('vendors.show', ['vendor' => $vendor->id]))
|
||||||
@ -44,7 +44,7 @@ class VendorsTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldSeeVendorUpdatePage()
|
public function testItShouldSeeVendorUpdatePage()
|
||||||
{
|
{
|
||||||
$vendor = Contact::create($this->getVendorRequest());
|
$vendor = $this->dispatch(new CreateContact($this->getVendorRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('vendors.edit', ['vendor' => $vendor->id]))
|
->get(route('vendors.edit', ['vendor' => $vendor->id]))
|
||||||
@ -57,7 +57,7 @@ class VendorsTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
$request = $this->getVendorRequest();
|
$request = $this->getVendorRequest();
|
||||||
|
|
||||||
$vendor = Contact::create($request);
|
$vendor = $this->dispatch(new CreateContact($request));
|
||||||
|
|
||||||
$request['name'] = $this->faker->name;
|
$request['name'] = $this->faker->name;
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ class VendorsTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldDeleteVendor()
|
public function testItShouldDeleteVendor()
|
||||||
{
|
{
|
||||||
$vendor = Contact::create($this->getVendorRequest());
|
$vendor = $this->dispatch(new CreateContact($this->getVendorRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('vendors.destroy', $vendor->id))
|
->delete(route('vendors.destroy', $vendor->id))
|
||||||
|
@ -26,7 +26,7 @@ abstract class FeatureTestCase extends TestCase
|
|||||||
|
|
||||||
$this->faker = Factory::create();
|
$this->faker = Factory::create();
|
||||||
$this->user = User::first();
|
$this->user = User::first();
|
||||||
$this->company = $this->user->first()->companies()->first();
|
$this->company = $this->user->companies()->first();
|
||||||
|
|
||||||
// Set Company settings
|
// Set Company settings
|
||||||
setting()->forgetAll();
|
setting()->forgetAll();
|
||||||
@ -48,7 +48,7 @@ abstract class FeatureTestCase extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$company) {
|
if (!$company) {
|
||||||
$company = $user->companies()->first();
|
$company = $this->company;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->startSession();
|
$this->startSession();
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Incomes;
|
namespace Tests\Feature\Incomes;
|
||||||
|
|
||||||
|
use App\Jobs\Common\CreateContact;
|
||||||
use App\Models\Auth\User;
|
use App\Models\Auth\User;
|
||||||
use App\Models\Common\Contact;
|
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
class CustomersTest extends FeatureTestCase
|
class CustomersTest extends FeatureTestCase
|
||||||
@ -62,7 +62,7 @@ class CustomersTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldSeeCustomerDetailPage()
|
public function testItShouldSeeCustomerDetailPage()
|
||||||
{
|
{
|
||||||
$customer = Contact::create($this->getCustomerRequest());
|
$customer = $this->dispatch(new CreateContact($this->getCustomerRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('customers.show', ['customer' => $customer->id]))
|
->get(route('customers.show', ['customer' => $customer->id]))
|
||||||
@ -72,7 +72,7 @@ class CustomersTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldSeeCustomerUpdatePage()
|
public function testItShouldSeeCustomerUpdatePage()
|
||||||
{
|
{
|
||||||
$customer = Contact::create($this->getCustomerRequest());
|
$customer = $this->dispatch(new CreateContact($this->getCustomerRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('customers.edit', ['customer' => $customer->id]))
|
->get(route('customers.edit', ['customer' => $customer->id]))
|
||||||
@ -85,7 +85,7 @@ class CustomersTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
$request = $this->getCustomerRequest();
|
$request = $this->getCustomerRequest();
|
||||||
|
|
||||||
$customer = Contact::create($request);
|
$customer = $this->dispatch(new CreateContact($request));
|
||||||
|
|
||||||
$request['name'] = $this->faker->name;
|
$request['name'] = $this->faker->name;
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ class CustomersTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldDeleteCustomer()
|
public function testItShouldDeleteCustomer()
|
||||||
{
|
{
|
||||||
$customer = Contact::create($this->getCustomerRequest());
|
$customer = $this->dispatch(new CreateContact($this->getCustomerRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('customers.destroy', $customer->id))
|
->delete(route('customers.destroy', $customer->id))
|
||||||
@ -135,10 +135,10 @@ class CustomersTest extends FeatureTestCase
|
|||||||
$password = $this->faker->password;
|
$password = $this->faker->password;
|
||||||
|
|
||||||
return $this->getCustomerRequest() + [
|
return $this->getCustomerRequest() + [
|
||||||
'create_user' => 1,
|
'create_user' => 1,
|
||||||
'locale' => 'en-GB',
|
'locale' => 'en-GB',
|
||||||
'password' => $password,
|
'password' => $password,
|
||||||
'password_confirmation' => $password
|
'password_confirmation' => $password
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ class InvoicesTest extends FeatureTestCase
|
|||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('invoices.create'))
|
->get(route('invoices.create'))
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->assertSeeText(trans( trans_choice('general.invoices', 1)));
|
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.invoices', 1)]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItShouldCreateInvoice()
|
public function testItShouldCreateInvoice()
|
||||||
@ -35,7 +35,7 @@ class InvoicesTest extends FeatureTestCase
|
|||||||
public function testItShouldCreateInvoiceWithRecurring()
|
public function testItShouldCreateInvoiceWithRecurring()
|
||||||
{
|
{
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->post(route('invoices.store'), $this->getInvoiceRequest(1))
|
->post(route('invoices.store'), $this->getInvoiceRequest(true))
|
||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
|
|
||||||
$this->assertFlashLevel('success');
|
$this->assertFlashLevel('success');
|
||||||
@ -43,7 +43,7 @@ class InvoicesTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldSeeInvoiceUpdatePage()
|
public function testItShouldSeeInvoiceUpdatePage()
|
||||||
{
|
{
|
||||||
$invoice = dispatch_now(new CreateInvoice($this->getInvoiceRequest()));
|
$invoice = $this->dispatch(new CreateInvoice($this->getInvoiceRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('invoices.edit', ['invoice' => $invoice->id]))
|
->get(route('invoices.edit', ['invoice' => $invoice->id]))
|
||||||
@ -54,7 +54,9 @@ class InvoicesTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldUpdateInvoice()
|
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;
|
$request['contact_name'] = $this->faker->name;
|
||||||
|
|
||||||
@ -67,7 +69,7 @@ class InvoicesTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldDeleteInvoice()
|
public function testItShouldDeleteInvoice()
|
||||||
{
|
{
|
||||||
$invoice = dispatch_now(new CreateInvoice($this->getInvoiceRequest()));
|
$invoice = $this->dispatch(new CreateInvoice($this->getInvoiceRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('invoices.destroy', $invoice->id))
|
->delete(route('invoices.destroy', $invoice->id))
|
||||||
@ -76,11 +78,11 @@ class InvoicesTest extends FeatureTestCase
|
|||||||
$this->assertFlashLevel('success');
|
$this->assertFlashLevel('success');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getInvoiceRequest($recurring = 0)
|
private function getInvoiceRequest($recurring = false)
|
||||||
{
|
{
|
||||||
$amount = $this->faker->randomFloat(2, 2);
|
$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 = [
|
$data = [
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
@ -93,7 +95,7 @@ class InvoicesTest extends FeatureTestCase
|
|||||||
'items' => $items,
|
'items' => $items,
|
||||||
'discount' => '0',
|
'discount' => '0',
|
||||||
'notes' => $this->faker->text(5),
|
'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',
|
'recurring_frequency' => 'no',
|
||||||
'contact_id' => '0',
|
'contact_id' => '0',
|
||||||
'contact_name' => $this->faker->name,
|
'contact_name' => $this->faker->name,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Incomes;
|
namespace Tests\Feature\Incomes;
|
||||||
|
|
||||||
use App\Models\Banking\Transaction;
|
use App\Jobs\Banking\CreateTransaction;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ class RevenuesTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
$request = $this->getRevenueRequest();
|
$request = $this->getRevenueRequest();
|
||||||
|
|
||||||
$revenue = Transaction::create($request);
|
$revenue = $this->dispatch(new CreateTransaction($request));
|
||||||
|
|
||||||
$request['name'] = $this->faker->text(15);
|
$request['name'] = $this->faker->text(15);
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class RevenuesTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldDeleteRevenue()
|
public function testItShouldDeleteRevenue()
|
||||||
{
|
{
|
||||||
$revenue = Transaction::create($this->getRevenueRequest());
|
$revenue = $this->dispatch(new CreateTransaction($this->getRevenueRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('revenues.destroy', $revenue->id))
|
->delete(route('revenues.destroy', $revenue->id))
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Settings;
|
namespace Tests\Feature\Settings;
|
||||||
|
|
||||||
use App\Models\Setting\Category;
|
use App\Jobs\Setting\CreateCategory;
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
class CategoriesTest extends FeatureTestCase
|
class CategoriesTest extends FeatureTestCase
|
||||||
@ -34,7 +34,7 @@ class CategoriesTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldSeeCategoryUpdatePage()
|
public function testItShouldSeeCategoryUpdatePage()
|
||||||
{
|
{
|
||||||
$category = Category::create($this->getCategoryRequest());
|
$category = $this->dispatch(new CreateCategory($this->getCategoryRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('categories.edit', ['category' => $category->id]))
|
->get(route('categories.edit', ['category' => $category->id]))
|
||||||
@ -46,7 +46,7 @@ class CategoriesTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
$request = $this->getCategoryRequest();
|
$request = $this->getCategoryRequest();
|
||||||
|
|
||||||
$category = Category::create($request);
|
$category = $this->dispatch(new CreateCategory($request));
|
||||||
|
|
||||||
$request['name'] = $this->faker->text(15);
|
$request['name'] = $this->faker->text(15);
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ class CategoriesTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldDeleteCategory()
|
public function testItShouldDeleteCategory()
|
||||||
{
|
{
|
||||||
$category = Category::create($this->getCategoryRequest());
|
$category = $this->dispatch(new CreateCategory($this->getCategoryRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('categories.destroy', $category->id))
|
->delete(route('categories.destroy', $category->id))
|
||||||
@ -73,7 +73,7 @@ class CategoriesTest extends FeatureTestCase
|
|||||||
return [
|
return [
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
'name' => $this->faker->text(15),
|
'name' => $this->faker->text(15),
|
||||||
'type' => 'other',
|
'type' => 'item',
|
||||||
'color' => $this->faker->text(15),
|
'color' => $this->faker->text(15),
|
||||||
'enabled' => $this->faker->boolean ? 1 : 0
|
'enabled' => $this->faker->boolean ? 1 : 0
|
||||||
];
|
];
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Settings;
|
namespace Tests\Feature\Settings;
|
||||||
|
|
||||||
use App\Models\Setting\Currency;
|
use App\Jobs\Setting\CreateCurrency;
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
class CurrenciesTest extends FeatureTestCase
|
class CurrenciesTest extends FeatureTestCase
|
||||||
@ -36,7 +36,7 @@ class CurrenciesTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
$request = $this->getCurrencyRequest();
|
$request = $this->getCurrencyRequest();
|
||||||
|
|
||||||
$currency = Currency::create($request);
|
$currency = $this->dispatch(new CreateCurrency($request));
|
||||||
|
|
||||||
$request['name'] = $this->faker->text(15);
|
$request['name'] = $this->faker->text(15);
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ class CurrenciesTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldDeleteCurrency()
|
public function testItShouldDeleteCurrency()
|
||||||
{
|
{
|
||||||
$currency = Currency::create($this->getCurrencyRequest());
|
$currency = $this->dispatch(new CreateCurrency($this->getCurrencyRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('currencies.destroy', $currency->id))
|
->delete(route('currencies.destroy', $currency->id))
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Settings;
|
namespace Tests\Feature\Settings;
|
||||||
|
|
||||||
use App\Models\Setting\Tax;
|
use App\Jobs\Setting\CreateTax;
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
class TaxesTest extends FeatureTestCase
|
class TaxesTest extends FeatureTestCase
|
||||||
@ -36,7 +36,7 @@ class TaxesTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
$request = $this->getTaxRequest();
|
$request = $this->getTaxRequest();
|
||||||
|
|
||||||
$tax = Tax::create($request);
|
$tax = $this->dispatch(new CreateTax($request));
|
||||||
|
|
||||||
$request['name'] = $this->faker->text(15);
|
$request['name'] = $this->faker->text(15);
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ class TaxesTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldDeleteTax()
|
public function testItShouldDeleteTax()
|
||||||
{
|
{
|
||||||
$tax = Tax::create($this->getTaxRequest());
|
$tax = $this->dispatch(new CreateTax($this->getTaxRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('taxes.destroy', $tax->id))
|
->delete(route('taxes.destroy', $tax->id))
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Tests;
|
namespace Tests;
|
||||||
|
|
||||||
|
use App\Traits\Jobs;
|
||||||
use Artisan;
|
use Artisan;
|
||||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
@ -9,7 +10,7 @@ use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
|||||||
|
|
||||||
abstract class TestCase extends BaseTestCase
|
abstract class TestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
use CreatesApplication, DatabaseMigrations;
|
use CreatesApplication, DatabaseMigrations, Jobs;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user