mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
Improve test coverage and quality
This commit is contained in:
@@ -67,7 +67,7 @@ class AccountControllerTest extends TestCase
|
|||||||
|
|
||||||
// data to submit
|
// data to submit
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
'name' => 'Some new asset account #' . $this->randomInt(),
|
||||||
'type' => 'asset',
|
'type' => 'asset',
|
||||||
'account_role' => 'defaultAsset',
|
'account_role' => 'defaultAsset',
|
||||||
'opening_balance' => '123.45',
|
'opening_balance' => '123.45',
|
||||||
@@ -146,7 +146,7 @@ class AccountControllerTest extends TestCase
|
|||||||
|
|
||||||
// data to submit
|
// data to submit
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'Some new liability account #' . random_int(1, 10000),
|
'name' => 'Some new liability account #' . $this->randomInt(),
|
||||||
'type' => 'liability',
|
'type' => 'liability',
|
||||||
'liability_amount' => '10000',
|
'liability_amount' => '10000',
|
||||||
'liability_start_date' => '2016-01-01',
|
'liability_start_date' => '2016-01-01',
|
||||||
@@ -185,7 +185,7 @@ class AccountControllerTest extends TestCase
|
|||||||
|
|
||||||
// data to submit
|
// data to submit
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
'name' => 'Some new asset account #' . $this->randomInt(),
|
||||||
'type' => 'asset',
|
'type' => 'asset',
|
||||||
'account_role' => 'ccAsset',
|
'account_role' => 'ccAsset',
|
||||||
];
|
];
|
||||||
@@ -233,7 +233,7 @@ class AccountControllerTest extends TestCase
|
|||||||
|
|
||||||
// data to submit
|
// data to submit
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
'name' => 'Some new asset account #' . $this->randomInt(),
|
||||||
'type' => 'asset',
|
'type' => 'asset',
|
||||||
'account_role' => 'defaultAsset',
|
'account_role' => 'defaultAsset',
|
||||||
'include_net_worth' => false,
|
'include_net_worth' => false,
|
||||||
@@ -314,7 +314,7 @@ class AccountControllerTest extends TestCase
|
|||||||
|
|
||||||
// data to submit
|
// data to submit
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
'name' => 'Some new asset account #' . $this->randomInt(),
|
||||||
'type' => 'asset',
|
'type' => 'asset',
|
||||||
'account_role' => 'defaultAsset',
|
'account_role' => 'defaultAsset',
|
||||||
];
|
];
|
||||||
@@ -355,7 +355,7 @@ class AccountControllerTest extends TestCase
|
|||||||
|
|
||||||
// data to submit
|
// data to submit
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'Some new asset account #' . random_int(1, 10000),
|
'name' => 'Some new asset account #' . $this->randomInt(),
|
||||||
'currency_code' => 'EUR',
|
'currency_code' => 'EUR',
|
||||||
'type' => 'asset',
|
'type' => 'asset',
|
||||||
'account_role' => 'defaultAsset',
|
'account_role' => 'defaultAsset',
|
||||||
|
@@ -115,7 +115,7 @@ class AttachmentControllerTest extends TestCase
|
|||||||
// data to submit
|
// data to submit
|
||||||
$data = [
|
$data = [
|
||||||
'filename' => 'Some new att',
|
'filename' => 'Some new att',
|
||||||
'description' => sprintf('Attempt #%d', random_int(1, 10000)),
|
'description' => sprintf('Attempt #%d', $this->randomInt()),
|
||||||
'model' => 'TransactionJournal',
|
'model' => 'TransactionJournal',
|
||||||
'model_id' => $journal->id,
|
'model_id' => $journal->id,
|
||||||
];
|
];
|
||||||
@@ -159,7 +159,7 @@ class AttachmentControllerTest extends TestCase
|
|||||||
// data to submit
|
// data to submit
|
||||||
$data = [
|
$data = [
|
||||||
'filename' => $attachment->filename,
|
'filename' => $attachment->filename,
|
||||||
'description' => sprintf('Attempt #%d', random_int(1, 10000)),
|
'description' => sprintf('Attempt #%d', $this->randomInt()),
|
||||||
'model' => 'TransactionJournal',
|
'model' => 'TransactionJournal',
|
||||||
'model_id' => 1,
|
'model_id' => 1,
|
||||||
];
|
];
|
||||||
|
@@ -68,8 +68,8 @@ class BillControllerTest extends TestCase
|
|||||||
|
|
||||||
// data to submit:
|
// data to submit:
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'New bill #' . random_int(1, 10000),
|
'name' => 'New bill #' . $this->randomInt(),
|
||||||
'match' => 'some,words,' . random_int(1, 10000),
|
'match' => 'some,words,' . $this->randomInt(),
|
||||||
'amount_min' => '66.34',
|
'amount_min' => '66.34',
|
||||||
'amount_max' => '45.67',
|
'amount_max' => '45.67',
|
||||||
'date' => '2018-01-01',
|
'date' => '2018-01-01',
|
||||||
@@ -121,8 +121,8 @@ class BillControllerTest extends TestCase
|
|||||||
|
|
||||||
// data to submit:
|
// data to submit:
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'New bill #' . random_int(1, 10000),
|
'name' => 'New bill #' . $this->randomInt(),
|
||||||
'match' => 'some,words,' . random_int(1, 10000),
|
'match' => 'some,words,' . $this->randomInt(),
|
||||||
'amount_min' => '12.34',
|
'amount_min' => '12.34',
|
||||||
'amount_max' => '45.67',
|
'amount_max' => '45.67',
|
||||||
'date' => '2018-01-01',
|
'date' => '2018-01-01',
|
||||||
@@ -160,8 +160,8 @@ class BillControllerTest extends TestCase
|
|||||||
$repository->shouldReceive('update')->andReturn($bill);
|
$repository->shouldReceive('update')->andReturn($bill);
|
||||||
// data to submit:
|
// data to submit:
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'New bill #' . random_int(1, 10000),
|
'name' => 'New bill #' . $this->randomInt(),
|
||||||
'match' => 'some,words,' . random_int(1, 10000),
|
'match' => 'some,words,' . $this->randomInt(),
|
||||||
'amount_min' => '12.34',
|
'amount_min' => '12.34',
|
||||||
'amount_max' => '45.67',
|
'amount_max' => '45.67',
|
||||||
'date' => '2018-01-01',
|
'date' => '2018-01-01',
|
||||||
|
@@ -80,9 +80,9 @@ class LinkTypeControllerTest extends TestCase
|
|||||||
|
|
||||||
// data to submit
|
// data to submit
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'random' . random_int(1, 100000),
|
'name' => 'random' . $this->randomInt(),
|
||||||
'outward' => 'outward' . random_int(1, 100000),
|
'outward' => 'outward' . $this->randomInt(),
|
||||||
'inward' => 'inward ' . random_int(1, 100000),
|
'inward' => 'inward ' . $this->randomInt(),
|
||||||
'editable' => true,
|
'editable' => true,
|
||||||
|
|
||||||
];
|
];
|
||||||
@@ -110,9 +110,9 @@ class LinkTypeControllerTest extends TestCase
|
|||||||
|
|
||||||
// data to submit
|
// data to submit
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'random' . random_int(1, 100000),
|
'name' => 'random' . $this->randomInt(),
|
||||||
'outward' => 'outward' . random_int(1, 100000),
|
'outward' => 'outward' . $this->randomInt(),
|
||||||
'inward' => 'inward ' . random_int(1, 100000),
|
'inward' => 'inward ' . $this->randomInt(),
|
||||||
'editable' => true,
|
'editable' => true,
|
||||||
|
|
||||||
];
|
];
|
||||||
@@ -146,9 +146,9 @@ class LinkTypeControllerTest extends TestCase
|
|||||||
// create editable link type:
|
// create editable link type:
|
||||||
$linkType = LinkType::create(
|
$linkType = LinkType::create(
|
||||||
[
|
[
|
||||||
'name' => 'random' . random_int(1, 100000),
|
'name' => 'random' . $this->randomInt(),
|
||||||
'outward' => 'outward' . random_int(1, 100000),
|
'outward' => 'outward' . $this->randomInt(),
|
||||||
'inward' => 'inward ' . random_int(1, 100000),
|
'inward' => 'inward ' . $this->randomInt(),
|
||||||
'editable' => true,
|
'editable' => true,
|
||||||
|
|
||||||
]
|
]
|
||||||
@@ -160,9 +160,9 @@ class LinkTypeControllerTest extends TestCase
|
|||||||
|
|
||||||
// data to submit
|
// data to submit
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'random' . random_int(1, 100000),
|
'name' => 'random' . $this->randomInt(),
|
||||||
'outward' => 'outward' . random_int(1, 100000),
|
'outward' => 'outward' . $this->randomInt(),
|
||||||
'inward' => 'inward ' . random_int(1, 100000),
|
'inward' => 'inward ' . $this->randomInt(),
|
||||||
'editable' => true,
|
'editable' => true,
|
||||||
|
|
||||||
];
|
];
|
||||||
@@ -186,9 +186,9 @@ class LinkTypeControllerTest extends TestCase
|
|||||||
// create editable link type:
|
// create editable link type:
|
||||||
$linkType = LinkType::create(
|
$linkType = LinkType::create(
|
||||||
[
|
[
|
||||||
'name' => 'random' . random_int(1, 100000),
|
'name' => 'random' . $this->randomInt(),
|
||||||
'outward' => 'outward' . random_int(1, 100000),
|
'outward' => 'outward' . $this->randomInt(),
|
||||||
'inward' => 'inward ' . random_int(1, 100000),
|
'inward' => 'inward ' . $this->randomInt(),
|
||||||
'editable' => false,
|
'editable' => false,
|
||||||
|
|
||||||
]
|
]
|
||||||
@@ -199,9 +199,9 @@ class LinkTypeControllerTest extends TestCase
|
|||||||
|
|
||||||
// data to submit
|
// data to submit
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'random' . random_int(1, 100000),
|
'name' => 'random' . $this->randomInt(),
|
||||||
'outward' => 'outward' . random_int(1, 100000),
|
'outward' => 'outward' . $this->randomInt(),
|
||||||
'inward' => 'inward ' . random_int(1, 100000),
|
'inward' => 'inward ' . $this->randomInt(),
|
||||||
'editable' => true,
|
'editable' => true,
|
||||||
|
|
||||||
];
|
];
|
||||||
@@ -227,9 +227,9 @@ class LinkTypeControllerTest extends TestCase
|
|||||||
// create editable link type:
|
// create editable link type:
|
||||||
$linkType = LinkType::create(
|
$linkType = LinkType::create(
|
||||||
[
|
[
|
||||||
'name' => 'random' . random_int(1, 100000),
|
'name' => 'random' . $this->randomInt(),
|
||||||
'outward' => 'outward' . random_int(1, 100000),
|
'outward' => 'outward' . $this->randomInt(),
|
||||||
'inward' => 'inward ' . random_int(1, 100000),
|
'inward' => 'inward ' . $this->randomInt(),
|
||||||
'editable' => true,
|
'editable' => true,
|
||||||
|
|
||||||
]
|
]
|
||||||
@@ -240,9 +240,9 @@ class LinkTypeControllerTest extends TestCase
|
|||||||
|
|
||||||
// data to submit
|
// data to submit
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'random' . random_int(1, 100000),
|
'name' => 'random' . $this->randomInt(),
|
||||||
'outward' => 'outward' . random_int(1, 100000),
|
'outward' => 'outward' . $this->randomInt(),
|
||||||
'inward' => 'inward ' . random_int(1, 100000),
|
'inward' => 'inward ' . $this->randomInt(),
|
||||||
'editable' => true,
|
'editable' => true,
|
||||||
|
|
||||||
];
|
];
|
||||||
|
@@ -78,7 +78,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$repository->shouldReceive('store')->once()->andReturn($piggy);
|
$repository->shouldReceive('store')->once()->andReturn($piggy);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'New piggy #' . random_int(1, 100000),
|
'name' => 'New piggy #' . $this->randomInt(),
|
||||||
'account_id' => 1,
|
'account_id' => 1,
|
||||||
'target_amount' => '100',
|
'target_amount' => '100',
|
||||||
];
|
];
|
||||||
@@ -106,7 +106,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'New piggy #' . random_int(1, 100000),
|
'name' => 'New piggy #' . $this->randomInt(),
|
||||||
'account_id' => 1,
|
'account_id' => 1,
|
||||||
'target_amount' => '100',
|
'target_amount' => '100',
|
||||||
];
|
];
|
||||||
@@ -157,7 +157,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::first());
|
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::first());
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'new pigy bank ' . random_int(1, 10000),
|
'name' => 'new pigy bank ' . $this->randomInt(),
|
||||||
'account_id' => 1,
|
'account_id' => 1,
|
||||||
'target_amount' => '100',
|
'target_amount' => '100',
|
||||||
];
|
];
|
||||||
|
@@ -80,7 +80,7 @@ class RuleGroupControllerTest extends TestCase
|
|||||||
$ruleGroupRepos->shouldReceive('setUser')->once();
|
$ruleGroupRepos->shouldReceive('setUser')->once();
|
||||||
$ruleGroup = $this->user()->ruleGroups()->first();
|
$ruleGroup = $this->user()->ruleGroups()->first();
|
||||||
$data = [
|
$data = [
|
||||||
'title' => 'Store new rule group ' . random_int(1, 100000),
|
'title' => 'Store new rule group ' . $this->randomInt(),
|
||||||
'active' => 1,
|
'active' => 1,
|
||||||
'description' => 'Hello',
|
'description' => 'Hello',
|
||||||
];
|
];
|
||||||
@@ -214,7 +214,7 @@ class RuleGroupControllerTest extends TestCase
|
|||||||
$ruleGroupRepos->shouldReceive('setUser')->once();
|
$ruleGroupRepos->shouldReceive('setUser')->once();
|
||||||
$ruleGroup = $this->user()->ruleGroups()->first();
|
$ruleGroup = $this->user()->ruleGroups()->first();
|
||||||
$data = [
|
$data = [
|
||||||
'title' => 'Store new rule ' . random_int(1, 100000),
|
'title' => 'Store new rule ' . $this->randomInt(),
|
||||||
'active' => 1,
|
'active' => 1,
|
||||||
'description' => 'Hello',
|
'description' => 'Hello',
|
||||||
];
|
];
|
||||||
|
@@ -57,7 +57,7 @@ class TagControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||||
$tag = $this->user()->tags()->inRandomOrder()->first();
|
$tag = $this->user()->tags()->inRandomOrder()->first();
|
||||||
$data = ['tag' => 'Some tag' . random_int(1, 10000),];
|
$data = ['tag' => 'Some tag' . $this->randomInt(),];
|
||||||
$transformer = $this->mock(TagTransformer::class);
|
$transformer = $this->mock(TagTransformer::class);
|
||||||
|
|
||||||
// mock transformer
|
// mock transformer
|
||||||
@@ -126,7 +126,7 @@ class TagControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||||
$tag = $this->user()->tags()->inRandomOrder()->first();
|
$tag = $this->user()->tags()->inRandomOrder()->first();
|
||||||
$data = ['tag' => 'Some tag' . random_int(1, 10000),];
|
$data = ['tag' => 'Some tag' . $this->randomInt(),];
|
||||||
$transformer = $this->mock(TagTransformer::class);
|
$transformer = $this->mock(TagTransformer::class);
|
||||||
|
|
||||||
// mock transformer
|
// mock transformer
|
||||||
|
@@ -61,7 +61,7 @@ class UserControllerTest extends TestCase
|
|||||||
public function testStoreBasic(): void
|
public function testStoreBasic(): void
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'email' => 'some_new@user' . random_int(1, 10000) . '.com',
|
'email' => 'some_new@user' . $this->randomInt() . '.com',
|
||||||
];
|
];
|
||||||
|
|
||||||
// mock
|
// mock
|
||||||
@@ -91,7 +91,7 @@ class UserControllerTest extends TestCase
|
|||||||
public function testStoreBasicJson(): void
|
public function testStoreBasicJson(): void
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'email' => 'some_new@user' . random_int(1, 10000) . '.com',
|
'email' => 'some_new@user' . $this->randomInt() . '.com',
|
||||||
'blocked' => true,
|
'blocked' => true,
|
||||||
'blocked_code' => 'email_changed',
|
'blocked_code' => 'email_changed',
|
||||||
];
|
];
|
||||||
@@ -185,11 +185,11 @@ class UserControllerTest extends TestCase
|
|||||||
public function testUpdate(): void
|
public function testUpdate(): void
|
||||||
{
|
{
|
||||||
// create a user first:
|
// create a user first:
|
||||||
$user = User::create(['email' => 'some@newu' . random_int(1, 10000) . 'ser.nl', 'password' => 'hello', 'blocked' => 0]);
|
$user = User::create(['email' => 'some@newu' . $this->randomInt() . 'ser.nl', 'password' => 'hello', 'blocked' => 0]);
|
||||||
|
|
||||||
// data:
|
// data:
|
||||||
$data = [
|
$data = [
|
||||||
'email' => 'some-new@email' . random_int(1, 10000) . '.com',
|
'email' => 'some-new@email' . $this->randomInt() . '.com',
|
||||||
'blocked' => 0,
|
'blocked' => 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -220,11 +220,11 @@ class UserControllerTest extends TestCase
|
|||||||
public function testUpdateJson(): void
|
public function testUpdateJson(): void
|
||||||
{
|
{
|
||||||
// create a user first:
|
// create a user first:
|
||||||
$user = User::create(['email' => 'some@newu' . random_int(1, 10000) . 'ser.nl', 'password' => 'hello', 'blocked' => 0]);
|
$user = User::create(['email' => 'some@newu' . $this->randomInt() . 'ser.nl', 'password' => 'hello', 'blocked' => 0]);
|
||||||
|
|
||||||
// data:
|
// data:
|
||||||
$data = [
|
$data = [
|
||||||
'email' => 'some-new@email' . random_int(1, 10000) . '.com',
|
'email' => 'some-new@email' . $this->randomInt() . '.com',
|
||||||
'blocked' => 0,
|
'blocked' => 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -101,7 +101,7 @@ class CreateControllerTest extends TestCase
|
|||||||
$this->session(['accounts.create.uri' => 'http://localhost']);
|
$this->session(['accounts.create.uri' => 'http://localhost']);
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'new account ' . random_int(1000, 9999),
|
'name' => 'new account ' . $this->randomInt(),
|
||||||
'what' => 'asset',
|
'what' => 'asset',
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ class CreateControllerTest extends TestCase
|
|||||||
$this->session(['accounts.create.uri' => 'http://localhost']);
|
$this->session(['accounts.create.uri' => 'http://localhost']);
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'new account ' . random_int(1000, 9999),
|
'name' => 'new account ' . $this->randomInt(),
|
||||||
'what' => 'asset',
|
'what' => 'asset',
|
||||||
'create_another' => 1,
|
'create_another' => 1,
|
||||||
];
|
];
|
||||||
@@ -157,7 +157,7 @@ class CreateControllerTest extends TestCase
|
|||||||
$this->session(['accounts.create.uri' => 'http://localhost']);
|
$this->session(['accounts.create.uri' => 'http://localhost']);
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'new liability account ' . random_int(1000, 9999),
|
'name' => 'new liability account ' . $this->randomInt(),
|
||||||
'what' => 'liabilities',
|
'what' => 'liabilities',
|
||||||
'liability_type_id' => AccountType::where('type', AccountType::LOAN)->first()->id,
|
'liability_type_id' => AccountType::where('type', AccountType::LOAN)->first()->id,
|
||||||
'openingBalance' => '100',
|
'openingBalance' => '100',
|
||||||
|
@@ -205,7 +205,7 @@ class EditControllerTest extends TestCase
|
|||||||
$this->session(['accounts.edit.uri' => 'http://localhost/javascript/account']);
|
$this->session(['accounts.edit.uri' => 'http://localhost/javascript/account']);
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'updated account ' . random_int(1000, 9999),
|
'name' => 'updated account ' . $this->randomInt(),
|
||||||
'active' => 1,
|
'active' => 1,
|
||||||
'what' => 'asset',
|
'what' => 'asset',
|
||||||
];
|
];
|
||||||
@@ -232,7 +232,7 @@ class EditControllerTest extends TestCase
|
|||||||
$this->session(['accounts.edit.uri' => 'http://localhost']);
|
$this->session(['accounts.edit.uri' => 'http://localhost']);
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'updated account ' . random_int(1000, 9999),
|
'name' => 'updated account ' . $this->randomInt(),
|
||||||
'active' => 1,
|
'active' => 1,
|
||||||
'what' => 'asset',
|
'what' => 'asset',
|
||||||
'return_to_edit' => '1',
|
'return_to_edit' => '1',
|
||||||
|
@@ -190,7 +190,7 @@ class AttachmentControllerTest extends TestCase
|
|||||||
|
|
||||||
$this->session(['attachments.edit.uri' => 'http://localhost']);
|
$this->session(['attachments.edit.uri' => 'http://localhost']);
|
||||||
$data = [
|
$data = [
|
||||||
'title' => 'Some updated title ' . random_int(1000, 9999),
|
'title' => 'Some updated title ' . $this->randomInt(),
|
||||||
'notes' => 'A',
|
'notes' => 'A',
|
||||||
'description' => 'B',
|
'description' => 'B',
|
||||||
];
|
];
|
||||||
|
@@ -326,7 +326,7 @@ class BillControllerTest extends TestCase
|
|||||||
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'New Bill ' . random_int(1000, 9999),
|
'name' => 'New Bill ' . $this->randomInt(),
|
||||||
'amount_min' => '100',
|
'amount_min' => '100',
|
||||||
'transaction_currency_id' => 1,
|
'transaction_currency_id' => 1,
|
||||||
'skip' => 0,
|
'skip' => 0,
|
||||||
@@ -364,7 +364,7 @@ class BillControllerTest extends TestCase
|
|||||||
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'New Bill ' . random_int(1000, 9999),
|
'name' => 'New Bill ' . $this->randomInt(),
|
||||||
'amount_min' => '100',
|
'amount_min' => '100',
|
||||||
'transaction_currency_id' => 1,
|
'transaction_currency_id' => 1,
|
||||||
'skip' => 0,
|
'skip' => 0,
|
||||||
@@ -400,7 +400,7 @@ class BillControllerTest extends TestCase
|
|||||||
$repository->shouldReceive('store')->andReturn(null);
|
$repository->shouldReceive('store')->andReturn(null);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'New Bill ' . random_int(1000, 9999),
|
'name' => 'New Bill ' . $this->randomInt(),
|
||||||
'amount_min' => '100',
|
'amount_min' => '100',
|
||||||
'transaction_currency_id' => 1,
|
'transaction_currency_id' => 1,
|
||||||
'skip' => 0,
|
'skip' => 0,
|
||||||
@@ -437,7 +437,7 @@ class BillControllerTest extends TestCase
|
|||||||
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'New Bill ' . random_int(1000, 9999),
|
'name' => 'New Bill ' . $this->randomInt(),
|
||||||
'amount_min' => '100',
|
'amount_min' => '100',
|
||||||
'transaction_currency_id' => 1,
|
'transaction_currency_id' => 1,
|
||||||
'skip' => 0,
|
'skip' => 0,
|
||||||
@@ -476,7 +476,7 @@ class BillControllerTest extends TestCase
|
|||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'id' => 1,
|
'id' => 1,
|
||||||
'name' => 'Updated Bill ' . random_int(1000, 9999),
|
'name' => 'Updated Bill ' . $this->randomInt(),
|
||||||
'amount_min' => '100',
|
'amount_min' => '100',
|
||||||
'transaction_currency_id' => 1,
|
'transaction_currency_id' => 1,
|
||||||
'skip' => 0,
|
'skip' => 0,
|
||||||
|
@@ -91,7 +91,7 @@ class CreateControllerTest extends TestCase
|
|||||||
$this->session(['budgets.create.uri' => 'http://localhost']);
|
$this->session(['budgets.create.uri' => 'http://localhost']);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'New Budget ' . random_int(1000, 9999),
|
'name' => 'New Budget ' . $this->randomInt(),
|
||||||
];
|
];
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->post(route('budgets.store'), $data);
|
$response = $this->post(route('budgets.store'), $data);
|
||||||
|
@@ -90,7 +90,7 @@ class EditControllerTest extends TestCase
|
|||||||
$this->session(['budgets.edit.uri' => 'http://localhost']);
|
$this->session(['budgets.edit.uri' => 'http://localhost']);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'Updated Budget ' . random_int(1000, 9999),
|
'name' => 'Updated Budget ' . $this->randomInt(),
|
||||||
'active' => 1,
|
'active' => 1,
|
||||||
];
|
];
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
@@ -184,7 +184,7 @@ class CategoryControllerTest extends TestCase
|
|||||||
$this->session(['categories.create.uri' => 'http://localhost']);
|
$this->session(['categories.create.uri' => 'http://localhost']);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'New Category ' . random_int(1000, 9999),
|
'name' => 'New Category ' . $this->randomInt(),
|
||||||
];
|
];
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->post(route('categories.store'), $data);
|
$response = $this->post(route('categories.store'), $data);
|
||||||
@@ -212,7 +212,7 @@ class CategoryControllerTest extends TestCase
|
|||||||
$this->session(['categories.edit.uri' => 'http://localhost']);
|
$this->session(['categories.edit.uri' => 'http://localhost']);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'Updated Category ' . random_int(1000, 9999),
|
'name' => 'Updated Category ' . $this->randomInt(),
|
||||||
'active' => 1,
|
'active' => 1,
|
||||||
];
|
];
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
@@ -51,6 +51,21 @@ use RuntimeException;
|
|||||||
*/
|
*/
|
||||||
abstract class TestCase extends BaseTestCase
|
abstract class TestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function randomInt(): int
|
||||||
|
{
|
||||||
|
$result = 4;
|
||||||
|
try {
|
||||||
|
$result = random_int(1, 100000);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Log::debug(sprintf('Could not generate random number: %s', $e->getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param string $range
|
* @param string $range
|
||||||
|
@@ -129,7 +129,7 @@ class CreateCSVImportTest extends TestCase
|
|||||||
|
|
||||||
$importJob = ImportJob::create(
|
$importJob = ImportJob::create(
|
||||||
[
|
[
|
||||||
'key' => 'key-' . random_int(1, 100000),
|
'key' => 'key-' . $this->randomInt(),
|
||||||
'user_id' => 1,
|
'user_id' => 1,
|
||||||
'file_type' => 'csv',
|
'file_type' => 'csv',
|
||||||
'status' => 'new',
|
'status' => 'new',
|
||||||
@@ -203,7 +203,7 @@ class CreateCSVImportTest extends TestCase
|
|||||||
|
|
||||||
$importJob = ImportJob::create(
|
$importJob = ImportJob::create(
|
||||||
[
|
[
|
||||||
'key' => 'key-' . random_int(1, 100000),
|
'key' => 'key-' . $this->randomInt(),
|
||||||
'user_id' => 1,
|
'user_id' => 1,
|
||||||
'file_type' => 'csv',
|
'file_type' => 'csv',
|
||||||
'status' => 'new',
|
'status' => 'new',
|
||||||
|
@@ -151,9 +151,11 @@ class MigrateToRulesTest extends TestCase
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
'actions' => [
|
'actions' => [
|
||||||
|
[
|
||||||
'type' => 'link_to_bill',
|
'type' => 'link_to_bill',
|
||||||
'value' => $bill->name,
|
'value' => $bill->name,
|
||||||
],
|
],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
// this is what the bill repos should receive:
|
// this is what the bill repos should receive:
|
||||||
@@ -260,9 +262,11 @@ class MigrateToRulesTest extends TestCase
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
'actions' => [
|
'actions' => [
|
||||||
|
[
|
||||||
'type' => 'link_to_bill',
|
'type' => 'link_to_bill',
|
||||||
'value' => $bill->name,
|
'value' => $bill->name,
|
||||||
],
|
],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
// this is what the bill repos should receive:
|
// this is what the bill repos should receive:
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -25,6 +25,7 @@ namespace Tests\Unit\Factory;
|
|||||||
|
|
||||||
|
|
||||||
use FireflyIII\Factory\AccountMetaFactory;
|
use FireflyIII\Factory\AccountMetaFactory;
|
||||||
|
use FireflyIII\Models\AccountMeta;
|
||||||
use Log;
|
use Log;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
@@ -34,8 +35,6 @@ use Tests\TestCase;
|
|||||||
*/
|
*/
|
||||||
class AccountMetaFactoryTest extends TestCase
|
class AccountMetaFactoryTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -50,16 +49,17 @@ class AccountMetaFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCreate(): void
|
public function testCreate(): void
|
||||||
{
|
{
|
||||||
$account = $this->user()->accounts()->inRandomOrder()->first();
|
$account = $this->getRandomAsset();
|
||||||
$data = [
|
$data = [
|
||||||
'account_id' => $account->id,
|
'account_id' => $account->id,
|
||||||
'name' => 'Some name',
|
'name' => 'Some name',
|
||||||
'data' => 'Some value',
|
'data' => 'Some value',
|
||||||
];
|
];
|
||||||
|
|
||||||
$factory = new AccountMetaFactory;
|
$factory = app(AccountMetaFactory::class);
|
||||||
$result = $factory->create($data);
|
$result = $factory->create($data);
|
||||||
$this->assertEquals($data['name'], $result->name);
|
$this->assertEquals($data['name'], $result->name);
|
||||||
|
$result->forceDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,19 +67,20 @@ class AccountMetaFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCrudDelete(): void
|
public function testCrudDelete(): void
|
||||||
{
|
{
|
||||||
$factory = new AccountMetaFactory;
|
$factory = app(AccountMetaFactory::class);
|
||||||
$account = $this->user()->accounts()->inRandomOrder()->first();
|
$account = $this->getRandomAsset();
|
||||||
$data = [
|
$data = [
|
||||||
'account_id' => $account->id,
|
'account_id' => $account->id,
|
||||||
'name' => 'Some name ' . random_int(1, 100000),
|
'name' => sprintf('Some name %d', $this->randomInt()),
|
||||||
'data' => 'Some value',
|
'data' => 'Some value',
|
||||||
];
|
];
|
||||||
|
|
||||||
$factory->create($data);
|
$new = $factory->create($data);
|
||||||
|
|
||||||
// update existing one
|
// update existing one
|
||||||
$result = $factory->crud($account, $data['name'], '');
|
$result = $factory->crud($account, $data['name'], '');
|
||||||
$this->assertNull($result);
|
$this->assertNull($result);
|
||||||
|
$this->assertCount(0, AccountMeta::where('id', $new->id)->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,11 +88,11 @@ class AccountMetaFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCrudExisting(): void
|
public function testCrudExisting(): void
|
||||||
{
|
{
|
||||||
$factory = new AccountMetaFactory;
|
$factory = app(AccountMetaFactory::class);
|
||||||
$account = $this->user()->accounts()->inRandomOrder()->first();
|
$account = $this->getRandomAsset();
|
||||||
$data = [
|
$data = [
|
||||||
'account_id' => $account->id,
|
'account_id' => $account->id,
|
||||||
'name' => 'Some name ' . random_int(1, 100000),
|
'name' => sprintf('Some name %d', $this->randomInt()),
|
||||||
'data' => 'Some value',
|
'data' => 'Some value',
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -103,7 +104,6 @@ class AccountMetaFactoryTest extends TestCase
|
|||||||
$this->assertEquals($result->account_id, $account->id);
|
$this->assertEquals($result->account_id, $account->id);
|
||||||
$this->assertEquals($existing->name, $result->name);
|
$this->assertEquals($existing->name, $result->name);
|
||||||
$this->assertEquals('Some NEW value', $result->data);
|
$this->assertEquals('Some NEW value', $result->data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,9 +111,9 @@ class AccountMetaFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCrudNew(): void
|
public function testCrudNew(): void
|
||||||
{
|
{
|
||||||
$account = $this->user()->accounts()->inRandomOrder()->first();
|
$factory = app(AccountMetaFactory::class);
|
||||||
$factory = new AccountMetaFactory;
|
$account = $this->getRandomAsset();
|
||||||
$result = $factory->crud($account, 'random name ' . random_int(1, 100000), 'Some value');
|
$result = $factory->crud($account, 'random name ' . $this->randomInt(), 'Some value');
|
||||||
$this->assertNotNull($result);
|
$this->assertNotNull($result);
|
||||||
$this->assertEquals($result->account_id, $account->id);
|
$this->assertEquals($result->account_id, $account->id);
|
||||||
|
|
||||||
|
@@ -24,7 +24,9 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Unit\Factory;
|
namespace Tests\Unit\Factory;
|
||||||
|
|
||||||
|
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Factory\AttachmentFactory;
|
use FireflyIII\Factory\AttachmentFactory;
|
||||||
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use Log;
|
use Log;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
@@ -51,7 +53,7 @@ class AttachmentFactoryTest extends TestCase
|
|||||||
public function testCreate(): void
|
public function testCreate(): void
|
||||||
{
|
{
|
||||||
|
|
||||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
|
$journal = $this->getRandomWithdrawal();
|
||||||
$data = [
|
$data = [
|
||||||
'model_id' => $journal->id,
|
'model_id' => $journal->id,
|
||||||
'model' => TransactionJournal::class,
|
'model' => TransactionJournal::class,
|
||||||
@@ -60,12 +62,80 @@ class AttachmentFactoryTest extends TestCase
|
|||||||
'notes' => 'Some notes',
|
'notes' => 'Some notes',
|
||||||
];
|
];
|
||||||
|
|
||||||
$factory = new AttachmentFactory;
|
/** @var AttachmentFactory $factory */
|
||||||
|
$factory = app(AttachmentFactory::class);
|
||||||
$factory->setUser($this->user());
|
$factory->setUser($this->user());
|
||||||
|
try {
|
||||||
$result = $factory->create($data);
|
$result = $factory->create($data);
|
||||||
|
} catch (FireflyException $e) {
|
||||||
|
$this->assertTrue(false, $e->getMessage());
|
||||||
|
}
|
||||||
$this->assertEquals($data['title'], $result->title);
|
$this->assertEquals($data['title'], $result->title);
|
||||||
$this->assertEquals(1, $result->notes()->count());
|
$this->assertEquals(1, $result->notes()->count());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \FireflyIII\Factory\AttachmentFactory
|
||||||
|
*/
|
||||||
|
public function testCreateTransaction(): void
|
||||||
|
{
|
||||||
|
|
||||||
|
$journal = $this->getRandomWithdrawal();
|
||||||
|
$transaction = $journal->transactions()->first();
|
||||||
|
$data = [
|
||||||
|
'model_id' => $transaction->id,
|
||||||
|
'model' => Transaction::class,
|
||||||
|
'filename' => 'testfile.pdf',
|
||||||
|
'title' => 'File name',
|
||||||
|
'notes' => 'Some notes',
|
||||||
|
];
|
||||||
|
|
||||||
|
/** @var AttachmentFactory $factory */
|
||||||
|
$factory = app(AttachmentFactory::class);
|
||||||
|
$factory->setUser($this->user());
|
||||||
|
try {
|
||||||
|
$result = $factory->create($data);
|
||||||
|
} catch (FireflyException $e) {
|
||||||
|
$this->assertTrue(false, $e->getMessage());
|
||||||
|
}
|
||||||
|
$this->assertEquals($data['title'], $result->title);
|
||||||
|
$this->assertEquals($result->attachable_id, $journal->id);
|
||||||
|
$this->assertEquals(1, $result->notes()->count());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \FireflyIII\Factory\AttachmentFactory
|
||||||
|
*/
|
||||||
|
public function testCreateTransactionAppendModel(): void
|
||||||
|
{
|
||||||
|
|
||||||
|
$journal = $this->getRandomWithdrawal();
|
||||||
|
$transaction = $journal->transactions()->first();
|
||||||
|
$data = [
|
||||||
|
'model_id' => $transaction->id,
|
||||||
|
'model' => 'Transaction',
|
||||||
|
'filename' => 'testfile.pdf',
|
||||||
|
'title' => 'File name',
|
||||||
|
'notes' => 'Some notes',
|
||||||
|
];
|
||||||
|
|
||||||
|
/** @var AttachmentFactory $factory */
|
||||||
|
$factory = app(AttachmentFactory::class);
|
||||||
|
$factory->setUser($this->user());
|
||||||
|
try {
|
||||||
|
$result = $factory->create($data);
|
||||||
|
} catch (FireflyException $e) {
|
||||||
|
$this->assertTrue(false, $e->getMessage());
|
||||||
|
}
|
||||||
|
$this->assertEquals($data['title'], $result->title);
|
||||||
|
$this->assertEquals($result->attachable_id, $journal->id);
|
||||||
|
$this->assertEquals(1, $result->notes()->count());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,6 @@ namespace Tests\Unit\Factory;
|
|||||||
use Amount;
|
use Amount;
|
||||||
use FireflyIII\Factory\BillFactory;
|
use FireflyIII\Factory\BillFactory;
|
||||||
use FireflyIII\Factory\TransactionCurrencyFactory;
|
use FireflyIII\Factory\TransactionCurrencyFactory;
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
|
||||||
use Log;
|
use Log;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
@@ -36,8 +35,6 @@ use Tests\TestCase;
|
|||||||
*/
|
*/
|
||||||
class BillFactoryTest extends TestCase
|
class BillFactoryTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -56,8 +53,9 @@ class BillFactoryTest extends TestCase
|
|||||||
public function testCreateBasic(): void
|
public function testCreateBasic(): void
|
||||||
{
|
{
|
||||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||||
|
$euro = $this->getEuro();
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'Some new bill #' . random_int(1, 10000),
|
'name' => sprintf('Some new bill #%d', $this->randomInt()),
|
||||||
'amount_min' => '5',
|
'amount_min' => '5',
|
||||||
'currency_id' => 1,
|
'currency_id' => 1,
|
||||||
'currency_code' => '',
|
'currency_code' => '',
|
||||||
@@ -71,8 +69,7 @@ class BillFactoryTest extends TestCase
|
|||||||
];
|
];
|
||||||
|
|
||||||
$currencyFactory->shouldReceive('find')->atLeast()->once()
|
$currencyFactory->shouldReceive('find')->atLeast()->once()
|
||||||
->withArgs([1, ''])->andReturn(TransactionCurrency::find(1));
|
->withArgs([1, ''])->andReturn($euro);
|
||||||
|
|
||||||
|
|
||||||
/** @var BillFactory $factory */
|
/** @var BillFactory $factory */
|
||||||
$factory = app(BillFactory::class);
|
$factory = app(BillFactory::class);
|
||||||
@@ -97,10 +94,11 @@ class BillFactoryTest extends TestCase
|
|||||||
public function testCreateDifferentCurrency(): void
|
public function testCreateDifferentCurrency(): void
|
||||||
{
|
{
|
||||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||||
|
$dollar = $this->getDollar();
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'Some new bill #' . random_int(1, 10000),
|
'name' => sprintf('Some new bill #%d', $this->randomInt()),
|
||||||
'amount_min' => '5',
|
'amount_min' => '5',
|
||||||
'currency_code' => 'USD',
|
'currency_code' => $dollar->code,
|
||||||
'amount_max' => '10',
|
'amount_max' => '10',
|
||||||
'date' => '2018-01-01',
|
'date' => '2018-01-01',
|
||||||
'repeat_freq' => 'monthly',
|
'repeat_freq' => 'monthly',
|
||||||
@@ -111,8 +109,7 @@ class BillFactoryTest extends TestCase
|
|||||||
];
|
];
|
||||||
|
|
||||||
$currencyFactory->shouldReceive('find')->atLeast()->once()
|
$currencyFactory->shouldReceive('find')->atLeast()->once()
|
||||||
->withArgs([0, 'USD'])->andReturn(TransactionCurrency::find(5));
|
->withArgs([0, $dollar->code])->andReturn($dollar);
|
||||||
|
|
||||||
|
|
||||||
/** @var BillFactory $factory */
|
/** @var BillFactory $factory */
|
||||||
$factory = app(BillFactory::class);
|
$factory = app(BillFactory::class);
|
||||||
@@ -121,7 +118,7 @@ class BillFactoryTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals($data['name'], $bill->name);
|
$this->assertEquals($data['name'], $bill->name);
|
||||||
$this->assertEquals($data['amount_min'], $bill->amount_min);
|
$this->assertEquals($data['amount_min'], $bill->amount_min);
|
||||||
$this->assertEquals(5, $bill->transaction_currency_id);
|
$this->assertEquals($dollar->id, $bill->transaction_currency_id);
|
||||||
$this->assertEquals($data['repeat_freq'], $bill->repeat_freq);
|
$this->assertEquals($data['repeat_freq'], $bill->repeat_freq);
|
||||||
$note = $bill->notes()->first();
|
$note = $bill->notes()->first();
|
||||||
$this->assertEquals($data['notes'], $note->text);
|
$this->assertEquals($data['notes'], $note->text);
|
||||||
@@ -137,13 +134,14 @@ class BillFactoryTest extends TestCase
|
|||||||
public function testCreateEmptyNotes(): void
|
public function testCreateEmptyNotes(): void
|
||||||
{
|
{
|
||||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||||
|
$euro = $this->getEuro();
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'Some new bill #' . random_int(1, 10000),
|
'name' => sprintf('Some new bill #%d', $this->randomInt()),
|
||||||
'amount_min' => '5',
|
'amount_min' => '5',
|
||||||
'amount_max' => '10',
|
'amount_max' => '10',
|
||||||
'date' => '2018-01-01',
|
'date' => '2018-01-01',
|
||||||
'repeat_freq' => 'monthly',
|
'repeat_freq' => 'monthly',
|
||||||
'currency_id' => 1,
|
'currency_id' => $euro->id,
|
||||||
'currency_code' => '',
|
'currency_code' => '',
|
||||||
'skip' => 0,
|
'skip' => 0,
|
||||||
'automatch' => true,
|
'automatch' => true,
|
||||||
@@ -152,7 +150,7 @@ class BillFactoryTest extends TestCase
|
|||||||
];
|
];
|
||||||
|
|
||||||
$currencyFactory->shouldReceive('find')->atLeast()->once()
|
$currencyFactory->shouldReceive('find')->atLeast()->once()
|
||||||
->withArgs([1, ''])->andReturn(TransactionCurrency::find(1));
|
->withArgs([1, ''])->andReturn($euro);
|
||||||
|
|
||||||
|
|
||||||
/** @var BillFactory $factory */
|
/** @var BillFactory $factory */
|
||||||
@@ -161,7 +159,7 @@ class BillFactoryTest extends TestCase
|
|||||||
$bill = $factory->create($data);
|
$bill = $factory->create($data);
|
||||||
|
|
||||||
$this->assertEquals($data['name'], $bill->name);
|
$this->assertEquals($data['name'], $bill->name);
|
||||||
$this->assertEquals(1, $bill->transaction_currency_id);
|
$this->assertEquals($euro->id, $bill->transaction_currency_id);
|
||||||
$this->assertEquals($data['amount_min'], $bill->amount_min);
|
$this->assertEquals($data['amount_min'], $bill->amount_min);
|
||||||
$this->assertEquals($data['repeat_freq'], $bill->repeat_freq);
|
$this->assertEquals($data['repeat_freq'], $bill->repeat_freq);
|
||||||
$this->assertEquals(0, $bill->notes()->count());
|
$this->assertEquals(0, $bill->notes()->count());
|
||||||
@@ -177,8 +175,9 @@ class BillFactoryTest extends TestCase
|
|||||||
public function testCreateNoCurrency(): void
|
public function testCreateNoCurrency(): void
|
||||||
{
|
{
|
||||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||||
|
$dollar = $this->getDollar();
|
||||||
$data = [
|
$data = [
|
||||||
'name' => 'Some new bill #' . random_int(1, 10000),
|
'name' => sprintf('Some new bill #%d', $this->randomInt()),
|
||||||
'amount_min' => '5',
|
'amount_min' => '5',
|
||||||
'amount_max' => '10',
|
'amount_max' => '10',
|
||||||
'date' => '2018-01-01',
|
'date' => '2018-01-01',
|
||||||
@@ -192,7 +191,7 @@ class BillFactoryTest extends TestCase
|
|||||||
$currencyFactory->shouldReceive('find')->atLeast()->once()
|
$currencyFactory->shouldReceive('find')->atLeast()->once()
|
||||||
->withArgs([0, ''])->andReturnNull();
|
->withArgs([0, ''])->andReturnNull();
|
||||||
|
|
||||||
Amount::shouldReceive('getDefaultCurrencyByUser')->atLeast()->once()->andReturn(TransactionCurrency::find(3));
|
Amount::shouldReceive('getDefaultCurrencyByUser')->atLeast()->once()->andReturn($dollar);
|
||||||
|
|
||||||
|
|
||||||
/** @var BillFactory $factory */
|
/** @var BillFactory $factory */
|
||||||
@@ -202,7 +201,7 @@ class BillFactoryTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals($data['name'], $bill->name);
|
$this->assertEquals($data['name'], $bill->name);
|
||||||
$this->assertEquals($data['amount_min'], $bill->amount_min);
|
$this->assertEquals($data['amount_min'], $bill->amount_min);
|
||||||
$this->assertEquals(3, $bill->transaction_currency_id);
|
$this->assertEquals($dollar->id, $bill->transaction_currency_id);
|
||||||
$this->assertEquals($data['repeat_freq'], $bill->repeat_freq);
|
$this->assertEquals($data['repeat_freq'], $bill->repeat_freq);
|
||||||
$note = $bill->notes()->first();
|
$note = $bill->notes()->first();
|
||||||
$this->assertEquals($data['notes'], $note->text);
|
$this->assertEquals($data['notes'], $note->text);
|
||||||
@@ -256,7 +255,7 @@ class BillFactoryTest extends TestCase
|
|||||||
/** @var BillFactory $factory */
|
/** @var BillFactory $factory */
|
||||||
$factory = app(BillFactory::class);
|
$factory = app(BillFactory::class);
|
||||||
$factory->setUser($this->user());
|
$factory->setUser($this->user());
|
||||||
$piggy = $factory->find(null, 'I dont exist' . random_int(1, 10000));
|
$piggy = $factory->find(null, sprintf('I dont exist #%d', $this->randomInt()));
|
||||||
|
|
||||||
$this->assertNull($piggy);
|
$this->assertNull($piggy);
|
||||||
}
|
}
|
||||||
|
@@ -102,7 +102,7 @@ class BudgetFactoryTest extends TestCase
|
|||||||
/** @var BudgetFactory $factory */
|
/** @var BudgetFactory $factory */
|
||||||
$factory = app(BudgetFactory::class);
|
$factory = app(BudgetFactory::class);
|
||||||
$factory->setUser($this->user());
|
$factory->setUser($this->user());
|
||||||
$this->assertNull($factory->find(null, 'I dont exist.' . random_int(1, 10000)));
|
$this->assertNull($factory->find(null, sprintf('I dont exist %d', $this->randomInt())));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -91,7 +91,7 @@ class CategoryFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFindOrCreateNewName(): void
|
public function testFindOrCreateNewName(): void
|
||||||
{
|
{
|
||||||
$name = 'Some new category #' . random_int(1, 10000);
|
$name = sprintf('Some new category #%d', $this->randomInt());
|
||||||
|
|
||||||
/** @var CategoryFactory $factory */
|
/** @var CategoryFactory $factory */
|
||||||
$factory = app(CategoryFactory::class);
|
$factory = app(CategoryFactory::class);
|
||||||
|
@@ -27,7 +27,6 @@ namespace Tests\Unit\Factory;
|
|||||||
use FireflyIII\Factory\PiggyBankEventFactory;
|
use FireflyIII\Factory\PiggyBankEventFactory;
|
||||||
use FireflyIII\Models\PiggyBankEvent;
|
use FireflyIII\Models\PiggyBankEvent;
|
||||||
use FireflyIII\Models\PiggyBankRepetition;
|
use FireflyIII\Models\PiggyBankRepetition;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
@@ -52,12 +51,8 @@ class PiggyBankEventFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCreateAmountZero(): void
|
public function testCreateAmountZero(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
$transfer = $this->getRandomTransfer();
|
||||||
|
$piggy = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||||
return;
|
|
||||||
/** @var TransactionJournal $transfer */
|
|
||||||
$transfer = $this->user()->transactionJournals()->where('transaction_type_id', 3)->first();
|
|
||||||
$piggy = $this->user()->piggyBanks()->first();
|
|
||||||
$repetition = PiggyBankRepetition::first();
|
$repetition = PiggyBankRepetition::first();
|
||||||
$repos = $this->mock(PiggyBankRepositoryInterface::class);
|
$repos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
/** @var PiggyBankEventFactory $factory */
|
/** @var PiggyBankEventFactory $factory */
|
||||||
@@ -76,11 +71,8 @@ class PiggyBankEventFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCreateNoPiggy(): void
|
public function testCreateNoPiggy(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
$this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
$transfer = $this->getRandomTransfer();
|
||||||
return;
|
|
||||||
/** @var TransactionJournal $transfer */
|
|
||||||
$transfer = $this->user()->transactionJournals()->where('transaction_type_id', 3)->first();
|
|
||||||
|
|
||||||
/** @var PiggyBankEventFactory $factory */
|
/** @var PiggyBankEventFactory $factory */
|
||||||
$factory = app(PiggyBankEventFactory::class);
|
$factory = app(PiggyBankEventFactory::class);
|
||||||
@@ -95,11 +87,7 @@ class PiggyBankEventFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCreateNoRep(): void
|
public function testCreateNoRep(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
$transfer = $this->getRandomTransfer();
|
||||||
|
|
||||||
return;
|
|
||||||
/** @var TransactionJournal $transfer */
|
|
||||||
$transfer = $this->user()->transactionJournals()->where('transaction_type_id', 3)->first();
|
|
||||||
$piggy = $this->user()->piggyBanks()->first();
|
$piggy = $this->user()->piggyBanks()->first();
|
||||||
$repos = $this->mock(PiggyBankRepositoryInterface::class);
|
$repos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
/** @var PiggyBankEventFactory $factory */
|
/** @var PiggyBankEventFactory $factory */
|
||||||
@@ -118,11 +106,9 @@ class PiggyBankEventFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCreateNotTransfer(): void
|
public function testCreateNotTransfer(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
$this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
$deposit = $this->getRandomDeposit();
|
||||||
|
|
||||||
return;
|
|
||||||
/** @var TransactionJournal $deposit */
|
|
||||||
$deposit = $this->user()->transactionJournals()->where('transaction_type_id', 2)->first();
|
|
||||||
$piggy = $this->user()->piggyBanks()->first();
|
$piggy = $this->user()->piggyBanks()->first();
|
||||||
/** @var PiggyBankEventFactory $factory */
|
/** @var PiggyBankEventFactory $factory */
|
||||||
$factory = app(PiggyBankEventFactory::class);
|
$factory = app(PiggyBankEventFactory::class);
|
||||||
@@ -135,15 +121,12 @@ class PiggyBankEventFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCreateSuccess(): void
|
public function testCreateSuccess(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
$transfer = $this->getRandomTransfer();
|
||||||
|
|
||||||
return;
|
|
||||||
/** @var TransactionJournal $transfer */
|
|
||||||
$transfer = $this->user()->transactionJournals()->where('transaction_type_id', 3)->first();
|
|
||||||
$piggy = $this->user()->piggyBanks()->first();
|
$piggy = $this->user()->piggyBanks()->first();
|
||||||
$repetition = PiggyBankRepetition::first();
|
$repetition = PiggyBankRepetition::first();
|
||||||
$event = PiggyBankEvent::first();
|
$event = PiggyBankEvent::first();
|
||||||
$repos = $this->mock(PiggyBankRepositoryInterface::class);
|
$repos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
|
|
||||||
/** @var PiggyBankEventFactory $factory */
|
/** @var PiggyBankEventFactory $factory */
|
||||||
$factory = app(PiggyBankEventFactory::class);
|
$factory = app(PiggyBankEventFactory::class);
|
||||||
|
|
||||||
@@ -155,8 +138,8 @@ class PiggyBankEventFactoryTest extends TestCase
|
|||||||
$repos->shouldReceive('createEventWithJournal')->once()->andReturn($event);
|
$repos->shouldReceive('createEventWithJournal')->once()->andReturn($event);
|
||||||
|
|
||||||
$result = $factory->create($transfer, $piggy);
|
$result = $factory->create($transfer, $piggy);
|
||||||
|
$this->assertNotnull($result);
|
||||||
$this->assertEquals($result->id, $event->id);
|
$this->assertEquals($result->id, $event->id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,7 @@ namespace Tests\Unit\Factory;
|
|||||||
|
|
||||||
use Amount;
|
use Amount;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Factory\AccountFactory;
|
||||||
use FireflyIII\Factory\BudgetFactory;
|
use FireflyIII\Factory\BudgetFactory;
|
||||||
use FireflyIII\Factory\CategoryFactory;
|
use FireflyIII\Factory\CategoryFactory;
|
||||||
use FireflyIII\Factory\PiggyBankFactory;
|
use FireflyIII\Factory\PiggyBankFactory;
|
||||||
@@ -35,12 +36,22 @@ use FireflyIII\Factory\TransactionTypeFactory;
|
|||||||
use FireflyIII\Models\TransactionCurrency;
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use FireflyIII\Validation\AccountValidator;
|
||||||
use Log;
|
use Log;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Test different combinations:
|
||||||
|
* Transfer
|
||||||
|
* Withdrawal
|
||||||
|
* Deposit
|
||||||
|
*
|
||||||
|
* With the correct types.
|
||||||
*
|
*
|
||||||
* Class RecurrenceFactoryTest
|
* Class RecurrenceFactoryTest
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
class RecurrenceFactoryTest extends TestCase
|
class RecurrenceFactoryTest extends TestCase
|
||||||
{
|
{
|
||||||
@@ -55,18 +66,20 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* With piggy bank. With tags. With budget. With category.
|
* With piggy bank. With tags. With budget. With category.
|
||||||
|
* This is a withdrawal
|
||||||
*
|
*
|
||||||
* @covers \FireflyIII\Factory\RecurrenceFactory
|
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||||
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
||||||
*/
|
*/
|
||||||
public function testBasic(): void
|
public function testCreate(): void
|
||||||
{
|
{
|
||||||
// objects to return:
|
// objects to return:
|
||||||
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
$source = $this->getRandomAsset();
|
||||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
$destination = $this->getRandomExpense();
|
||||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||||
|
$euro = $this->getEuro();
|
||||||
|
|
||||||
// mock other factories:
|
// mock other factories:
|
||||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||||
@@ -74,23 +87,28 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
$categoryFactory = $this->mock(CategoryFactory::class);
|
$categoryFactory = $this->mock(CategoryFactory::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||||
|
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||||
|
$accountFactory = $this->mock(AccountFactory::class);
|
||||||
|
$validator = $this->mock(AccountValidator::class);
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn($euro)->once();
|
||||||
$piggyFactory->shouldReceive('setUser')->once();
|
$piggyFactory->shouldReceive('setUser')->atLeast()->once();
|
||||||
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
$budgetFactory->shouldReceive('setUser')->atLeast()->once();
|
||||||
|
|
||||||
$accountRepos->shouldReceive('setUser')->twice();
|
$accountRepos->shouldReceive('setUser')->twice();
|
||||||
$accountRepos->shouldReceive('findNull')->twice()->andReturn($accountA, $accountB);
|
$categoryFactory->shouldReceive('setUser')->once();
|
||||||
|
|
||||||
|
|
||||||
|
$piggyFactory->shouldReceive('find')->atLeast()->once()->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
||||||
|
$accountRepos->shouldReceive('findNull')->twice()->andReturn($source, $destination);
|
||||||
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
||||||
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
||||||
|
|
||||||
$budgetFactory->shouldReceive('setUser')->once();
|
|
||||||
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
||||||
|
|
||||||
$categoryFactory->shouldReceive('setUser')->once();
|
|
||||||
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||||
|
$validator->shouldReceive('setUser')->once();
|
||||||
|
$validator->shouldReceive('setTransactionType')->atLeast()->once();
|
||||||
|
$validator->shouldReceive('validateSource')->atLeast()->once()->andReturn(true);
|
||||||
|
$validator->shouldReceive('validateDestination')->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
// data for basic recurrence.
|
// data for basic recurrence.
|
||||||
$data = [
|
$data = [
|
||||||
@@ -98,7 +116,7 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
'type' => 'withdrawal',
|
'type' => 'withdrawal',
|
||||||
'first_date' => Carbon::now()->addDay(),
|
'first_date' => Carbon::now()->addDay(),
|
||||||
'repetitions' => 0,
|
'repetitions' => 0,
|
||||||
'title' => 'Test recurrence' . random_int(1, 100000),
|
'title' => 'Test recurrence' . $this->randomInt(),
|
||||||
'description' => 'Description thing',
|
'description' => 'Description thing',
|
||||||
'apply_rules' => true,
|
'apply_rules' => true,
|
||||||
'active' => true,
|
'active' => true,
|
||||||
@@ -122,7 +140,7 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
'source_id' => 1,
|
'source_id' => 1,
|
||||||
'source_name' => 'Some name',
|
'source_name' => 'Some name',
|
||||||
'destination_id' => 2,
|
'destination_id' => 2,
|
||||||
'destination_name' => 'some otjer name',
|
'destination_name' => 'some other name',
|
||||||
'currency_id' => 1,
|
'currency_id' => 1,
|
||||||
'currency_code' => 'EUR',
|
'currency_code' => 'EUR',
|
||||||
'foreign_currency_id' => null,
|
'foreign_currency_id' => null,
|
||||||
@@ -138,199 +156,9 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
|
||||||
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(1));
|
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(1));
|
||||||
$factory = new RecurrenceFactory;
|
/** @var RecurrenceFactory $factory */
|
||||||
$factory->setUser($this->user());
|
$factory = app(RecurrenceFactory::class);
|
||||||
|
|
||||||
$result = $factory->create($data);
|
|
||||||
$this->assertEquals($result->title, $data['recurrence']['title']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deposit. With piggy bank. With tags. With budget. With category.
|
|
||||||
*
|
|
||||||
* @covers \FireflyIII\Factory\RecurrenceFactory
|
|
||||||
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
|
||||||
*/
|
|
||||||
public function testBasicDeposit(): void
|
|
||||||
{
|
|
||||||
// objects to return:
|
|
||||||
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
|
||||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
|
||||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
|
||||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
|
||||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
|
||||||
|
|
||||||
// mock other factories:
|
|
||||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
|
||||||
$budgetFactory = $this->mock(BudgetFactory::class);
|
|
||||||
$categoryFactory = $this->mock(CategoryFactory::class);
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
|
||||||
|
|
||||||
// mock calls:
|
|
||||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
|
||||||
$piggyFactory->shouldReceive('setUser')->once();
|
|
||||||
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
|
||||||
|
|
||||||
$accountRepos->shouldReceive('setUser')->twice();
|
|
||||||
$accountRepos->shouldReceive('findNull')->twice()->andReturn($accountA, $accountB);
|
|
||||||
|
|
||||||
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
|
||||||
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
|
||||||
|
|
||||||
$budgetFactory->shouldReceive('setUser')->once();
|
|
||||||
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
|
||||||
|
|
||||||
$categoryFactory->shouldReceive('setUser')->once();
|
|
||||||
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
|
||||||
|
|
||||||
// data for basic recurrence.
|
|
||||||
$data = [
|
|
||||||
'recurrence' => [
|
|
||||||
'type' => 'deposit',
|
|
||||||
'first_date' => Carbon::now()->addDay(),
|
|
||||||
'repetitions' => 0,
|
|
||||||
'title' => 'Test recurrence' . random_int(1, 100000),
|
|
||||||
'description' => 'Description thing',
|
|
||||||
'apply_rules' => true,
|
|
||||||
'active' => true,
|
|
||||||
'repeat_until' => null,
|
|
||||||
],
|
|
||||||
'meta' => [
|
|
||||||
'tags' => ['a', 'b', 'c'],
|
|
||||||
'piggy_bank_id' => 1,
|
|
||||||
'piggy_bank_name' => 'Bla bla',
|
|
||||||
],
|
|
||||||
'repetitions' => [
|
|
||||||
[
|
|
||||||
'type' => 'daily',
|
|
||||||
'moment' => '',
|
|
||||||
'skip' => 0,
|
|
||||||
'weekend' => 1,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'transactions' => [
|
|
||||||
[
|
|
||||||
'source_id' => 1,
|
|
||||||
'source_name' => 'Some name',
|
|
||||||
'destination_id' => 2,
|
|
||||||
'destination_name' => 'some otjer name',
|
|
||||||
'currency_id' => 1,
|
|
||||||
'currency_code' => 'EUR',
|
|
||||||
'foreign_currency_id' => null,
|
|
||||||
'foreign_currency_code' => null,
|
|
||||||
'foreign_amount' => null,
|
|
||||||
'description' => 'Bla bla bla',
|
|
||||||
'amount' => '100',
|
|
||||||
'budget_id' => 1,
|
|
||||||
'budget_name' => 'Some budget',
|
|
||||||
'category_id' => 2,
|
|
||||||
'category_name' => 'Some category',
|
|
||||||
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
|
||||||
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(2));
|
|
||||||
|
|
||||||
$factory = new RecurrenceFactory;
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
|
|
||||||
$result = $factory->create($data);
|
|
||||||
$this->assertEquals($result->title, $data['recurrence']['title']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No piggy bank. With tags. With budget. With category.
|
|
||||||
*
|
|
||||||
* @covers \FireflyIII\Factory\RecurrenceFactory
|
|
||||||
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
|
||||||
*/
|
|
||||||
public function testBasicNoPiggybank(): void
|
|
||||||
{
|
|
||||||
// objects to return:
|
|
||||||
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
|
||||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
|
||||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
|
||||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
|
||||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
|
||||||
|
|
||||||
// mock other factories:
|
|
||||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
|
||||||
$budgetFactory = $this->mock(BudgetFactory::class);
|
|
||||||
$categoryFactory = $this->mock(CategoryFactory::class);
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
|
||||||
|
|
||||||
// mock calls:
|
|
||||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
|
||||||
$piggyFactory->shouldReceive('setUser')->once();
|
|
||||||
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn(null);
|
|
||||||
|
|
||||||
$accountRepos->shouldReceive('setUser')->twice();
|
|
||||||
$accountRepos->shouldReceive('findNull')->twice()->andReturn($accountA, $accountB);
|
|
||||||
|
|
||||||
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
|
||||||
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
|
||||||
|
|
||||||
$budgetFactory->shouldReceive('setUser')->once();
|
|
||||||
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
|
||||||
|
|
||||||
$categoryFactory->shouldReceive('setUser')->once();
|
|
||||||
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
|
||||||
|
|
||||||
// data for basic recurrence.
|
|
||||||
$data = [
|
|
||||||
'recurrence' => [
|
|
||||||
'type' => 'withdrawal',
|
|
||||||
'first_date' => Carbon::now()->addDay(),
|
|
||||||
'repetitions' => 0,
|
|
||||||
'title' => 'Test recurrence' . random_int(1, 100000),
|
|
||||||
'description' => 'Description thing',
|
|
||||||
'apply_rules' => true,
|
|
||||||
'active' => true,
|
|
||||||
'repeat_until' => null,
|
|
||||||
],
|
|
||||||
'meta' => [
|
|
||||||
'tags' => ['a', 'b', 'c'],
|
|
||||||
'piggy_bank_id' => 1,
|
|
||||||
'piggy_bank_name' => 'Bla bla',
|
|
||||||
],
|
|
||||||
'repetitions' => [
|
|
||||||
[
|
|
||||||
'type' => 'daily',
|
|
||||||
'moment' => '',
|
|
||||||
'skip' => 0,
|
|
||||||
'weekend' => 1,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'transactions' => [
|
|
||||||
[
|
|
||||||
'source_id' => 1,
|
|
||||||
'source_name' => 'Some name',
|
|
||||||
'destination_id' => 2,
|
|
||||||
'destination_name' => 'some otjer name',
|
|
||||||
'currency_id' => 1,
|
|
||||||
'currency_code' => 'EUR',
|
|
||||||
'foreign_currency_id' => null,
|
|
||||||
'foreign_currency_code' => null,
|
|
||||||
'foreign_amount' => null,
|
|
||||||
'description' => 'Bla bla bla',
|
|
||||||
'amount' => '100',
|
|
||||||
'budget_id' => 1,
|
|
||||||
'budget_name' => 'Some budget',
|
|
||||||
'category_id' => 2,
|
|
||||||
'category_name' => 'Some category',
|
|
||||||
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
|
||||||
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(1));
|
|
||||||
$factory = new RecurrenceFactory;
|
|
||||||
$factory->setUser($this->user());
|
$factory->setUser($this->user());
|
||||||
|
|
||||||
$result = $factory->create($data);
|
$result = $factory->create($data);
|
||||||
@@ -339,16 +167,239 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* With piggy bank. With tags. With budget. With category.
|
* With piggy bank. With tags. With budget. With category.
|
||||||
|
* Submit account names, not types. This is a withdrawal.
|
||||||
*
|
*
|
||||||
* @covers \FireflyIII\Factory\RecurrenceFactory
|
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||||
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
||||||
*/
|
*/
|
||||||
public function testBasicNoTags(): void
|
public function testCreateByName(): void
|
||||||
{
|
{
|
||||||
// objects to return:
|
// objects to return:
|
||||||
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
$source = $this->getRandomAsset();
|
||||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
$destination = $this->getRandomExpense();
|
||||||
|
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||||
|
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||||
|
$euro = $this->getEuro();
|
||||||
|
|
||||||
|
// mock other factories:
|
||||||
|
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||||
|
$budgetFactory = $this->mock(BudgetFactory::class);
|
||||||
|
$categoryFactory = $this->mock(CategoryFactory::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||||
|
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||||
|
$accountFactory = $this->mock(AccountFactory::class);
|
||||||
|
$validator = $this->mock(AccountValidator::class);
|
||||||
|
|
||||||
|
// mock calls:
|
||||||
|
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn($euro)->once();
|
||||||
|
$piggyFactory->shouldReceive('setUser')->atLeast()->once();
|
||||||
|
$budgetFactory->shouldReceive('setUser')->atLeast()->once();
|
||||||
|
$categoryFactory->shouldReceive('setUser')->once();
|
||||||
|
$accountRepos->shouldReceive('setUser')->twice();
|
||||||
|
//$accountFactory->shouldReceive('setUser')->atLeast()->once();
|
||||||
|
|
||||||
|
$piggyFactory->shouldReceive('find')->atLeast()->once()->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
||||||
|
|
||||||
|
// return NULL for account ID's.
|
||||||
|
$accountRepos->shouldReceive('findNull')->twice()->andReturn(null, null);
|
||||||
|
// but find them by name:
|
||||||
|
$accountRepos->shouldReceive('findByName')->twice()->andReturn($source, $destination);
|
||||||
|
|
||||||
|
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
||||||
|
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
||||||
|
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
||||||
|
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||||
|
|
||||||
|
// validator:
|
||||||
|
$validator->shouldReceive('setUser')->once();
|
||||||
|
$validator->shouldReceive('setTransactionType')->atLeast()->once();
|
||||||
|
$validator->shouldReceive('validateSource')->atLeast()->once()->andReturn(true);
|
||||||
|
$validator->shouldReceive('validateDestination')->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
|
// data for basic recurrence.
|
||||||
|
$data = [
|
||||||
|
'recurrence' => [
|
||||||
|
'type' => 'withdrawal',
|
||||||
|
'first_date' => Carbon::now()->addDay(),
|
||||||
|
'repetitions' => 0,
|
||||||
|
'title' => 'Test recurrence' . $this->randomInt(),
|
||||||
|
'description' => 'Description thing',
|
||||||
|
'apply_rules' => true,
|
||||||
|
'active' => true,
|
||||||
|
'repeat_until' => null,
|
||||||
|
],
|
||||||
|
'meta' => [
|
||||||
|
'tags' => ['a', 'b', 'c'],
|
||||||
|
'piggy_bank_id' => 1,
|
||||||
|
'piggy_bank_name' => 'Bla bla',
|
||||||
|
],
|
||||||
|
'repetitions' => [
|
||||||
|
[
|
||||||
|
'type' => 'daily',
|
||||||
|
'moment' => '',
|
||||||
|
'skip' => 0,
|
||||||
|
'weekend' => 1,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'transactions' => [
|
||||||
|
[
|
||||||
|
'source_id' => 1,
|
||||||
|
'source_name' => 'Some name',
|
||||||
|
'destination_id' => 2,
|
||||||
|
'destination_name' => 'some other name',
|
||||||
|
'currency_id' => 1,
|
||||||
|
'currency_code' => 'EUR',
|
||||||
|
'foreign_currency_id' => null,
|
||||||
|
'foreign_currency_code' => null,
|
||||||
|
'foreign_amount' => null,
|
||||||
|
'description' => 'Bla bla bla',
|
||||||
|
'amount' => '100',
|
||||||
|
'budget_id' => 1,
|
||||||
|
'budget_name' => 'Some budget',
|
||||||
|
'category_id' => 2,
|
||||||
|
'category_name' => 'Some category',
|
||||||
|
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(1));
|
||||||
|
/** @var RecurrenceFactory $factory */
|
||||||
|
$factory = app(RecurrenceFactory::class);
|
||||||
|
$factory->setUser($this->user());
|
||||||
|
|
||||||
|
$result = $factory->create($data);
|
||||||
|
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* With piggy bank. With tags. With budget. With category.
|
||||||
|
* Submit account names, not types. Also a withdrawal
|
||||||
|
*
|
||||||
|
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||||
|
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
||||||
|
*/
|
||||||
|
public function testCreateNewByName(): void
|
||||||
|
{
|
||||||
|
// objects to return:
|
||||||
|
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||||
|
$source = $this->getRandomAsset();
|
||||||
|
$destination = $this->getRandomExpense();
|
||||||
|
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||||
|
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||||
|
$euro = $this->getEuro();
|
||||||
|
|
||||||
|
// mock other factories:
|
||||||
|
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||||
|
$budgetFactory = $this->mock(BudgetFactory::class);
|
||||||
|
$categoryFactory = $this->mock(CategoryFactory::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||||
|
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||||
|
$accountFactory = $this->mock(AccountFactory::class);
|
||||||
|
$validator = $this->mock(AccountValidator::class);
|
||||||
|
|
||||||
|
// mock calls:
|
||||||
|
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn($euro)->once();
|
||||||
|
$piggyFactory->shouldReceive('setUser')->atLeast()->once();
|
||||||
|
$budgetFactory->shouldReceive('setUser')->atLeast()->once();
|
||||||
|
$categoryFactory->shouldReceive('setUser')->once();
|
||||||
|
|
||||||
|
$accountRepos->shouldReceive('setUser')->twice();
|
||||||
|
$piggyFactory->shouldReceive('find')->atLeast()->once()->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
||||||
|
|
||||||
|
// return NULL for account ID's.
|
||||||
|
$accountRepos->shouldReceive('findNull')->twice()->andReturn(null, null);
|
||||||
|
// but find them by name (at least the first one):
|
||||||
|
$accountRepos->shouldReceive('findByName')->twice()->andReturn($source, null);
|
||||||
|
|
||||||
|
// this activates the "create by name" routine (account factory):
|
||||||
|
$accountFactory->shouldReceive('setUser')->atLeast()->once();
|
||||||
|
$accountFactory->shouldReceive('findOrCreate')->atLeast()->once()
|
||||||
|
->andReturn($destination);
|
||||||
|
|
||||||
|
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
||||||
|
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
||||||
|
|
||||||
|
|
||||||
|
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
||||||
|
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||||
|
|
||||||
|
// validator:
|
||||||
|
$validator->shouldReceive('setUser')->once();
|
||||||
|
$validator->shouldReceive('setTransactionType')->atLeast()->once();
|
||||||
|
$validator->shouldReceive('validateSource')->atLeast()->once()->andReturn(true);
|
||||||
|
$validator->shouldReceive('validateDestination')->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
|
// data for basic recurrence.
|
||||||
|
$data = [
|
||||||
|
'recurrence' => [
|
||||||
|
'type' => 'withdrawal',
|
||||||
|
'first_date' => Carbon::now()->addDay(),
|
||||||
|
'repetitions' => 0,
|
||||||
|
'title' => 'Test recurrence' . $this->randomInt(),
|
||||||
|
'description' => 'Description thing',
|
||||||
|
'apply_rules' => true,
|
||||||
|
'active' => true,
|
||||||
|
'repeat_until' => null,
|
||||||
|
],
|
||||||
|
'meta' => [
|
||||||
|
'tags' => ['a', 'b', 'c'],
|
||||||
|
'piggy_bank_id' => 1,
|
||||||
|
'piggy_bank_name' => 'Bla bla',
|
||||||
|
],
|
||||||
|
'repetitions' => [
|
||||||
|
[
|
||||||
|
'type' => 'daily',
|
||||||
|
'moment' => '',
|
||||||
|
'skip' => 0,
|
||||||
|
'weekend' => 1,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'transactions' => [
|
||||||
|
[
|
||||||
|
'source_id' => 1,
|
||||||
|
'source_name' => 'Some name',
|
||||||
|
'destination_id' => 2,
|
||||||
|
'destination_name' => 'some other name',
|
||||||
|
'currency_id' => 1,
|
||||||
|
'currency_code' => 'EUR',
|
||||||
|
'foreign_currency_id' => null,
|
||||||
|
'foreign_currency_code' => null,
|
||||||
|
'foreign_amount' => null,
|
||||||
|
'description' => 'Bla bla bla',
|
||||||
|
'amount' => '100',
|
||||||
|
'budget_id' => 1,
|
||||||
|
'budget_name' => 'Some budget',
|
||||||
|
'category_id' => 2,
|
||||||
|
'category_name' => 'Some category',
|
||||||
|
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(1));
|
||||||
|
/** @var RecurrenceFactory $factory */
|
||||||
|
$factory = app(RecurrenceFactory::class);
|
||||||
|
$factory->setUser($this->user());
|
||||||
|
|
||||||
|
$result = $factory->create($data);
|
||||||
|
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deposit. With piggy bank. With tags. With budget. With category.
|
||||||
|
*
|
||||||
|
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||||
|
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
||||||
|
*/
|
||||||
|
public function testCreateDeposit(): void
|
||||||
|
{
|
||||||
|
// objects to return:
|
||||||
|
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||||
|
$source = $this->getRandomRevenue();
|
||||||
|
$destination = $this->getRandomAsset();
|
||||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||||
|
|
||||||
@@ -358,6 +409,9 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
$categoryFactory = $this->mock(CategoryFactory::class);
|
$categoryFactory = $this->mock(CategoryFactory::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||||
|
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||||
|
$accountFactory = $this->mock(AccountFactory::class);
|
||||||
|
$validator = $this->mock(AccountValidator::class);
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
||||||
@@ -365,7 +419,7 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
||||||
|
|
||||||
$accountRepos->shouldReceive('setUser')->twice();
|
$accountRepos->shouldReceive('setUser')->twice();
|
||||||
$accountRepos->shouldReceive('findNull')->twice()->andReturn($accountA, $accountB);
|
$accountRepos->shouldReceive('findNull')->twice()->andReturn($source, $destination);
|
||||||
|
|
||||||
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
||||||
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
||||||
@@ -376,13 +430,230 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
$categoryFactory->shouldReceive('setUser')->once();
|
$categoryFactory->shouldReceive('setUser')->once();
|
||||||
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||||
|
|
||||||
|
// validator:
|
||||||
|
$validator->shouldReceive('setUser')->once();
|
||||||
|
$validator->shouldReceive('setTransactionType')->atLeast()->once();
|
||||||
|
$validator->shouldReceive('validateSource')->atLeast()->once()->andReturn(true);
|
||||||
|
$validator->shouldReceive('validateDestination')->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
|
// data for basic recurrence.
|
||||||
|
$data = [
|
||||||
|
'recurrence' => [
|
||||||
|
'type' => 'deposit',
|
||||||
|
'first_date' => Carbon::now()->addDay(),
|
||||||
|
'repetitions' => 0,
|
||||||
|
'title' => 'Test recurrence' . $this->randomInt(),
|
||||||
|
'description' => 'Description thing',
|
||||||
|
'apply_rules' => true,
|
||||||
|
'active' => true,
|
||||||
|
'repeat_until' => null,
|
||||||
|
],
|
||||||
|
'meta' => [
|
||||||
|
'tags' => ['a', 'b', 'c'],
|
||||||
|
'piggy_bank_id' => 1,
|
||||||
|
'piggy_bank_name' => 'Bla bla',
|
||||||
|
],
|
||||||
|
'repetitions' => [
|
||||||
|
[
|
||||||
|
'type' => 'daily',
|
||||||
|
'moment' => '',
|
||||||
|
'skip' => 0,
|
||||||
|
'weekend' => 1,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'transactions' => [
|
||||||
|
[
|
||||||
|
'source_id' => 1,
|
||||||
|
'source_name' => 'Some name',
|
||||||
|
'destination_id' => 2,
|
||||||
|
'destination_name' => 'some otjer name',
|
||||||
|
'currency_id' => 1,
|
||||||
|
'currency_code' => 'EUR',
|
||||||
|
'foreign_currency_id' => null,
|
||||||
|
'foreign_currency_code' => null,
|
||||||
|
'foreign_amount' => null,
|
||||||
|
'description' => 'Bla bla bla',
|
||||||
|
'amount' => '100',
|
||||||
|
'budget_id' => 1,
|
||||||
|
'budget_name' => 'Some budget',
|
||||||
|
'category_id' => 2,
|
||||||
|
'category_name' => 'Some category',
|
||||||
|
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(2));
|
||||||
|
|
||||||
|
/** @var RecurrenceFactory $factory */
|
||||||
|
$factory = app(RecurrenceFactory::class);
|
||||||
|
$factory->setUser($this->user());
|
||||||
|
|
||||||
|
$result = $factory->create($data);
|
||||||
|
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No piggy bank. With tags. With budget. With category. Withdrawal.
|
||||||
|
*
|
||||||
|
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||||
|
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
||||||
|
*/
|
||||||
|
public function testCreateNoPiggybank(): void
|
||||||
|
{
|
||||||
|
// objects to return:
|
||||||
|
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||||
|
$source = $this->getRandomAsset();
|
||||||
|
$destination = $this->getRandomExpense();
|
||||||
|
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||||
|
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||||
|
|
||||||
|
// mock other factories:
|
||||||
|
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||||
|
$budgetFactory = $this->mock(BudgetFactory::class);
|
||||||
|
$categoryFactory = $this->mock(CategoryFactory::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||||
|
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||||
|
$accountFactory = $this->mock(AccountFactory::class);
|
||||||
|
$validator = $this->mock(AccountValidator::class);
|
||||||
|
|
||||||
|
// mock calls:
|
||||||
|
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
||||||
|
$piggyFactory->shouldReceive('setUser')->once();
|
||||||
|
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn(null);
|
||||||
|
|
||||||
|
$accountRepos->shouldReceive('setUser')->twice();
|
||||||
|
$accountRepos->shouldReceive('findNull')->twice()->andReturn($source, $destination);
|
||||||
|
|
||||||
|
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
||||||
|
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
||||||
|
|
||||||
|
$budgetFactory->shouldReceive('setUser')->once();
|
||||||
|
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
||||||
|
|
||||||
|
$categoryFactory->shouldReceive('setUser')->once();
|
||||||
|
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||||
|
|
||||||
|
// validator:
|
||||||
|
$validator->shouldReceive('setUser')->once();
|
||||||
|
$validator->shouldReceive('setTransactionType')->atLeast()->once();
|
||||||
|
$validator->shouldReceive('validateSource')->atLeast()->once()->andReturn(true);
|
||||||
|
$validator->shouldReceive('validateDestination')->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
// data for basic recurrence.
|
// data for basic recurrence.
|
||||||
$data = [
|
$data = [
|
||||||
'recurrence' => [
|
'recurrence' => [
|
||||||
'type' => 'withdrawal',
|
'type' => 'withdrawal',
|
||||||
'first_date' => Carbon::now()->addDay(),
|
'first_date' => Carbon::now()->addDay(),
|
||||||
'repetitions' => 0,
|
'repetitions' => 0,
|
||||||
'title' => 'Test recurrence' . random_int(1, 100000),
|
'title' => 'Test recurrence' . $this->randomInt(),
|
||||||
|
'description' => 'Description thing',
|
||||||
|
'apply_rules' => true,
|
||||||
|
'active' => true,
|
||||||
|
'repeat_until' => null,
|
||||||
|
],
|
||||||
|
'meta' => [
|
||||||
|
'tags' => ['a', 'b', 'c'],
|
||||||
|
'piggy_bank_id' => 1,
|
||||||
|
'piggy_bank_name' => 'Bla bla',
|
||||||
|
],
|
||||||
|
'repetitions' => [
|
||||||
|
[
|
||||||
|
'type' => 'daily',
|
||||||
|
'moment' => '',
|
||||||
|
'skip' => 0,
|
||||||
|
'weekend' => 1,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'transactions' => [
|
||||||
|
[
|
||||||
|
'source_id' => 1,
|
||||||
|
'source_name' => 'Some name',
|
||||||
|
'destination_id' => 2,
|
||||||
|
'destination_name' => 'some otjer name',
|
||||||
|
'currency_id' => 1,
|
||||||
|
'currency_code' => 'EUR',
|
||||||
|
'foreign_currency_id' => null,
|
||||||
|
'foreign_currency_code' => null,
|
||||||
|
'foreign_amount' => null,
|
||||||
|
'description' => 'Bla bla bla',
|
||||||
|
'amount' => '100',
|
||||||
|
'budget_id' => 1,
|
||||||
|
'budget_name' => 'Some budget',
|
||||||
|
'category_id' => 2,
|
||||||
|
'category_name' => 'Some category',
|
||||||
|
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(1));
|
||||||
|
/** @var RecurrenceFactory $factory */
|
||||||
|
$factory = app(RecurrenceFactory::class);
|
||||||
|
$factory->setUser($this->user());
|
||||||
|
|
||||||
|
$result = $factory->create($data);
|
||||||
|
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* With piggy bank. With tags. With budget. With category. Withdrawal
|
||||||
|
*
|
||||||
|
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||||
|
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
||||||
|
*/
|
||||||
|
public function testCreateNoTags(): void
|
||||||
|
{
|
||||||
|
// objects to return:
|
||||||
|
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||||
|
$source = $this->getRandomAsset();
|
||||||
|
$destination = $this->getRandomExpense();
|
||||||
|
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||||
|
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||||
|
|
||||||
|
// mock other factories:
|
||||||
|
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||||
|
$budgetFactory = $this->mock(BudgetFactory::class);
|
||||||
|
$categoryFactory = $this->mock(CategoryFactory::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||||
|
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||||
|
$accountFactory = $this->mock(AccountFactory::class);
|
||||||
|
$validator = $this->mock(AccountValidator::class);
|
||||||
|
|
||||||
|
// mock calls:
|
||||||
|
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
||||||
|
$piggyFactory->shouldReceive('setUser')->once();
|
||||||
|
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
||||||
|
|
||||||
|
$accountRepos->shouldReceive('setUser')->twice();
|
||||||
|
$accountRepos->shouldReceive('findNull')->twice()->andReturn($source, $destination);
|
||||||
|
|
||||||
|
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
||||||
|
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
||||||
|
|
||||||
|
$budgetFactory->shouldReceive('setUser')->once();
|
||||||
|
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
||||||
|
|
||||||
|
$categoryFactory->shouldReceive('setUser')->once();
|
||||||
|
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||||
|
|
||||||
|
|
||||||
|
// validator:
|
||||||
|
$validator->shouldReceive('setUser')->once();
|
||||||
|
$validator->shouldReceive('setTransactionType')->atLeast()->once();
|
||||||
|
$validator->shouldReceive('validateSource')->atLeast()->once()->andReturn(true);
|
||||||
|
$validator->shouldReceive('validateDestination')->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
|
// data for basic recurrence.
|
||||||
|
$data = [
|
||||||
|
'recurrence' => [
|
||||||
|
'type' => 'withdrawal',
|
||||||
|
'first_date' => Carbon::now()->addDay(),
|
||||||
|
'repetitions' => 0,
|
||||||
|
'title' => 'Test recurrence' . $this->randomInt(),
|
||||||
'description' => 'Description thing',
|
'description' => 'Description thing',
|
||||||
'apply_rules' => true,
|
'apply_rules' => true,
|
||||||
'active' => true,
|
'active' => true,
|
||||||
@@ -422,9 +693,10 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
|
||||||
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(1));
|
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(1));
|
||||||
$factory = new RecurrenceFactory;
|
/** @var RecurrenceFactory $factory */
|
||||||
|
$factory = app(RecurrenceFactory::class);
|
||||||
$factory->setUser($this->user());
|
$factory->setUser($this->user());
|
||||||
|
|
||||||
$result = $factory->create($data);
|
$result = $factory->create($data);
|
||||||
@@ -437,14 +709,15 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
* @covers \FireflyIII\Factory\RecurrenceFactory
|
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||||
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
||||||
*/
|
*/
|
||||||
public function testBasicTransfer(): void
|
public function testCreateTransfer(): void
|
||||||
{
|
{
|
||||||
// objects to return:
|
// objects to return:
|
||||||
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
$source = $this->getRandomAsset();
|
||||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
$destination = $this->getRandomAsset($source->id);
|
||||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||||
|
$validator = $this->mock(AccountValidator::class);
|
||||||
|
|
||||||
// mock other factories:
|
// mock other factories:
|
||||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||||
@@ -452,6 +725,8 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
$categoryFactory = $this->mock(CategoryFactory::class);
|
$categoryFactory = $this->mock(CategoryFactory::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||||
|
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||||
|
$accountFactory = $this->mock(AccountFactory::class);
|
||||||
|
|
||||||
// mock calls:
|
// mock calls:
|
||||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
||||||
@@ -459,7 +734,7 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
||||||
|
|
||||||
$accountRepos->shouldReceive('setUser')->twice();
|
$accountRepos->shouldReceive('setUser')->twice();
|
||||||
$accountRepos->shouldReceive('findNull')->twice()->andReturn($accountA, $accountB);
|
$accountRepos->shouldReceive('findNull')->twice()->andReturn($source, $destination);
|
||||||
|
|
||||||
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
||||||
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
||||||
@@ -470,13 +745,19 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
$categoryFactory->shouldReceive('setUser')->once();
|
$categoryFactory->shouldReceive('setUser')->once();
|
||||||
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||||
|
|
||||||
|
// validator:
|
||||||
|
$validator->shouldReceive('setUser')->once();
|
||||||
|
$validator->shouldReceive('setTransactionType')->atLeast()->once();
|
||||||
|
$validator->shouldReceive('validateSource')->atLeast()->once()->andReturn(true);
|
||||||
|
$validator->shouldReceive('validateDestination')->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
// data for basic recurrence.
|
// data for basic recurrence.
|
||||||
$data = [
|
$data = [
|
||||||
'recurrence' => [
|
'recurrence' => [
|
||||||
'type' => 'transfer',
|
'type' => 'transfer',
|
||||||
'first_date' => Carbon::now()->addDay(),
|
'first_date' => Carbon::now()->addDay(),
|
||||||
'repetitions' => 0,
|
'repetitions' => 0,
|
||||||
'title' => 'Test recurrence' . random_int(1, 100000),
|
'title' => 'Test recurrence' . $this->randomInt(),
|
||||||
'description' => 'Description thing',
|
'description' => 'Description thing',
|
||||||
'apply_rules' => true,
|
'apply_rules' => true,
|
||||||
'active' => true,
|
'active' => true,
|
||||||
@@ -517,10 +798,12 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
|
||||||
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(3));
|
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(3));
|
||||||
|
|
||||||
$factory = new RecurrenceFactory;
|
/** @var RecurrenceFactory $factory */
|
||||||
|
$factory = app(RecurrenceFactory::class);
|
||||||
|
|
||||||
$factory->setUser($this->user());
|
$factory->setUser($this->user());
|
||||||
|
|
||||||
$result = $factory->create($data);
|
$result = $factory->create($data);
|
||||||
@@ -532,17 +815,21 @@ class RecurrenceFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCreateBadTransactionType(): void
|
public function testCreateBadTransactionType(): void
|
||||||
{
|
{
|
||||||
|
$accountFactory = $this->mock(AccountFactory::class);
|
||||||
|
$validator = $this->mock(AccountValidator::class);
|
||||||
|
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||||
$data = [
|
$data = [
|
||||||
'recurrence' => [
|
'recurrence' => [
|
||||||
'type' => 'bad type',
|
'type' => 'bad type',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
|
||||||
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(null);
|
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(null);
|
||||||
|
|
||||||
|
|
||||||
$factory = new RecurrenceFactory;
|
/** @var RecurrenceFactory $factory */
|
||||||
|
$factory = app(RecurrenceFactory::class);
|
||||||
$factory->setUser($this->user());
|
$factory->setUser($this->user());
|
||||||
|
|
||||||
$result = $factory->create($data);
|
$result = $factory->create($data);
|
||||||
|
@@ -62,7 +62,7 @@ class TagFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFindOrCreateNew(): void
|
public function testFindOrCreateNew(): void
|
||||||
{
|
{
|
||||||
$tag = 'Some new tag#' . random_int(1, 10000);
|
$tag = sprintf('Some new tag #%d', $this->randomInt());
|
||||||
/** @var TagFactory $factory */
|
/** @var TagFactory $factory */
|
||||||
$factory = app(TagFactory::class);
|
$factory = app(TagFactory::class);
|
||||||
$factory->setUser($this->user());
|
$factory->setUser($this->user());
|
||||||
|
@@ -24,13 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Unit\Factory;
|
namespace Tests\Unit\Factory;
|
||||||
|
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Factory\TransactionFactory;
|
use FireflyIII\Factory\TransactionFactory;
|
||||||
use FireflyIII\Models\Account;
|
|
||||||
use FireflyIII\Models\AccountType;
|
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|
||||||
use FireflyIII\Support\NullArrayObject;
|
|
||||||
use Log;
|
use Log;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
@@ -52,752 +46,130 @@ class TransactionFactoryTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
* @covers \FireflyIII\Factory\TransactionFactory
|
||||||
*/
|
*/
|
||||||
public function testCreateBasic(): void
|
public function testCreateNegative(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
// data used in calls.
|
// data used in calls.
|
||||||
$journal = $this->getRandomWithdrawal();
|
$journal = $this->getRandomWithdrawal();
|
||||||
$account = $this->getRandomAsset();
|
$account = $this->getRandomAsset();
|
||||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
$euro = $this->getEuro();
|
||||||
$amount = '10';
|
$amount = '10';
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
/** @var TransactionFactory $factory */
|
||||||
$factory = app(TransactionFactory::class);
|
$factory = app(TransactionFactory::class);
|
||||||
|
|
||||||
|
|
||||||
|
// set details:
|
||||||
$factory->setUser($this->user());
|
$factory->setUser($this->user());
|
||||||
$factory->setJournal($journal);
|
$factory->setJournal($journal);
|
||||||
$transaction = $factory->create($account, $euro, $amount);
|
$factory->setAccount($account);
|
||||||
|
$factory->setCurrency($euro);
|
||||||
|
$factory->setReconciled(false);
|
||||||
|
|
||||||
|
// create negative
|
||||||
|
$transaction = $factory->createNegative($amount, null);
|
||||||
|
|
||||||
$this->assertEquals($transaction->account_id, $account->id);
|
$this->assertEquals($transaction->account_id, $account->id);
|
||||||
|
$this->assertEquals('-10', $transaction->amount);
|
||||||
|
$transaction->forceDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
* @covers \FireflyIII\Factory\TransactionFactory
|
||||||
*/
|
*/
|
||||||
public function testCreateNull(): void
|
public function testCreatePositive(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
// data used in calls.
|
// data used in calls.
|
||||||
$journal = $this->getRandomWithdrawal();
|
$journal = $this->getRandomWithdrawal();
|
||||||
$account = new Account;
|
$account = $this->getRandomAsset();
|
||||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
$euro = $this->getEuro();
|
||||||
$amount = '10';
|
$amount = '10';
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
/** @var TransactionFactory $factory */
|
||||||
$factory = app(TransactionFactory::class);
|
$factory = app(TransactionFactory::class);
|
||||||
|
|
||||||
|
|
||||||
|
// set details:
|
||||||
$factory->setUser($this->user());
|
$factory->setUser($this->user());
|
||||||
$factory->setJournal($journal);
|
$factory->setJournal($journal);
|
||||||
$transaction = $factory->create($account, $euro, $amount);
|
$factory->setAccount($account);
|
||||||
|
$factory->setCurrency($euro);
|
||||||
|
$factory->setReconciled(false);
|
||||||
|
|
||||||
$this->assertNull($transaction);
|
// create positive
|
||||||
|
$transaction = $factory->createPositive($amount, null);
|
||||||
|
|
||||||
|
$this->assertEquals($transaction->account_id, $account->id);
|
||||||
|
$this->assertEquals('10', $transaction->amount);
|
||||||
|
$transaction->forceDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
* @covers \FireflyIII\Factory\TransactionFactory
|
||||||
*/
|
*/
|
||||||
public function testCreatePair(): void
|
public function testCreateNegativeForeign(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
// used objects
|
|
||||||
$withdrawal = $this->getRandomWithdrawal();
|
|
||||||
$asset = $this->getRandomAsset();
|
|
||||||
$expense = $this->getRandomExpense();
|
|
||||||
$currency = TransactionCurrency::whereCode('EUR')->first();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
$accountRepos->shouldReceive('findNull')->withArgs([1])->once()->andReturn($asset);
|
|
||||||
$accountRepos->shouldReceive('findByName')->withArgs(['Some destination', [AccountType::EXPENSE]])->once()->andReturn($expense);
|
|
||||||
|
|
||||||
|
|
||||||
$data = new NullArrayObject(
|
|
||||||
[
|
|
||||||
'source_id' => 1,
|
|
||||||
'destination_name' => 'Some destination',
|
|
||||||
'amount' => '20',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($withdrawal);
|
|
||||||
$pairs = $factory->createPair($data, $currency, null);
|
|
||||||
$first = $pairs->first();
|
|
||||||
$this->assertCount(2, $pairs);
|
|
||||||
$this->assertEquals('-20', $first->amount);
|
|
||||||
$this->assertEquals($currency->id, $first->transaction_currency_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testCreatePairForeign(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
// used objects:
|
|
||||||
$withdrawal = $this->getRandomWithdrawal();
|
|
||||||
$expense = $this->getRandomExpense();
|
|
||||||
$asset = $this->getRandomAsset();
|
|
||||||
$currency = TransactionCurrency::whereCode('EUR')->first();
|
|
||||||
$foreign = TransactionCurrency::whereCode('USD')->first();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
$accountRepos->shouldReceive('findNull')->withArgs([1])->once()->andReturn($asset);
|
|
||||||
$accountRepos->shouldReceive('findByName')->withArgs(['Some destination', [AccountType::EXPENSE]])->once()->andReturn($expense);
|
|
||||||
|
|
||||||
|
|
||||||
$data = new NullArrayObject(
|
|
||||||
[
|
|
||||||
'source_id' => 1,
|
|
||||||
'destination_name' => 'Some destination',
|
|
||||||
'amount' => '20',
|
|
||||||
'foreign_amount' => '20',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($withdrawal);
|
|
||||||
$pairs = $factory->createPair($data, $currency, $foreign);
|
|
||||||
$first = $pairs->first();
|
|
||||||
$this->assertCount(2, $pairs);
|
|
||||||
$this->assertEquals('-20', $first->amount);
|
|
||||||
$this->assertEquals($currency->id, $first->transaction_currency_id);
|
|
||||||
$this->assertEquals($foreign->id, $first->foreign_currency_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To cover everything, test several combinations.
|
|
||||||
*
|
|
||||||
* For the source account, submit a Deposit and an Revenue account ID (this is OK).
|
|
||||||
* Expected result: the same revenue account.
|
|
||||||
*
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testDepositSourceAsseRevenueId(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
// data used in calls.
|
// data used in calls.
|
||||||
$deposit = $this->getRandomDeposit();
|
$journal = $this->getRandomWithdrawal();
|
||||||
$revenue = $this->getRandomRevenue();
|
$account = $this->getRandomAsset();
|
||||||
|
$euro = $this->getEuro();
|
||||||
// mock calls.
|
$dollar = $this->getDollar();
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
$accountRepos->shouldReceive('findNull')->once()->withArgs([$revenue->id])->andReturn($revenue);
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($deposit);
|
|
||||||
|
|
||||||
$result = $factory->getAccount('source', null, $revenue->id, null);
|
|
||||||
$this->assertEquals($revenue->id, $result->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To cover everything, test several combinations.
|
|
||||||
*
|
|
||||||
* For the source account, submit a Deposit and nothing else (this is OK).
|
|
||||||
* Expected result: a cash account
|
|
||||||
*
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testDepositSourceRevenueCash(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
// data used in calls.
|
|
||||||
$deposit = $this->getRandomDeposit();
|
|
||||||
$revenue = $this->getRandomRevenue();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
$accountRepos->shouldReceive('getCashAccount')->once()->andReturn($revenue);
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($deposit);
|
|
||||||
|
|
||||||
$result = $factory->getAccount('source', null, null, null);
|
|
||||||
$this->assertEquals($revenue->name, $result->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To cover everything, test several combinations.
|
|
||||||
*
|
|
||||||
* For the source account, submit a Deposit and an Revenue account name (this is OK).
|
|
||||||
* Expected result: a new revenue account.
|
|
||||||
*
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testDepositSourceRevenueNameNew(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
// data used in calls.
|
|
||||||
$deposit = $this->getRandomDeposit();
|
|
||||||
$name = 'random rev name ' . random_int(1, 100000);
|
|
||||||
$revenue = $this->getRandomRevenue();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
$accountRepos->shouldReceive('findByName')->once()->withArgs([$name, [AccountType::REVENUE]])->andReturnNull();
|
|
||||||
// system will automatically expand search:
|
|
||||||
$accountRepos->shouldReceive('findByName')->once()->withArgs(
|
|
||||||
[$name, [AccountType::REVENUE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE, AccountType::INITIAL_BALANCE,
|
|
||||||
AccountType::RECONCILIATION]]
|
|
||||||
)->andReturnNull();
|
|
||||||
|
|
||||||
// then store new account:
|
|
||||||
$accountRepos->shouldReceive('store')->once()->withArgs(
|
|
||||||
[[
|
|
||||||
'account_type_id' => null,
|
|
||||||
'accountType' => AccountType::REVENUE,
|
|
||||||
'name' => $name,
|
|
||||||
'active' => true,
|
|
||||||
'iban' => null,
|
|
||||||
]]
|
|
||||||
)->andReturn($revenue);
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($deposit);
|
|
||||||
|
|
||||||
$result = $factory->getAccount('source', null, null, $name);
|
|
||||||
$this->assertEquals($revenue->name, $result->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function testDramaBasic(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
$withdrawal = $this->getRandomWithdrawal();
|
|
||||||
$source = $withdrawal->transactions()->where('amount', '<', 0)->first();
|
|
||||||
$dest = $withdrawal->transactions()->where('amount', '>', 0)->first();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($withdrawal);
|
|
||||||
$factory->makeDramaOverAccountTypes($source->account, $dest->account);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function testDramaNotAllowed(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
$withdrawal = $this->getRandomWithdrawal();
|
|
||||||
|
|
||||||
// this is an asset account.
|
|
||||||
$source = $withdrawal->transactions()->where('amount', '<', 0)->first();
|
|
||||||
// so destiny cannot be also asset account
|
|
||||||
$dest = $this->getRandomAsset();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($withdrawal);
|
|
||||||
try {
|
|
||||||
$factory->makeDramaOverAccountTypes($source->account, $dest);
|
|
||||||
} catch (FireflyException $e) {
|
|
||||||
$this->assertEquals(
|
|
||||||
'Journal of type "Withdrawal" has a source account of type "Asset account" and cannot accept a "Asset account"-account as destination, but only accounts of: Expense account, Loan, Debt, Mortgage',
|
|
||||||
$e->getMessage()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testGetAmountBasic(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
$amount = '10';
|
$amount = '10';
|
||||||
// data used in calls.
|
|
||||||
$journal = $this->getRandomWithdrawal();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
/** @var TransactionFactory $factory */
|
||||||
$factory = app(TransactionFactory::class);
|
$factory = app(TransactionFactory::class);
|
||||||
|
|
||||||
|
|
||||||
|
// set details:
|
||||||
$factory->setUser($this->user());
|
$factory->setUser($this->user());
|
||||||
$factory->setJournal($journal);
|
$factory->setJournal($journal);
|
||||||
|
$factory->setAccount($account);
|
||||||
|
$factory->setCurrency($euro);
|
||||||
|
$factory->setForeignCurrency($dollar);
|
||||||
|
$factory->setReconciled(false);
|
||||||
|
|
||||||
$result = $factory->getAmount($amount);
|
// create negative
|
||||||
$this->assertEquals($amount, $result);
|
$transaction = $factory->createNegative($amount, $amount);
|
||||||
|
|
||||||
|
$this->assertEquals($transaction->account_id, $account->id);
|
||||||
|
$this->assertEquals('-10', $transaction->amount);
|
||||||
|
$this->assertEquals('-10', $transaction->foreign_amount);
|
||||||
|
$this->assertEquals($euro->id, $transaction->transaction_currency_id);
|
||||||
|
$this->assertEquals($dollar->id, $transaction->foreign_currency_id);
|
||||||
|
$transaction->forceDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
* @covers \FireflyIII\Factory\TransactionFactory
|
||||||
*/
|
*/
|
||||||
public function testGetAmountNull(): void
|
public function testCreatePositiveForeign(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
$amount = '';
|
|
||||||
// data used in calls.
|
// data used in calls.
|
||||||
$journal = $this->getRandomWithdrawal();
|
$journal = $this->getRandomWithdrawal();
|
||||||
|
$account = $this->getRandomAsset();
|
||||||
// mock calls.
|
$euro = $this->getEuro();
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
$dollar = $this->getDollar();
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($journal);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$factory->getAmount($amount);
|
|
||||||
} catch (FireflyException $e) {
|
|
||||||
$this->assertEquals('The amount cannot be an empty string: ""', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testGetAmountZero(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
$amount = '0.0';
|
|
||||||
// data used in calls.
|
|
||||||
$journal = $this->getRandomWithdrawal();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($journal);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$factory->getAmount($amount);
|
|
||||||
} catch (FireflyException $e) {
|
|
||||||
$this->assertEquals('The amount seems to be zero: "0.0"', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testGetForeignAmountBasic(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
$amount = '10';
|
$amount = '10';
|
||||||
// data used in calls.
|
|
||||||
$journal = $this->getRandomWithdrawal();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
/** @var TransactionFactory $factory */
|
||||||
$factory = app(TransactionFactory::class);
|
$factory = app(TransactionFactory::class);
|
||||||
|
|
||||||
|
|
||||||
|
// set details:
|
||||||
$factory->setUser($this->user());
|
$factory->setUser($this->user());
|
||||||
$factory->setJournal($journal);
|
$factory->setJournal($journal);
|
||||||
|
$factory->setAccount($account);
|
||||||
|
$factory->setCurrency($euro);
|
||||||
|
$factory->setForeignCurrency($dollar);
|
||||||
|
$factory->setReconciled(false);
|
||||||
|
|
||||||
$result = $factory->getForeignAmount($amount);
|
// create positive
|
||||||
$this->assertEquals($amount, $result);
|
$transaction = $factory->createPositive($amount, $amount);
|
||||||
}
|
$this->assertEquals($transaction->account_id, $account->id);
|
||||||
|
$this->assertEquals('10', $transaction->amount);
|
||||||
|
$this->assertEquals('10', $transaction->foreign_amount);
|
||||||
|
$this->assertEquals($euro->id, $transaction->transaction_currency_id);
|
||||||
|
$this->assertEquals($dollar->id, $transaction->foreign_currency_id);
|
||||||
|
|
||||||
/**
|
$transaction->forceDelete();
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testGetForeignAmountEmpty(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
$amount = '';
|
|
||||||
// data used in calls.
|
|
||||||
$journal = $this->getRandomWithdrawal();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($journal);
|
|
||||||
|
|
||||||
$result = $factory->getForeignAmount($amount);
|
|
||||||
$this->assertNull($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testGetForeignAmountNull(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
$amount = null;
|
|
||||||
// data used in calls.
|
|
||||||
$journal = $this->getRandomWithdrawal();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($journal);
|
|
||||||
|
|
||||||
$result = $factory->getForeignAmount($amount);
|
|
||||||
$this->assertNull($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testGetForeignAmountZero(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
$amount = '0.0';
|
|
||||||
// data used in calls.
|
|
||||||
$journal = $this->getRandomWithdrawal();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($journal);
|
|
||||||
|
|
||||||
$result = $factory->getForeignAmount($amount);
|
|
||||||
$this->assertNull($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To cover everything, test several combinations.
|
|
||||||
*
|
|
||||||
* For the source account, submit a Withdrawal and an Asset account ID (this is OK).
|
|
||||||
* Expected result: the same asset account.
|
|
||||||
*
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testWithdrawalSourceAssetId(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
// data used in calls.
|
|
||||||
$withdrawal = $this->getRandomWithdrawal();
|
|
||||||
$asset = $this->getRandomAsset();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
$accountRepos->shouldReceive('findNull')->once()->withArgs([$asset->id])->andReturn($asset);
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($withdrawal);
|
|
||||||
|
|
||||||
$result = $factory->getAccount('source', null, $asset->id, null);
|
|
||||||
$this->assertEquals($asset->id, $result->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To cover everything, test several combinations.
|
|
||||||
*
|
|
||||||
* For the source account, submit a Withdrawal and an Asset account ID (this is OK).
|
|
||||||
* Expected result: find won't return anything so we expect a big fat error.
|
|
||||||
*
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testWithdrawalSourceAssetIdNOK(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
// data used in calls.
|
|
||||||
$withdrawal = $this->getRandomWithdrawal();
|
|
||||||
$asset = $this->getRandomAsset();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
$accountRepos->shouldReceive('findNull')->once()->withArgs([$asset->id])->andReturn($asset);
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($withdrawal);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$factory->getAccount('source', null, $asset->id, null);
|
|
||||||
} catch (FireflyException $e) {
|
|
||||||
$this->assertEquals('TransactionFactory: Cannot create asset account with ID #0 or name "(no name)".', $e->getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* To cover everything, test several combinations.
|
|
||||||
*
|
|
||||||
* For the source account, submit a Withdrawal and an Asset account name (this is OK).
|
|
||||||
* Expected result: the same asset account.
|
|
||||||
*
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testWithdrawalSourceAssetName(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
// data used in calls.
|
|
||||||
$withdrawal = $this->getRandomWithdrawal();
|
|
||||||
$asset = $this->getRandomAsset();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
$accountRepos->shouldReceive('findByName')->once()->withArgs([$asset->name, [AccountType::ASSET]])->andReturn($asset);
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($withdrawal);
|
|
||||||
|
|
||||||
$result = $factory->getAccount('source', null, null, $asset->name);
|
|
||||||
$this->assertEquals($asset->id, $result->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To cover everything, test several combinations.
|
|
||||||
*
|
|
||||||
* For the source account, submit a Withdrawal and an Asset account name (this is OK).
|
|
||||||
* Expected result: the same asset account.
|
|
||||||
*
|
|
||||||
* This will initially return NULL and then search again with all possible types.
|
|
||||||
*
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testWithdrawalSourceAssetName2(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
// data used in calls.
|
|
||||||
$withdrawal = $this->getRandomWithdrawal();
|
|
||||||
$asset = $this->getRandomAsset();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
$accountRepos->shouldReceive('findByName')->once()->withArgs([$asset->name, [AccountType::ASSET]])->andReturnNull();
|
|
||||||
$accountRepos->shouldReceive('findByName')->once()->withArgs(
|
|
||||||
[$asset->name, [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]]
|
|
||||||
)->andReturn($asset);
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($withdrawal);
|
|
||||||
|
|
||||||
$result = $factory->getAccount('source', null, null, $asset->name);
|
|
||||||
$this->assertEquals($asset->id, $result->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To cover everything, test several combinations.
|
|
||||||
*
|
|
||||||
* For the source account, submit a Withdrawal and an Asset account object (this is OK).
|
|
||||||
* Expected result: the same asset account.
|
|
||||||
*
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testWithdrawalSourceAssetObj(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
// data used in calls.
|
|
||||||
$withdrawal = $this->getRandomWithdrawal();
|
|
||||||
$asset = $this->getRandomAsset();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($withdrawal);
|
|
||||||
|
|
||||||
$result = $factory->getAccount('source', $asset, null, null);
|
|
||||||
$this->assertEquals($asset->id, $result->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To cover everything, test several combinations.
|
|
||||||
*
|
|
||||||
* For the source account, submit a Withdrawal and an Expense account object (this is not OK).
|
|
||||||
* Expected result: big fat error because of missing data.
|
|
||||||
*
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testWithdrawalSourceAssetObjNOK(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
// data used in calls.
|
|
||||||
$withdrawal = $this->getRandomWithdrawal();
|
|
||||||
$expense = $this->getRandomExpense();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($withdrawal);
|
|
||||||
try {
|
|
||||||
$factory->getAccount('source', $expense, null, null);
|
|
||||||
} catch (FireflyException $e) {
|
|
||||||
$this->assertEquals('TransactionFactory: Cannot create asset account with ID #0 or name "(no name)".', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To cover everything, test several combinations.
|
|
||||||
*
|
|
||||||
* For the source account, submit a Withdrawal and Loan account object (this is OK).
|
|
||||||
* Expected result: the same loan account.
|
|
||||||
*
|
|
||||||
* @covers \FireflyIII\Factory\TransactionFactory
|
|
||||||
*/
|
|
||||||
public function testWithdrawalSourceLoanObj(): void
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
// mock classes
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
|
|
||||||
// data used in calls.
|
|
||||||
$withdrawal = $this->getRandomWithdrawal();
|
|
||||||
$loan = $this->getRandomLoan();
|
|
||||||
|
|
||||||
// mock calls.
|
|
||||||
$accountRepos->shouldReceive('setUser')->once();
|
|
||||||
|
|
||||||
/** @var TransactionFactory $factory */
|
|
||||||
$factory = app(TransactionFactory::class);
|
|
||||||
$factory->setUser($this->user());
|
|
||||||
$factory->setJournal($withdrawal);
|
|
||||||
|
|
||||||
$result = $factory->getAccount('source', $loan, null, null);
|
|
||||||
$this->assertEquals($loan->id, $result->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -25,7 +25,6 @@ namespace Tests\Unit\Factory;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Factory\TransactionJournalMetaFactory;
|
use FireflyIII\Factory\TransactionJournalMetaFactory;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Models\TransactionJournalMeta;
|
use FireflyIII\Models\TransactionJournalMeta;
|
||||||
use Log;
|
use Log;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
@@ -50,14 +49,10 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testUpdateOrCreateBasic(): void
|
public function testUpdateOrCreateBasic(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
$withdrawal = $this->getRandomWithdrawal();
|
||||||
|
$withdrawal->transactionJournalMeta()->delete();
|
||||||
return;
|
|
||||||
/** @var TransactionJournal $journal */
|
|
||||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
|
|
||||||
$journal->transactionJournalMeta()->delete();
|
|
||||||
$set = [
|
$set = [
|
||||||
'journal' => $journal,
|
'journal' => $withdrawal,
|
||||||
'name' => 'hello',
|
'name' => 'hello',
|
||||||
'data' => 'bye!',
|
'data' => 'bye!',
|
||||||
];
|
];
|
||||||
@@ -65,7 +60,7 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
|||||||
$factory = app(TransactionJournalMetaFactory::class);
|
$factory = app(TransactionJournalMetaFactory::class);
|
||||||
$result = $factory->updateOrCreate($set);
|
$result = $factory->updateOrCreate($set);
|
||||||
|
|
||||||
$this->assertEquals(1, $journal->transactionJournalMeta()->count());
|
$this->assertEquals(1, $withdrawal->transactionJournalMeta()->count());
|
||||||
$this->assertEquals($set['data'], $result->data);
|
$this->assertEquals($set['data'], $result->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,14 +69,10 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testUpdateOrCreateDate(): void
|
public function testUpdateOrCreateDate(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
$withdrawal = $this->getRandomWithdrawal();
|
||||||
|
$withdrawal->transactionJournalMeta()->delete();
|
||||||
return;
|
|
||||||
/** @var TransactionJournal $journal */
|
|
||||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
|
|
||||||
$journal->transactionJournalMeta()->delete();
|
|
||||||
$set = [
|
$set = [
|
||||||
'journal' => $journal,
|
'journal' => $withdrawal,
|
||||||
'name' => 'hello',
|
'name' => 'hello',
|
||||||
'data' => new Carbon('2012-01-01'),
|
'data' => new Carbon('2012-01-01'),
|
||||||
];
|
];
|
||||||
@@ -89,7 +80,7 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
|||||||
$factory = app(TransactionJournalMetaFactory::class);
|
$factory = app(TransactionJournalMetaFactory::class);
|
||||||
$result = $factory->updateOrCreate($set);
|
$result = $factory->updateOrCreate($set);
|
||||||
|
|
||||||
$this->assertEquals(1, $journal->transactionJournalMeta()->count());
|
$this->assertEquals(1, $withdrawal->transactionJournalMeta()->count());
|
||||||
$this->assertEquals($set['data']->toW3cString(), $result->data);
|
$this->assertEquals($set['data']->toW3cString(), $result->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,22 +89,18 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testUpdateOrCreateDeleteExisting(): void
|
public function testUpdateOrCreateDeleteExisting(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
$withdrawal = $this->getRandomWithdrawal();
|
||||||
|
TransactionJournalMeta::create(
|
||||||
return;
|
|
||||||
/** @var TransactionJournal $journal */
|
|
||||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 3)->first();
|
|
||||||
$meta = TransactionJournalMeta::create(
|
|
||||||
[
|
[
|
||||||
'transaction_journal_id' => $journal->id,
|
'transaction_journal_id' => $withdrawal->id,
|
||||||
'name' => 'hello',
|
'name' => 'hello',
|
||||||
'data' => 'bye!',
|
'data' => 'bye!',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$count = $journal->transactionJournalMeta()->count();
|
$count = $withdrawal->transactionJournalMeta()->count();
|
||||||
|
|
||||||
$set = [
|
$set = [
|
||||||
'journal' => $journal,
|
'journal' => $withdrawal,
|
||||||
'name' => 'hello',
|
'name' => 'hello',
|
||||||
'data' => null,
|
'data' => null,
|
||||||
];
|
];
|
||||||
@@ -121,7 +108,7 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
|||||||
$factory = app(TransactionJournalMetaFactory::class);
|
$factory = app(TransactionJournalMetaFactory::class);
|
||||||
$factory->updateOrCreate($set);
|
$factory->updateOrCreate($set);
|
||||||
|
|
||||||
$this->assertEquals($count - 1, $journal->transactionJournalMeta()->count());
|
$this->assertEquals($count - 1, $withdrawal->transactionJournalMeta()->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -129,14 +116,10 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testUpdateOrCreateEmpty(): void
|
public function testUpdateOrCreateEmpty(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
$withdrawal = $this->getRandomWithdrawal();
|
||||||
|
$withdrawal->transactionJournalMeta()->delete();
|
||||||
return;
|
|
||||||
/** @var TransactionJournal $journal */
|
|
||||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
|
|
||||||
$journal->transactionJournalMeta()->delete();
|
|
||||||
$set = [
|
$set = [
|
||||||
'journal' => $journal,
|
'journal' => $withdrawal,
|
||||||
'name' => 'hello',
|
'name' => 'hello',
|
||||||
'data' => '',
|
'data' => '',
|
||||||
];
|
];
|
||||||
@@ -144,7 +127,7 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
|||||||
$factory = app(TransactionJournalMetaFactory::class);
|
$factory = app(TransactionJournalMetaFactory::class);
|
||||||
$result = $factory->updateOrCreate($set);
|
$result = $factory->updateOrCreate($set);
|
||||||
|
|
||||||
$this->assertEquals(0, $journal->transactionJournalMeta()->count());
|
$this->assertEquals(0, $withdrawal->transactionJournalMeta()->count());
|
||||||
$this->assertNull($result);
|
$this->assertNull($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,14 +136,10 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testUpdateOrCreateExistingEmpty(): void
|
public function testUpdateOrCreateExistingEmpty(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
$withdrawal = $this->getRandomWithdrawal();
|
||||||
|
$withdrawal->transactionJournalMeta()->delete();
|
||||||
return;
|
|
||||||
/** @var TransactionJournal $journal */
|
|
||||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
|
|
||||||
$journal->transactionJournalMeta()->delete();
|
|
||||||
$set = [
|
$set = [
|
||||||
'journal' => $journal,
|
'journal' => $withdrawal,
|
||||||
'name' => 'hello',
|
'name' => 'hello',
|
||||||
'data' => 'SomeData',
|
'data' => 'SomeData',
|
||||||
];
|
];
|
||||||
@@ -168,12 +147,12 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
|||||||
$factory = app(TransactionJournalMetaFactory::class);
|
$factory = app(TransactionJournalMetaFactory::class);
|
||||||
$result = $factory->updateOrCreate($set);
|
$result = $factory->updateOrCreate($set);
|
||||||
|
|
||||||
$this->assertEquals(1, $journal->transactionJournalMeta()->count());
|
$this->assertEquals(1, $withdrawal->transactionJournalMeta()->count());
|
||||||
$this->assertNotNull($result);
|
$this->assertNotNull($result);
|
||||||
|
|
||||||
// overrule with empty entry:
|
// overrule with empty entry:
|
||||||
$set = [
|
$set = [
|
||||||
'journal' => $journal,
|
'journal' => $withdrawal,
|
||||||
'name' => 'hello',
|
'name' => 'hello',
|
||||||
'data' => '',
|
'data' => '',
|
||||||
];
|
];
|
||||||
@@ -181,7 +160,7 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
|||||||
$factory = app(TransactionJournalMetaFactory::class);
|
$factory = app(TransactionJournalMetaFactory::class);
|
||||||
$result = $factory->updateOrCreate($set);
|
$result = $factory->updateOrCreate($set);
|
||||||
|
|
||||||
$this->assertEquals(0, $journal->transactionJournalMeta()->count());
|
$this->assertEquals(0, $withdrawal->transactionJournalMeta()->count());
|
||||||
$this->assertNull($result);
|
$this->assertNull($result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -57,7 +57,7 @@ class BunqJobConfigurationTest extends TestCase
|
|||||||
$jobRepos->shouldReceive('setUser')->once();
|
$jobRepos->shouldReceive('setUser')->once();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'bunq_jc_A' . random_int(1, 100000);
|
$job->key = 'bunq_jc_A' . $this->randomInt();
|
||||||
$job->status = 'new';
|
$job->status = 'new';
|
||||||
$job->stage = 'new';
|
$job->stage = 'new';
|
||||||
$job->provider = 'bunq';
|
$job->provider = 'bunq';
|
||||||
@@ -154,7 +154,7 @@ class BunqJobConfigurationTest extends TestCase
|
|||||||
$jobRepos->shouldReceive('setUser')->once();
|
$jobRepos->shouldReceive('setUser')->once();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'bunq_jc_E' . random_int(1, 100000);
|
$job->key = 'bunq_jc_E' . $this->randomInt();
|
||||||
$job->status = 'new';
|
$job->status = 'new';
|
||||||
$job->stage = 'choose-accounts';
|
$job->stage = 'choose-accounts';
|
||||||
$job->provider = 'bunq';
|
$job->provider = 'bunq';
|
||||||
|
@@ -58,7 +58,7 @@ class YnabJobConfigurationTest extends TestCase
|
|||||||
$jobRepos->shouldReceive('setUser')->once();
|
$jobRepos->shouldReceive('setUser')->once();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'ynab_jc_A' . random_int(1, 100000);
|
$job->key = 'ynab_jc_A' . $this->randomInt();
|
||||||
$job->status = 'new';
|
$job->status = 'new';
|
||||||
$job->stage = 'new';
|
$job->stage = 'new';
|
||||||
$job->provider = 'ynab';
|
$job->provider = 'ynab';
|
||||||
@@ -155,7 +155,7 @@ class YnabJobConfigurationTest extends TestCase
|
|||||||
$jobRepos->shouldReceive('setUser')->once();
|
$jobRepos->shouldReceive('setUser')->once();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'ynab_jc_E' . random_int(1, 100000);
|
$job->key = 'ynab_jc_E' . $this->randomInt();
|
||||||
$job->status = 'new';
|
$job->status = 'new';
|
||||||
$job->stage = 'new';
|
$job->stage = 'new';
|
||||||
$job->provider = 'ynab';
|
$job->provider = 'ynab';
|
||||||
|
@@ -46,220 +46,220 @@ class TransactionUpdateServiceTest extends TestCase
|
|||||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
// * @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
||||||
*/
|
// */
|
||||||
public function testReconcile(): void
|
// public function testReconcile(): void
|
||||||
{
|
// {
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
// $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||||
|
//
|
||||||
return;
|
// return;
|
||||||
$transaction = $this->user()->transactions()->inRandomOrder()->first();
|
// $transaction = $this->user()->transactions()->inRandomOrder()->first();
|
||||||
|
//
|
||||||
/** @var TransactionUpdateService $service */
|
// /** @var TransactionUpdateService $service */
|
||||||
$service = app(TransactionUpdateService::class);
|
// $service = app(TransactionUpdateService::class);
|
||||||
$service->setUser($this->user());
|
// $service->setUser($this->user());
|
||||||
$result = $service->reconcile($transaction->id);
|
// $result = $service->reconcile($transaction->id);
|
||||||
$this->assertEquals($result->id, $transaction->id);
|
// $this->assertEquals($result->id, $transaction->id);
|
||||||
$this->assertEquals(true, $result->reconciled);
|
// $this->assertEquals(true, $result->reconciled);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
// * @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
||||||
* @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
// * @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
||||||
*/
|
// */
|
||||||
public function testReconcileNull(): void
|
// public function testReconcileNull(): void
|
||||||
{
|
// {
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
// $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||||
|
//
|
||||||
return;
|
// return;
|
||||||
/** @var TransactionUpdateService $service */
|
// /** @var TransactionUpdateService $service */
|
||||||
$service = app(TransactionUpdateService::class);
|
// $service = app(TransactionUpdateService::class);
|
||||||
$service->setUser($this->user());
|
// $service->setUser($this->user());
|
||||||
$result = $service->reconcile(-1);
|
// $result = $service->reconcile(-1);
|
||||||
$this->assertNull($result);
|
// $this->assertNull($result);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
// * @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
||||||
* @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
// * @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
||||||
*/
|
// */
|
||||||
public function testUpdateBudget(): void
|
// public function testUpdateBudget(): void
|
||||||
{
|
// {
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
// $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||||
|
//
|
||||||
return;
|
// return;
|
||||||
/** @var Transaction $source */
|
// /** @var Transaction $source */
|
||||||
$source = $this->user()->transactions()->where('amount', '>', 0)->inRandomOrder()->first();
|
// $source = $this->user()->transactions()->where('amount', '>', 0)->inRandomOrder()->first();
|
||||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
// $budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||||
|
//
|
||||||
$factory = $this->mock(BudgetFactory::class);
|
// $factory = $this->mock(BudgetFactory::class);
|
||||||
$factory->shouldReceive('setUser');
|
// $factory->shouldReceive('setUser');
|
||||||
$factory->shouldReceive('find')->andReturn($budget);
|
// $factory->shouldReceive('find')->andReturn($budget);
|
||||||
|
//
|
||||||
/** @var TransactionUpdateService $service */
|
// /** @var TransactionUpdateService $service */
|
||||||
$service = app(TransactionUpdateService::class);
|
// $service = app(TransactionUpdateService::class);
|
||||||
$service->setUser($this->user());
|
// $service->setUser($this->user());
|
||||||
$result = $service->updateBudget($source, $budget->id);
|
// $result = $service->updateBudget($source, $budget->id);
|
||||||
|
//
|
||||||
$this->assertEquals(1, $result->budgets()->count());
|
// $this->assertEquals(1, $result->budgets()->count());
|
||||||
$this->assertEquals($budget->name, $result->budgets()->first()->name);
|
// $this->assertEquals($budget->name, $result->budgets()->first()->name);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
// * @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
||||||
* @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
// * @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
||||||
*/
|
// */
|
||||||
public function testUpdateCategory(): void
|
// public function testUpdateCategory(): void
|
||||||
{
|
// {
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
// $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||||
|
//
|
||||||
return;
|
// return;
|
||||||
/** @var Transaction $source */
|
// /** @var Transaction $source */
|
||||||
$source = $this->user()->transactions()->where('amount', '>', 0)->inRandomOrder()->first();
|
// $source = $this->user()->transactions()->where('amount', '>', 0)->inRandomOrder()->first();
|
||||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
// $category = $this->user()->categories()->inRandomOrder()->first();
|
||||||
|
//
|
||||||
$factory = $this->mock(CategoryFactory::class);
|
// $factory = $this->mock(CategoryFactory::class);
|
||||||
$factory->shouldReceive('setUser');
|
// $factory->shouldReceive('setUser');
|
||||||
$factory->shouldReceive('findOrCreate')->andReturn($category);
|
// $factory->shouldReceive('findOrCreate')->andReturn($category);
|
||||||
|
//
|
||||||
/** @var TransactionUpdateService $service */
|
// /** @var TransactionUpdateService $service */
|
||||||
$service = app(TransactionUpdateService::class);
|
// $service = app(TransactionUpdateService::class);
|
||||||
$service->setUser($this->user());
|
// $service->setUser($this->user());
|
||||||
$result = $service->updateCategory($source, $category->name);
|
// $result = $service->updateCategory($source, $category->name);
|
||||||
|
//
|
||||||
$this->assertEquals(1, $result->categories()->count());
|
// $this->assertEquals(1, $result->categories()->count());
|
||||||
$this->assertEquals($category->name, $result->categories()->first()->name);
|
// $this->assertEquals($category->name, $result->categories()->first()->name);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
// * @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
||||||
* @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
// * @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
||||||
*/
|
// */
|
||||||
public function testUpdateDestinationBasic(): void
|
// public function testUpdateDestinationBasic(): void
|
||||||
{
|
// {
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
// $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||||
|
//
|
||||||
return;
|
// return;
|
||||||
/** @var Transaction $source */
|
// /** @var Transaction $source */
|
||||||
$source = $this->user()->transactions()->where('amount', '>', 0)->inRandomOrder()->first();
|
// $source = $this->user()->transactions()->where('amount', '>', 0)->inRandomOrder()->first();
|
||||||
$data = [
|
// $data = [
|
||||||
'currency_id' => 1,
|
// 'currency_id' => 1,
|
||||||
'currency_code' => null,
|
// 'currency_code' => null,
|
||||||
'description' => 'Some new description',
|
// 'description' => 'Some new description',
|
||||||
'reconciled' => false,
|
// 'reconciled' => false,
|
||||||
'foreign_amount' => null,
|
// 'foreign_amount' => null,
|
||||||
'budget_id' => null,
|
// 'budget_id' => null,
|
||||||
'budget_name' => null,
|
// 'budget_name' => null,
|
||||||
'destination_id' => (int)$source->account_id,
|
// 'destination_id' => (int)$source->account_id,
|
||||||
'destination_name' => null,
|
// 'destination_name' => null,
|
||||||
'category_id' => null,
|
// 'category_id' => null,
|
||||||
'category_name' => null,
|
// 'category_name' => null,
|
||||||
'amount' => $source->amount,
|
// 'amount' => $source->amount,
|
||||||
'foreign_currency_id' => null,
|
// 'foreign_currency_id' => null,
|
||||||
'foreign_currency_code' => null,
|
// 'foreign_currency_code' => null,
|
||||||
];
|
// ];
|
||||||
|
//
|
||||||
// mock repository:
|
// // mock repository:
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
// $accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$accountRepos->shouldReceive('setUser');
|
// $accountRepos->shouldReceive('setUser');
|
||||||
$accountRepos->shouldReceive('findNull')->andReturn($source->account);
|
// $accountRepos->shouldReceive('findNull')->andReturn($source->account);
|
||||||
|
//
|
||||||
/** @var TransactionUpdateService $service */
|
// /** @var TransactionUpdateService $service */
|
||||||
$service = app(TransactionUpdateService::class);
|
// $service = app(TransactionUpdateService::class);
|
||||||
$service->setUser($this->user());
|
// $service->setUser($this->user());
|
||||||
$result = $service->update($source, $data);
|
// $result = $service->update($source, $data);
|
||||||
|
//
|
||||||
$this->assertEquals($source->id, $result->id);
|
// $this->assertEquals($source->id, $result->id);
|
||||||
$this->assertEquals($result->description, $data['description']);
|
// $this->assertEquals($result->description, $data['description']);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
// * @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
||||||
* @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
// * @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
||||||
*/
|
// */
|
||||||
public function testUpdateDestinationForeign(): void
|
// public function testUpdateDestinationForeign(): void
|
||||||
{
|
// {
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
// $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||||
|
//
|
||||||
return;
|
// return;
|
||||||
/** @var Transaction $source */
|
// /** @var Transaction $source */
|
||||||
$source = $this->user()->transactions()->where('amount', '>', 0)->inRandomOrder()->first();
|
// $source = $this->user()->transactions()->where('amount', '>', 0)->inRandomOrder()->first();
|
||||||
$data = [
|
// $data = [
|
||||||
'currency_id' => 1,
|
// 'currency_id' => 1,
|
||||||
'currency_code' => null,
|
// 'currency_code' => null,
|
||||||
'description' => 'Some new description',
|
// 'description' => 'Some new description',
|
||||||
'reconciled' => false,
|
// 'reconciled' => false,
|
||||||
'foreign_amount' => '12.34',
|
// 'foreign_amount' => '12.34',
|
||||||
'budget_id' => null,
|
// 'budget_id' => null,
|
||||||
'budget_name' => null,
|
// 'budget_name' => null,
|
||||||
'destination_id' => (int)$source->account_id,
|
// 'destination_id' => (int)$source->account_id,
|
||||||
'destination_name' => null,
|
// 'destination_name' => null,
|
||||||
'category_id' => null,
|
// 'category_id' => null,
|
||||||
'category_name' => null,
|
// 'category_name' => null,
|
||||||
'amount' => $source->amount,
|
// 'amount' => $source->amount,
|
||||||
'foreign_currency_id' => 2,
|
// 'foreign_currency_id' => 2,
|
||||||
'foreign_currency_code' => null,
|
// 'foreign_currency_code' => null,
|
||||||
];
|
// ];
|
||||||
|
//
|
||||||
// mock repository:
|
// // mock repository:
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
// $accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$accountRepos->shouldReceive('setUser');
|
// $accountRepos->shouldReceive('setUser');
|
||||||
$accountRepos->shouldReceive('findNull')->andReturn($source->account);
|
// $accountRepos->shouldReceive('findNull')->andReturn($source->account);
|
||||||
|
//
|
||||||
/** @var TransactionUpdateService $service */
|
// /** @var TransactionUpdateService $service */
|
||||||
$service = app(TransactionUpdateService::class);
|
// $service = app(TransactionUpdateService::class);
|
||||||
$service->setUser($this->user());
|
// $service->setUser($this->user());
|
||||||
$result = $service->update($source, $data);
|
// $result = $service->update($source, $data);
|
||||||
|
//
|
||||||
|
//
|
||||||
$this->assertEquals($source->id, $result->id);
|
// $this->assertEquals($source->id, $result->id);
|
||||||
$this->assertEquals($result->description, $data['description']);
|
// $this->assertEquals($result->description, $data['description']);
|
||||||
$this->assertEquals($data['foreign_amount'], $result->foreign_amount);
|
// $this->assertEquals($data['foreign_amount'], $result->foreign_amount);
|
||||||
$this->assertEquals($data['foreign_currency_id'], $result->foreign_currency_id);
|
// $this->assertEquals($data['foreign_currency_id'], $result->foreign_currency_id);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
// * @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
||||||
* @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
// * @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
||||||
*/
|
// */
|
||||||
public function testUpdateSourceBasic(): void
|
// public function testUpdateSourceBasic(): void
|
||||||
{
|
// {
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
// $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||||
|
//
|
||||||
return;
|
// return;
|
||||||
/** @var Transaction $source */
|
// /** @var Transaction $source */
|
||||||
$source = $this->user()->transactions()->where('amount', '<', 0)->inRandomOrder()->first();
|
// $source = $this->user()->transactions()->where('amount', '<', 0)->inRandomOrder()->first();
|
||||||
$data = [
|
// $data = [
|
||||||
'currency_id' => 1,
|
// 'currency_id' => 1,
|
||||||
'currency_code' => null,
|
// 'currency_code' => null,
|
||||||
'description' => 'Some new description',
|
// 'description' => 'Some new description',
|
||||||
'reconciled' => false,
|
// 'reconciled' => false,
|
||||||
'foreign_amount' => null,
|
// 'foreign_amount' => null,
|
||||||
'budget_id' => null,
|
// 'budget_id' => null,
|
||||||
'budget_name' => null,
|
// 'budget_name' => null,
|
||||||
'source_id' => (int)$source->account_id,
|
// 'source_id' => (int)$source->account_id,
|
||||||
'source_name' => null,
|
// 'source_name' => null,
|
||||||
'category_id' => null,
|
// 'category_id' => null,
|
||||||
'category_name' => null,
|
// 'category_name' => null,
|
||||||
'amount' => $source->amount,
|
// 'amount' => $source->amount,
|
||||||
'foreign_currency_id' => null,
|
// 'foreign_currency_id' => null,
|
||||||
'foreign_currency_code' => null,
|
// 'foreign_currency_code' => null,
|
||||||
];
|
// ];
|
||||||
|
//
|
||||||
// mock repository:
|
// // mock repository:
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
// $accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$accountRepos->shouldReceive('setUser');
|
// $accountRepos->shouldReceive('setUser');
|
||||||
$accountRepos->shouldReceive('findNull')->andReturn($source->account);
|
// $accountRepos->shouldReceive('findNull')->andReturn($source->account);
|
||||||
|
//
|
||||||
/** @var TransactionUpdateService $service */
|
// /** @var TransactionUpdateService $service */
|
||||||
$service = app(TransactionUpdateService::class);
|
// $service = app(TransactionUpdateService::class);
|
||||||
$service->setUser($this->user());
|
// $service->setUser($this->user());
|
||||||
$result = $service->update($source, $data);
|
// $result = $service->update($source, $data);
|
||||||
|
//
|
||||||
$this->assertEquals($source->id, $result->id);
|
// $this->assertEquals($source->id, $result->id);
|
||||||
$this->assertEquals($result->description, $data['description']);
|
// $this->assertEquals($result->description, $data['description']);
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
@@ -123,7 +123,7 @@ class StageImportDataHandlerTest extends TestCase
|
|||||||
$revenue = $this->user()->accounts()->where('account_type_id', 5)->first();
|
$revenue = $this->user()->accounts()->where('account_type_id', 5)->first();
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
$job->key = 'sid_a__' . random_int(1, 100000);
|
$job->key = 'sid_a__' . $this->randomInt();
|
||||||
$job->status = 'new';
|
$job->status = 'new';
|
||||||
$job->stage = 'new';
|
$job->stage = 'new';
|
||||||
$job->provider = 'spectre';
|
$job->provider = 'spectre';
|
||||||
|
Reference in New Issue
Block a user