fixed tests
This commit is contained in:
parent
661bd096aa
commit
906c493e25
40
composer.lock
generated
40
composer.lock
generated
@ -8,16 +8,16 @@
|
||||
"packages": [
|
||||
{
|
||||
"name": "akaunting/firewall",
|
||||
"version": "1.2.4",
|
||||
"version": "1.2.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/akaunting/firewall.git",
|
||||
"reference": "8ea7afac1d545fa66bf741284310c684340ecb4c"
|
||||
"reference": "924529c4ae1db454745aa59a2731679e8ff287b8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/akaunting/firewall/zipball/8ea7afac1d545fa66bf741284310c684340ecb4c",
|
||||
"reference": "8ea7afac1d545fa66bf741284310c684340ecb4c",
|
||||
"url": "https://api.github.com/repos/akaunting/firewall/zipball/924529c4ae1db454745aa59a2731679e8ff287b8",
|
||||
"reference": "924529c4ae1db454745aa59a2731679e8ff287b8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -67,7 +67,7 @@
|
||||
"waf",
|
||||
"xss"
|
||||
],
|
||||
"time": "2019-12-20T12:15:04+00:00"
|
||||
"time": "2020-01-04T18:36:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "akaunting/language",
|
||||
@ -1181,16 +1181,16 @@
|
||||
},
|
||||
{
|
||||
"name": "dingo/api",
|
||||
"version": "v2.4.0",
|
||||
"version": "v2.4.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dingo/api.git",
|
||||
"reference": "512eb1a0cd55a6f9f997d60183bf8bfb2a0f3187"
|
||||
"reference": "05299b02e98c2833fed7fee8ce223b4ba8d2b2d4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/dingo/api/zipball/512eb1a0cd55a6f9f997d60183bf8bfb2a0f3187",
|
||||
"reference": "512eb1a0cd55a6f9f997d60183bf8bfb2a0f3187",
|
||||
"url": "https://api.github.com/repos/dingo/api/zipball/05299b02e98c2833fed7fee8ce223b4ba8d2b2d4",
|
||||
"reference": "05299b02e98c2833fed7fee8ce223b4ba8d2b2d4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1259,7 +1259,7 @@
|
||||
"laravel",
|
||||
"restful"
|
||||
],
|
||||
"time": "2019-09-27T04:15:05+00:00"
|
||||
"time": "2020-01-06T12:31:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dingo/blueprint",
|
||||
@ -3165,16 +3165,16 @@
|
||||
},
|
||||
{
|
||||
"name": "league/flysystem",
|
||||
"version": "1.0.62",
|
||||
"version": "1.0.63",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/flysystem.git",
|
||||
"reference": "14dd5d7dff5fbc29ca9a2a53ff109760e40d91a0"
|
||||
"reference": "8132daec326565036bc8e8d1876f77ec183a7bd6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/14dd5d7dff5fbc29ca9a2a53ff109760e40d91a0",
|
||||
"reference": "14dd5d7dff5fbc29ca9a2a53ff109760e40d91a0",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/8132daec326565036bc8e8d1876f77ec183a7bd6",
|
||||
"reference": "8132daec326565036bc8e8d1876f77ec183a7bd6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -3245,7 +3245,7 @@
|
||||
"sftp",
|
||||
"storage"
|
||||
],
|
||||
"time": "2019-12-29T14:46:55+00:00"
|
||||
"time": "2020-01-04T16:30:31+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/fractal",
|
||||
@ -7125,16 +7125,16 @@
|
||||
},
|
||||
{
|
||||
"name": "facade/ignition",
|
||||
"version": "1.13.0",
|
||||
"version": "1.14.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/facade/ignition.git",
|
||||
"reference": "1d2103aefecc9c4e6975bcc77fc5eceb330adb33"
|
||||
"reference": "c6d36683b40e005cd395ddff1bbfbf0aa0fcd3c5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/facade/ignition/zipball/1d2103aefecc9c4e6975bcc77fc5eceb330adb33",
|
||||
"reference": "1d2103aefecc9c4e6975bcc77fc5eceb330adb33",
|
||||
"url": "https://api.github.com/repos/facade/ignition/zipball/c6d36683b40e005cd395ddff1bbfbf0aa0fcd3c5",
|
||||
"reference": "c6d36683b40e005cd395ddff1bbfbf0aa0fcd3c5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -7192,7 +7192,7 @@
|
||||
"laravel",
|
||||
"page"
|
||||
],
|
||||
"time": "2019-11-27T11:17:18+00:00"
|
||||
"time": "2020-01-06T09:32:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "facade/ignition-contracts",
|
||||
|
26
database/factories/Account.php
Normal file
26
database/factories/Account.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Auth\User;
|
||||
use App\Models\Banking\Account;
|
||||
use App\Models\Setting\Currency;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
|
||||
$factory->define(Account::class, function (Faker $faker) use ($company) {
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
'name' => $faker->text(5),
|
||||
'number' => (string) $faker->randomNumber(2),
|
||||
'currency_code' => setting('default.currency'),
|
||||
//'currency_code' => Currency::enabled()->get()->random(1)->pluck('code')->first(),
|
||||
'opening_balance' => '0',
|
||||
'bank_name' => $faker->text(5),
|
||||
'bank_phone' => null,
|
||||
'bank_address' => null,
|
||||
'enabled' => $faker->boolean ? 1 : 0,
|
||||
];
|
||||
});
|
@ -4,9 +4,11 @@ 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();
|
||||
$user = User::first();
|
||||
$company = $user->companies()->first();
|
||||
|
||||
$factory->define(Item::class, function (Faker $faker) use ($company) {
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
|
||||
return [
|
||||
'company_id' => $company->id,
|
||||
|
@ -27,23 +27,16 @@ class Accounts extends Seeder
|
||||
$company_id = $this->command->argument('company');
|
||||
|
||||
setting()->setExtraColumns(['company_id' => $company_id]);
|
||||
setting()->forgetAll();
|
||||
|
||||
$rows = [
|
||||
[
|
||||
'company_id' => $company_id,
|
||||
'name' => trans('demo.accounts.cash'),
|
||||
'number' => '1',
|
||||
'currency_code' => 'USD',
|
||||
'bank_name' => trans('demo.accounts.cash'),
|
||||
'enabled' => '1',
|
||||
],
|
||||
];
|
||||
$account = Account::create([
|
||||
'company_id' => $company_id,
|
||||
'name' => trans('demo.accounts.cash'),
|
||||
'number' => '1',
|
||||
'currency_code' => 'USD',
|
||||
'bank_name' => trans('demo.accounts.cash'),
|
||||
'enabled' => '1',
|
||||
]);
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$account = Account::create($row);
|
||||
|
||||
setting()->set('default.account', $account->id);
|
||||
}
|
||||
setting()->set('default.account', $account->id);
|
||||
}
|
||||
}
|
||||
|
@ -37,9 +37,6 @@ class InstallCommand extends Command
|
||||
$old_company_id = session('company_id');
|
||||
|
||||
session(['company_id' => $company_id]);
|
||||
setting()->setExtraColumns(['company_id' => $company_id]);
|
||||
setting()->forgetAll();
|
||||
setting()->load(true);
|
||||
|
||||
$module = module($alias);
|
||||
|
||||
@ -65,13 +62,9 @@ class InstallCommand extends Command
|
||||
event(new \App\Events\Module\Installed($alias, $company_id));
|
||||
|
||||
session()->forget('company_id');
|
||||
setting()->forgetAll();
|
||||
|
||||
if (!empty($old_company_id)) {
|
||||
session(['company_id' => $old_company_id]);
|
||||
|
||||
setting()->setExtraColumns(['company_id' => $old_company_id]);
|
||||
setting()->load(true);
|
||||
}
|
||||
|
||||
$this->info('Module installed!');
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace Tests\Feature\Banking;
|
||||
|
||||
use App\Jobs\Banking\CreateAccount;
|
||||
use App\Models\Banking\Account;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
class AccountsTest extends FeatureTestCase
|
||||
@ -26,7 +27,7 @@ class AccountsTest extends FeatureTestCase
|
||||
public function testItShouldCreateAccount()
|
||||
{
|
||||
$this->loginAs()
|
||||
->post(route('accounts.index'), $this->getAccountRequest())
|
||||
->post(route('accounts.index'), factory(Account::class)->raw())
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
@ -34,7 +35,7 @@ class AccountsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldSeeAccountUpdatePage()
|
||||
{
|
||||
$account = $this->dispatch(new CreateAccount($this->getAccountRequest()));
|
||||
$account = $this->dispatch(new CreateAccount(factory(Account::class)->raw()));
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('accounts.edit', ['account' => $account->id]))
|
||||
@ -44,7 +45,7 @@ class AccountsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldUpdateAccount()
|
||||
{
|
||||
$request = $this->getAccountRequest();
|
||||
$request = factory(Account::class)->raw();
|
||||
|
||||
$account = $this->dispatch(new CreateAccount($request));
|
||||
|
||||
@ -59,7 +60,7 @@ class AccountsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldDeleteAccount()
|
||||
{
|
||||
$account = $this->dispatch(new CreateAccount($this->getAccountRequest()));
|
||||
$account = $this->dispatch(new CreateAccount(factory(Account::class)->raw()));
|
||||
|
||||
$this->loginAs()
|
||||
->delete(route('accounts.destroy', ['account' => $account]))
|
||||
@ -67,20 +68,4 @@ class AccountsTest extends FeatureTestCase
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
private function getAccountRequest()
|
||||
{
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'name' => $this->faker->text(5),
|
||||
'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' => 0,
|
||||
'enabled' => $this->faker->boolean ? 1 : 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,8 @@
|
||||
|
||||
namespace Tests\Feature\Banking;
|
||||
|
||||
use App\Jobs\Banking\CreateTransaction;
|
||||
use App\Models\Banking\Transaction;
|
||||
use App\Models\Banking\Transfer;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
class TransfersTest extends FeatureTestCase
|
||||
@ -27,12 +26,8 @@ class TransfersTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldCreateTransfer()
|
||||
{
|
||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('income')));
|
||||
|
||||
$expense_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('expense')));
|
||||
|
||||
$this->loginAs()
|
||||
->post(route('transfers.store'), $this->getTransferRequest($income_transaction, $expense_transaction))
|
||||
->post(route('transfers.store'), $this->getRequest())
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
@ -40,11 +35,7 @@ class TransfersTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldSeeTransferUpdatePage()
|
||||
{
|
||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('income')));
|
||||
|
||||
$expense_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('expense')));
|
||||
|
||||
$transfer = Transfer::create($this->getTransferRequest($income_transaction, $expense_transaction));
|
||||
$transfer = Transfer::create($this->getRequest());
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('transfers.edit', ['transfer' => $transfer->id]))
|
||||
@ -54,11 +45,7 @@ class TransfersTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldUpdateTransfer()
|
||||
{
|
||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('income')));
|
||||
|
||||
$expense_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('expense')));
|
||||
|
||||
$request = $this->getTransferRequest($income_transaction, $expense_transaction);
|
||||
$request = $this->getRequest();
|
||||
|
||||
$transfer = Transfer::create($request);
|
||||
|
||||
@ -73,11 +60,7 @@ class TransfersTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldDeleteTransfer()
|
||||
{
|
||||
$income_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('income')));
|
||||
|
||||
$expense_transaction = $this->dispatch(new CreateTransaction($this->getTransactionRequest('expense')));
|
||||
|
||||
$transfer = Transfer::create($this->getTransferRequest($income_transaction, $expense_transaction));
|
||||
$transfer = Transfer::create($this->getRequest());
|
||||
|
||||
$this->loginAs()
|
||||
->delete(route('transfers.destroy', ['transfer' => $transfer->id]))
|
||||
@ -86,41 +69,23 @@ class TransfersTest extends FeatureTestCase
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
private function getTransferRequest($income_transaction, $expense_transaction)
|
||||
private function getRequest()
|
||||
{
|
||||
$income_transaction = factory(Transaction::class)->create();
|
||||
|
||||
$expense_transaction = factory(Transaction::class)->state('expense')->create();
|
||||
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'income_transaction_id' => $income_transaction->id,
|
||||
'expense_transaction_id' => $expense_transaction->id,
|
||||
'from_account_id' => '1',
|
||||
'to_account_id' => '2',
|
||||
'from_account_id' => $income_transaction->account_id,
|
||||
'to_account_id' => $expense_transaction->account_id,
|
||||
'amount' => '5',
|
||||
'transferred_at' => $this->faker->date(),
|
||||
'description'=> $this->faker->text(5),
|
||||
'payment_method' => 'offlinepayment.cash.1',
|
||||
'reference' => null,
|
||||
'currency_code' => setting('default.currency'),
|
||||
'currency_rate' => '1'
|
||||
];
|
||||
}
|
||||
|
||||
private function getTransactionRequest($type)
|
||||
{
|
||||
$attachment = UploadedFile::fake()->create('image.jpg');
|
||||
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'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($type)->first()->id,
|
||||
'reference' => $this->faker->text(5),
|
||||
'payment_method' => setting('default.payment_method'),
|
||||
'attachment' => $attachment,
|
||||
'reference' => null,
|
||||
];
|
||||
}
|
||||
}
|
@ -26,8 +26,8 @@ abstract class FeatureTestCase extends TestCase
|
||||
$this->company = $this->user->companies()->first();
|
||||
|
||||
// Set Company settings
|
||||
setting()->forgetAll();
|
||||
setting()->setExtraColumns(['company_id' => $this->company->id]);
|
||||
setting()->forgetAll();
|
||||
setting()->load(true);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user