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