fixed tests
This commit is contained in:
parent
63ab57730d
commit
2cdc431f8c
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,3 +15,4 @@ robots.txt
|
|||||||
_ide_helper.php
|
_ide_helper.php
|
||||||
.phpstorm.meta.php
|
.phpstorm.meta.php
|
||||||
/storage/debugbar/*
|
/storage/debugbar/*
|
||||||
|
.phpunit.result.cache
|
||||||
|
@ -30,7 +30,7 @@ class CreateReconciliation extends Job
|
|||||||
$transactions = $this->request->get('transactions');
|
$transactions = $this->request->get('transactions');
|
||||||
|
|
||||||
$reconciliation = Reconciliation::create([
|
$reconciliation = Reconciliation::create([
|
||||||
'company_id' => session('company_id'),
|
'company_id' => $this->request['company_id'],
|
||||||
'account_id' => $this->request->get('account_id'),
|
'account_id' => $this->request->get('account_id'),
|
||||||
'started_at' => $this->request->get('started_at'),
|
'started_at' => $this->request->get('started_at'),
|
||||||
'ended_at' => $this->request->get('ended_at'),
|
'ended_at' => $this->request->get('ended_at'),
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Faker\Generator;
|
|
||||||
use App\Models\Auth\User;
|
|
||||||
use App\Models\Common\Item;
|
|
||||||
use App\Models\Common\Company;
|
|
||||||
use Illuminate\Database\Eloquent\Factory;
|
|
||||||
|
|
||||||
/** @var Factory $factory */
|
|
||||||
$factory->define(Item::class, function (Generator $faker) {
|
|
||||||
/** @var User $user */
|
|
||||||
$user = User::first();
|
|
||||||
/** @var Company $company */
|
|
||||||
$company = $user->companies()->first();
|
|
||||||
|
|
||||||
return [
|
|
||||||
'name' => $faker->title,
|
|
||||||
'company_id' => $company->id,
|
|
||||||
'description' => $faker->text(100),
|
|
||||||
'purchase_price' => $faker->randomFloat(2,10,20),
|
|
||||||
'sale_price' => $faker->randomFloat(2,10,20),
|
|
||||||
'category_id' => $company->categories()->first()->id,
|
|
||||||
'tax_id' => $company->taxes()->first()->id,
|
|
||||||
'enabled' => $this->faker->boolean ? 1 : 0
|
|
||||||
];
|
|
||||||
});
|
|
21
database/factories/ItemFactory.php
Normal file
21
database/factories/ItemFactory.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Auth\User;
|
||||||
|
use App\Models\Common\Item;
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
|
$factory->define(Item::class, function (Faker $faker) {
|
||||||
|
$user = User::first();
|
||||||
|
$company = $user->companies()->first();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'company_id' => $company->id,
|
||||||
|
'name' => $faker->text(15),
|
||||||
|
'description' => $faker->text(100),
|
||||||
|
'purchase_price' => $faker->randomFloat(2, 10, 20),
|
||||||
|
'sale_price' => $faker->randomFloat(2, 10, 20),
|
||||||
|
'category_id' => $company->categories()->type('item')->pluck('id')->first(),
|
||||||
|
'tax_id' => '',
|
||||||
|
'enabled' => $faker->boolean ? 1 : 0
|
||||||
|
];
|
||||||
|
});
|
28
database/factories/TransactionFactory.php
Normal file
28
database/factories/TransactionFactory.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Auth\User;
|
||||||
|
use App\Models\Banking\Transaction;
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
|
|
||||||
|
$factory->define(Transaction::class, function (Faker $faker) {
|
||||||
|
$user = User::first();
|
||||||
|
$company = $user->companies()->first();
|
||||||
|
|
||||||
|
$attachment = UploadedFile::fake()->create('image.jpg');
|
||||||
|
|
||||||
|
return [
|
||||||
|
'company_id' => $company->id,
|
||||||
|
'type' => 'income',
|
||||||
|
'account_id' => setting('default.account'),
|
||||||
|
'paid_at' => $faker->date(),
|
||||||
|
'amount' => $faker->randomFloat(2, 2),
|
||||||
|
'currency_code' => setting('default.currency'),
|
||||||
|
'currency_rate' => '1',
|
||||||
|
'description' => $faker->text(5),
|
||||||
|
'category_id' => $company->categories()->type('income')->first()->id,
|
||||||
|
'reference' => $faker->text(5),
|
||||||
|
'payment_method' => setting('default.payment_method'),
|
||||||
|
'attachment' => $attachment,
|
||||||
|
];
|
||||||
|
});
|
@ -3,14 +3,15 @@
|
|||||||
namespace Database\Seeds;
|
namespace Database\Seeds;
|
||||||
|
|
||||||
use App\Abstracts\Model;
|
use App\Abstracts\Model;
|
||||||
use App\Models\Auth\User;
|
use App\Jobs\Auth\CreateUser;
|
||||||
use App\Models\Common\Company;
|
use App\Models\Common\Company;
|
||||||
use Artisan;
|
use App\Traits\Jobs;
|
||||||
use Date;
|
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
class TestCompany extends Seeder
|
class TestCompany extends Seeder
|
||||||
{
|
{
|
||||||
|
use Jobs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the database seeds.
|
* Run the database seeds.
|
||||||
*
|
*
|
||||||
@ -37,8 +38,8 @@ class TestCompany extends Seeder
|
|||||||
|
|
||||||
setting()->setExtraColumns(['company_id' => '1']);
|
setting()->setExtraColumns(['company_id' => '1']);
|
||||||
setting()->set([
|
setting()->set([
|
||||||
'company.name' => 'Test Inc.',
|
'company.name' => 'Test Company',
|
||||||
'company.email' => 'info@test.com',
|
'company.email' => 'test@company.com',
|
||||||
'company.address' => 'New Street 1254',
|
'company.address' => 'New Street 1254',
|
||||||
'localisation.financial_start' => '01-01',
|
'localisation.financial_start' => '01-01',
|
||||||
'default.currency' => 'USD',
|
'default.currency' => 'USD',
|
||||||
@ -46,8 +47,8 @@ class TestCompany extends Seeder
|
|||||||
'default.payment_method' => 'offline-payments.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' => '0',
|
'schedule.send_invoice_reminder' => '1',
|
||||||
'schedule.send_bill_reminder' => '0',
|
'schedule.send_bill_reminder' => '1',
|
||||||
'wizard.completed' => '1',
|
'wizard.completed' => '1',
|
||||||
'contact.type.customer' => 'customer',
|
'contact.type.customer' => 'customer',
|
||||||
'contact.type.vendor' => 'vendor',
|
'contact.type.vendor' => 'vendor',
|
||||||
@ -59,25 +60,16 @@ class TestCompany extends Seeder
|
|||||||
|
|
||||||
public function createUser()
|
public function createUser()
|
||||||
{
|
{
|
||||||
// Create user
|
$this->dispatch(new CreateUser([
|
||||||
$user = User::create([
|
'name' => 'Test',
|
||||||
'name' => 'Admin',
|
'email' => 'test@company.com',
|
||||||
'email' => 'admin@akaunting.com',
|
|
||||||
'password' => '123456',
|
'password' => '123456',
|
||||||
'last_logged_in_at' => Date::now(),
|
'locale' => 'en-GB',
|
||||||
]);
|
'companies' => ['1'],
|
||||||
|
'roles' => ['1'],
|
||||||
|
'enabled' => '1',
|
||||||
|
]));
|
||||||
|
|
||||||
// Attach Role
|
$this->command->info('Test user created.');
|
||||||
$user->roles()->attach(1);
|
|
||||||
|
|
||||||
// Attach company
|
|
||||||
$user->companies()->attach(1);
|
|
||||||
|
|
||||||
Artisan::call('user:seed', [
|
|
||||||
'user' => $user->id,
|
|
||||||
'company' => 1,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->command->info('Admin user created.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ class UsersTest extends FeatureTestCase
|
|||||||
'password_confirmation' => $password,
|
'password_confirmation' => $password,
|
||||||
'locale' => 'en-GB',
|
'locale' => 'en-GB',
|
||||||
'companies' => [$this->company->id],
|
'companies' => [$this->company->id],
|
||||||
'roles' => Role::take(1)->pluck('id')->toArray(),
|
'roles' => ['1'],
|
||||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
namespace Tests\Feature\Banking;
|
namespace Tests\Feature\Banking;
|
||||||
|
|
||||||
use App\Jobs\Banking\CreateAccount;
|
use App\Jobs\Banking\CreateAccount;
|
||||||
use App\Models\Banking\Account;
|
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
class AccountsTest extends FeatureTestCase
|
class AccountsTest extends FeatureTestCase
|
||||||
@ -47,7 +46,7 @@ class AccountsTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
$request = $this->getAccountRequest();
|
$request = $this->getAccountRequest();
|
||||||
|
|
||||||
$account= Account::create($request);
|
$account = $this->dispatch(new CreateAccount($request));
|
||||||
|
|
||||||
$request['name'] = $this->faker->text(5);
|
$request['name'] = $this->faker->text(5);
|
||||||
|
|
||||||
@ -60,7 +59,7 @@ class AccountsTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldDeleteAccount()
|
public function testItShouldDeleteAccount()
|
||||||
{
|
{
|
||||||
$account = Account::create($this->getAccountRequest());
|
$account = $this->dispatch(new CreateAccount($this->getAccountRequest()));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('accounts.destroy', ['account' => $account]))
|
->delete(route('accounts.destroy', ['account' => $account]))
|
||||||
@ -74,13 +73,13 @@ class AccountsTest extends FeatureTestCase
|
|||||||
return [
|
return [
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
'name' => $this->faker->text(5),
|
'name' => $this->faker->text(5),
|
||||||
'number' => '1',
|
'number' => (string) $this->faker->randomNumber(2),
|
||||||
'currency_code' => setting('default.currency'),
|
'currency_code' => setting('default.currency', 'USD'),
|
||||||
'opening_balance' => 0,
|
'opening_balance' => '0',
|
||||||
'bank_name' => $this->faker->text(5),
|
'bank_name' => $this->faker->text(5),
|
||||||
'bank_phone' => null,
|
'bank_phone' => null,
|
||||||
'bank_address' => null,
|
'bank_address' => null,
|
||||||
'default_account' => $this->faker->randomElement(['yes', 'no']),
|
'default_account' => 0,
|
||||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,6 @@ class ReconciliationsTest extends FeatureTestCase
|
|||||||
$this->assertFlashLevel('success');
|
$this->assertFlashLevel('success');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function getReconciliationRequest()
|
private function getReconciliationRequest()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace Tests\Feature\Banking;
|
namespace Tests\Feature\Banking;
|
||||||
|
|
||||||
use App\Jobs\Banking\CreateTransaction;
|
use App\Jobs\Banking\CreateTransaction;
|
||||||
use App\Jobs\Banking\CreateTransfer;
|
use App\Models\Banking\Transfer;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
@ -27,11 +27,9 @@ class TransfersTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldCreateTransfer()
|
public function testItShouldCreateTransfer()
|
||||||
{
|
{
|
||||||
// Create income
|
$income_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('income')));
|
||||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
|
|
||||||
|
|
||||||
// Create expense
|
$expense_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('expense')));
|
||||||
$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))
|
||||||
@ -42,31 +40,27 @@ class TransfersTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldSeeTransferUpdatePage()
|
public function testItShouldSeeTransferUpdatePage()
|
||||||
{
|
{
|
||||||
// Create income
|
$income_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('income')));
|
||||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
|
|
||||||
|
|
||||||
// Create expense
|
$expense_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('expense')));
|
||||||
$expense_transaction = $this->dispatch(new CreateTransaction($this->getExpenseRequest()));
|
|
||||||
|
|
||||||
$transfer = $this->dispatch(new CreateTransfer($this->getTransferRequest($income_transaction, $expense_transaction)));
|
$transfer = Transfer::create($this->getTransferRequest($income_transaction, $expense_transaction));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('transfers.edit', ['transfer' => $transfer->id]))
|
->get(route('transfers.edit', ['transfer' => $transfer->id]))
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->assertSee($expense_transaction->description);
|
->assertSee($transfer->description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItShouldUpdateTransfer()
|
public function testItShouldUpdateTransfer()
|
||||||
{
|
{
|
||||||
// Create income
|
$income_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('income')));
|
||||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
|
|
||||||
|
|
||||||
// Create expense
|
$expense_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('expense')));
|
||||||
$expense_transaction = $this->dispatch(new CreateTransaction($this->getExpenseRequest()));
|
|
||||||
|
|
||||||
$request = $this->getTransferRequest($income_transaction, $expense_transaction);
|
$request = $this->getTransferRequest($income_transaction, $expense_transaction);
|
||||||
|
|
||||||
$transfer = $this->dispatch(new CreateTransfer($request));
|
$transfer = Transfer::create($request);
|
||||||
|
|
||||||
$request['description'] = $this->faker->text(10);
|
$request['description'] = $this->faker->text(10);
|
||||||
|
|
||||||
@ -79,13 +73,11 @@ class TransfersTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testItShouldDeleteTransfer()
|
public function testItShouldDeleteTransfer()
|
||||||
{
|
{
|
||||||
// Create income
|
$income_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('income')));
|
||||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
|
|
||||||
|
|
||||||
// Create expense
|
$expense_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('expense')));
|
||||||
$expense_transaction = $this->dispatch(new CreateTransaction($this->getExpenseRequest()));
|
|
||||||
|
|
||||||
$transfer = $this->dispatch(new CreateTransfer($this->getTransferRequest($income_transaction, $expense_transaction)));
|
$transfer = Transfer::create($this->getTransferRequest($income_transaction, $expense_transaction));
|
||||||
|
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->delete(route('transfers.destroy', ['transfer' => $transfer->id]))
|
->delete(route('transfers.destroy', ['transfer' => $transfer->id]))
|
||||||
@ -112,43 +104,23 @@ class TransfersTest extends FeatureTestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getIncomeRequest()
|
private function getTransactionRequest($type)
|
||||||
{
|
{
|
||||||
$attachment = UploadedFile::fake()->create('image.jpg');
|
$attachment = UploadedFile::fake()->create('image.jpg');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
'type' => 'income',
|
'type' => $type,
|
||||||
'account_id' => setting('default.account'),
|
'account_id' => setting('default.account'),
|
||||||
'paid_at' => $this->faker->date(),
|
'paid_at' => $this->faker->date(),
|
||||||
'amount' => $this->faker->randomFloat(2, 2),
|
'amount' => $this->faker->randomFloat(2, 2),
|
||||||
'currency_code' => setting('default.currency'),
|
'currency_code' => setting('default.currency'),
|
||||||
'currency_rate' => '1',
|
'currency_rate' => '1',
|
||||||
'description' => $this->faker->text(5),
|
'description' => $this->faker->text(5),
|
||||||
'category_id' => $this->company->categories()->type('income')->first()->id,
|
'category_id' => $this->company->categories()->type($type)->first()->id,
|
||||||
'reference' => $this->faker->text(5),
|
'reference' => $this->faker->text(5),
|
||||||
'payment_method' => setting('default.payment_method'),
|
'payment_method' => setting('default.payment_method'),
|
||||||
'attachment' => $attachment
|
'attachment' => $attachment,
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getExpenseRequest()
|
|
||||||
{
|
|
||||||
$attachment = UploadedFile::fake()->create('image.jpg');
|
|
||||||
|
|
||||||
return [
|
|
||||||
'company_id' => $this->company->id,
|
|
||||||
'type' => 'expense',
|
|
||||||
'account_id' => setting('default.account'),
|
|
||||||
'paid_at' => $this->faker->date(),
|
|
||||||
'amount' => $this->faker->randomFloat(2, 2),
|
|
||||||
'currency_code' => setting('default.currency'),
|
|
||||||
'currency_rate' => '1',
|
|
||||||
'description' => $this->faker->text(5),
|
|
||||||
'category_id' => $this->company->categories()->type('expense')->first()->id,
|
|
||||||
'payment_method' => setting('default.payment_method'),
|
|
||||||
'reference' => $this->faker->text(5),
|
|
||||||
'attachment' => $attachment
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,19 @@ namespace Tests\Feature\Commands;
|
|||||||
|
|
||||||
use App\Jobs\Expense\CreateBill;
|
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 as Notification;
|
||||||
use Jenssegers\Date\Date;
|
use Jenssegers\Date\Date;
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
class BillReminderTest extends FeatureTestCase
|
class BillReminderTest extends FeatureTestCase
|
||||||
{
|
{
|
||||||
private $addDay;
|
private $add_days;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->addDay = 3;
|
$this->add_days = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBillReminderByDueDate()
|
public function testBillReminderByDueDate()
|
||||||
@ -25,7 +25,7 @@ class BillReminderTest extends FeatureTestCase
|
|||||||
|
|
||||||
$bill = $this->dispatch(new CreateBill($this->getBillRequest()));
|
$bill = $this->dispatch(new CreateBill($this->getBillRequest()));
|
||||||
|
|
||||||
Date::setTestNow(Date::now()->subDays($this->addDay));
|
Date::setTestNow(Date::now()->subDays($this->add_days));
|
||||||
|
|
||||||
$this->artisan('reminder:bill');
|
$this->artisan('reminder:bill');
|
||||||
|
|
||||||
@ -41,7 +41,6 @@ class BillReminderTest extends FeatureTestCase
|
|||||||
/**
|
/**
|
||||||
* Bill request
|
* Bill request
|
||||||
*
|
*
|
||||||
* @param int $recurring
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getBillRequest()
|
private function getBillRequest()
|
||||||
@ -51,26 +50,26 @@ class BillReminderTest extends FeatureTestCase
|
|||||||
$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 = [
|
||||||
'contact_id' => '0',
|
'company_id' => $this->company->id,
|
||||||
'billed_at' => $this->faker->date(),
|
'billed_at' => $this->faker->date(),
|
||||||
'due_at' => Date::now()->subDays($this->addDay - 1),
|
'due_at' => Date::now()->subDays($this->add_days - 1),
|
||||||
'bill_number' => '1',
|
'bill_number' => '1',
|
||||||
'order_number' => '1',
|
'order_number' => '1',
|
||||||
'currency_code' => setting('default.currency'),
|
'currency_code' => setting('default.currency', 'USD'),
|
||||||
'currency_rate' => '1',
|
'currency_rate' => '1',
|
||||||
'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('expense')->pluck('id')->first(),
|
||||||
'recurring_frequency' => 'no',
|
'recurring_frequency' => 'no',
|
||||||
|
'contact_id' => '0',
|
||||||
'contact_name' => $this->faker->name,
|
'contact_name' => $this->faker->name,
|
||||||
'contact_email' =>$this->faker->email,
|
'contact_email' =>$this->faker->email,
|
||||||
'contact_tax_number' => null,
|
'contact_tax_number' => null,
|
||||||
'contact_phone' => null,
|
'contact_phone' => null,
|
||||||
'contact_address' => $this->faker->address,
|
'contact_address' => $this->faker->address,
|
||||||
'bill_status_code' => 'sent',
|
'bill_status_code' => 'received',
|
||||||
'amount' => $amount,
|
'amount' => $amount,
|
||||||
'company_id' => $this->company->id,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -10,13 +10,13 @@ use Tests\Feature\FeatureTestCase;
|
|||||||
|
|
||||||
class InvoiceReminderTest extends FeatureTestCase
|
class InvoiceReminderTest extends FeatureTestCase
|
||||||
{
|
{
|
||||||
private $addDay;
|
private $add_days;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->addDay = 3;
|
$this->add_days = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvoiceReminderByDueDate()
|
public function testInvoiceReminderByDueDate()
|
||||||
@ -25,7 +25,7 @@ class InvoiceReminderTest extends FeatureTestCase
|
|||||||
|
|
||||||
$invoice = $this->dispatch(new CreateInvoice($this->getInvoiceRequest()));
|
$invoice = $this->dispatch(new CreateInvoice($this->getInvoiceRequest()));
|
||||||
|
|
||||||
Date::setTestNow(Date::now()->addDay($this->addDay));
|
Date::setTestNow(Date::now()->addDay($this->add_days));
|
||||||
|
|
||||||
$this->artisan('reminder:invoice');
|
$this->artisan('reminder:invoice');
|
||||||
|
|
||||||
@ -50,18 +50,19 @@ class InvoiceReminderTest extends FeatureTestCase
|
|||||||
$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 = [
|
||||||
'contact_id' => '0',
|
'company_id' => $this->company->id,
|
||||||
'invoiced_at' => $this->faker->date(),
|
'invoiced_at' => $this->faker->date(),
|
||||||
'due_at' => Date::now()->addDay($this->addDay - 1),
|
'due_at' => Date::now()->subDays($this->add_days - 1),
|
||||||
'invoice_number' => '1',
|
'invoice_number' => '1',
|
||||||
'order_number' => '1',
|
'order_number' => '1',
|
||||||
'currency_code' => setting('default.currency'),
|
'currency_code' => setting('default.currency', 'USD'),
|
||||||
'currency_rate' => '1',
|
'currency_rate' => '1',
|
||||||
'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_name' => $this->faker->name,
|
'contact_name' => $this->faker->name,
|
||||||
'contact_email' =>$this->faker->email,
|
'contact_email' =>$this->faker->email,
|
||||||
'contact_tax_number' => null,
|
'contact_tax_number' => null,
|
||||||
@ -69,7 +70,6 @@ class InvoiceReminderTest extends FeatureTestCase
|
|||||||
'contact_address' => $this->faker->address,
|
'contact_address' => $this->faker->address,
|
||||||
'invoice_status_code' => 'sent',
|
'invoice_status_code' => 'sent',
|
||||||
'amount' => $amount,
|
'amount' => $amount,
|
||||||
'company_id' => $this->company->id,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -90,7 +90,7 @@ class BillsTest extends FeatureTestCase
|
|||||||
'due_at' => $this->faker->date(),
|
'due_at' => $this->faker->date(),
|
||||||
'bill_number' => '1',
|
'bill_number' => '1',
|
||||||
'order_number' => '1',
|
'order_number' => '1',
|
||||||
'currency_code' => setting('default.currency'),
|
'currency_code' => setting('default.currency', 'USD'),
|
||||||
'currency_rate' => '1',
|
'currency_rate' => '1',
|
||||||
'items' => $items,
|
'items' => $items,
|
||||||
'discount' => '0',
|
'discount' => '0',
|
||||||
|
@ -9,15 +9,10 @@ use Tests\TestCase;
|
|||||||
|
|
||||||
abstract class FeatureTestCase extends TestCase
|
abstract class FeatureTestCase extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var \Faker\Generator
|
|
||||||
*/
|
|
||||||
protected $faker;
|
protected $faker;
|
||||||
|
|
||||||
/** @var User */
|
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
/** @var Company */
|
|
||||||
protected $company;
|
protected $company;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
|
@ -49,17 +49,6 @@ class CustomersTest extends FeatureTestCase
|
|||||||
$this->assertEquals($customer['email'], $user->email);
|
$this->assertEquals($customer['email'], $user->email);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItShouldNotCreateCustomerWithExistsUser()
|
|
||||||
{
|
|
||||||
$customer = $this->getCustomerRequestWithUser();
|
|
||||||
|
|
||||||
User::create($customer);
|
|
||||||
|
|
||||||
$this->loginAs()
|
|
||||||
->post(route('customers.store'), $customer)
|
|
||||||
->assertSessionHasErrors(['email']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItShouldSeeCustomerDetailPage()
|
public function testItShouldSeeCustomerDetailPage()
|
||||||
{
|
{
|
||||||
$customer = $this->dispatch(new CreateContact($this->getCustomerRequest()));
|
$customer = $this->dispatch(new CreateContact($this->getCustomerRequest()));
|
||||||
|
@ -90,7 +90,7 @@ class InvoicesTest extends FeatureTestCase
|
|||||||
'due_at' => $this->faker->date(),
|
'due_at' => $this->faker->date(),
|
||||||
'invoice_number' => '1',
|
'invoice_number' => '1',
|
||||||
'order_number' => '1',
|
'order_number' => '1',
|
||||||
'currency_code' => setting('default.currency'),
|
'currency_code' => setting('default.currency', 'USD'),
|
||||||
'currency_rate' => '1',
|
'currency_rate' => '1',
|
||||||
'items' => $items,
|
'items' => $items,
|
||||||
'discount' => '0',
|
'discount' => '0',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user