fixed tests
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace Tests\Feature\Banking;
|
||||
|
||||
use App\Jobs\Banking\CreateAccount;
|
||||
use App\Models\Banking\Account;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
class AccountsTest extends FeatureTestCase
|
||||
@@ -47,7 +46,7 @@ class AccountsTest extends FeatureTestCase
|
||||
{
|
||||
$request = $this->getAccountRequest();
|
||||
|
||||
$account= Account::create($request);
|
||||
$account = $this->dispatch(new CreateAccount($request));
|
||||
|
||||
$request['name'] = $this->faker->text(5);
|
||||
|
||||
@@ -60,7 +59,7 @@ class AccountsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldDeleteAccount()
|
||||
{
|
||||
$account = Account::create($this->getAccountRequest());
|
||||
$account = $this->dispatch(new CreateAccount($this->getAccountRequest()));
|
||||
|
||||
$this->loginAs()
|
||||
->delete(route('accounts.destroy', ['account' => $account]))
|
||||
@@ -74,13 +73,13 @@ class AccountsTest extends FeatureTestCase
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'name' => $this->faker->text(5),
|
||||
'number' => '1',
|
||||
'currency_code' => setting('default.currency'),
|
||||
'opening_balance' => 0,
|
||||
'number' => (string) $this->faker->randomNumber(2),
|
||||
'currency_code' => setting('default.currency', 'USD'),
|
||||
'opening_balance' => '0',
|
||||
'bank_name' => $this->faker->text(5),
|
||||
'bank_phone' => null,
|
||||
'bank_address' => null,
|
||||
'default_account' => $this->faker->randomElement(['yes', 'no']),
|
||||
'default_account' => 0,
|
||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -68,7 +68,6 @@ class ReconciliationsTest extends FeatureTestCase
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
|
||||
private function getReconciliationRequest()
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Tests\Feature\Banking;
|
||||
|
||||
use App\Jobs\Banking\CreateTransaction;
|
||||
use App\Jobs\Banking\CreateTransfer;
|
||||
use App\Models\Banking\Transfer;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
@@ -27,11 +27,9 @@ class TransfersTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldCreateTransfer()
|
||||
{
|
||||
// Create income
|
||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
|
||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('income')));
|
||||
|
||||
// Create expense
|
||||
$expense_transaction = $this->dispatch(new CreateTransaction($this->getExpenseRequest()));
|
||||
$expense_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('expense')));
|
||||
|
||||
$this->loginAs()
|
||||
->post(route('transfers.store'), $this->getTransferRequest($income_transaction, $expense_transaction))
|
||||
@@ -42,31 +40,27 @@ class TransfersTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldSeeTransferUpdatePage()
|
||||
{
|
||||
// Create income
|
||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
|
||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('income')));
|
||||
|
||||
// Create expense
|
||||
$expense_transaction = $this->dispatch(new CreateTransaction($this->getExpenseRequest()));
|
||||
$expense_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('expense')));
|
||||
|
||||
$transfer = $this->dispatch(new CreateTransfer($this->getTransferRequest($income_transaction, $expense_transaction)));
|
||||
$transfer = Transfer::create($this->getTransferRequest($income_transaction, $expense_transaction));
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('transfers.edit', ['transfer' => $transfer->id]))
|
||||
->assertStatus(200)
|
||||
->assertSee($expense_transaction->description);
|
||||
->assertSee($transfer->description);
|
||||
}
|
||||
|
||||
public function testItShouldUpdateTransfer()
|
||||
{
|
||||
// Create income
|
||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
|
||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('income')));
|
||||
|
||||
// Create expense
|
||||
$expense_transaction = $this->dispatch(new CreateTransaction($this->getExpenseRequest()));
|
||||
$expense_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('expense')));
|
||||
|
||||
$request = $this->getTransferRequest($income_transaction, $expense_transaction);
|
||||
|
||||
$transfer = $this->dispatch(new CreateTransfer($request));
|
||||
$transfer = Transfer::create($request);
|
||||
|
||||
$request['description'] = $this->faker->text(10);
|
||||
|
||||
@@ -79,13 +73,11 @@ class TransfersTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldDeleteTransfer()
|
||||
{
|
||||
// Create income
|
||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getIncomeRequest()));
|
||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('income')));
|
||||
|
||||
// Create expense
|
||||
$expense_transaction = $this->dispatch(new CreateTransaction($this->getExpenseRequest()));
|
||||
$expense_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('expense')));
|
||||
|
||||
$transfer = $this->dispatch(new CreateTransfer($this->getTransferRequest($income_transaction, $expense_transaction)));
|
||||
$transfer = Transfer::create($this->getTransferRequest($income_transaction, $expense_transaction));
|
||||
|
||||
$this->loginAs()
|
||||
->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');
|
||||
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'type' => 'income',
|
||||
'type' => $type,
|
||||
'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('income')->first()->id,
|
||||
'category_id' => $this->company->categories()->type($type)->first()->id,
|
||||
'reference' => $this->faker->text(5),
|
||||
'payment_method' => setting('default.payment_method'),
|
||||
'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
|
||||
'attachment' => $attachment,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user