Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Update tests
James Cole049c93465aba
diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.phpindex 8c06e1e63c..26e3a5c5e0 100644--- a/app/Factory/AccountFactory.php+++ b/app/Factory/AccountFactory.php@@ -194,7 +194,8 @@ class AccountFactory/** @var array $types */$types = config('firefly.accountTypeByIdentifier.' . $accountType) ?? [];if (\count($types) > 0) {- $result = AccountType::whereIn('types', $types)->first();+ Log::debug(sprintf('%d accounts in list from config', \count($types)), $types);+ $result = AccountType::whereIn('type', $types)->first();}if (null === $result && null !== $accountType) {// try as full name:diff --git a/changelog.md b/changelog.mdindex 121443f5bf..e2ed3349f7 100644--- a/changelog.md+++ b/changelog.md@@ -2,6 +2,14 @@All notable changes to this project will be documented in this file.This project adheres to [Semantic Versioning](http://semver.org/).+4.7.6+- Only PHP7.2 as of the next release on October 1st.+- New liability feature. Does not do much yet. Tell me what you need while I develop:+-- transactions to / from+-- creation of liability: where is the money? move to asset? away?+-- what to do with interest?++## [4.7.5.3] - 2017-07-28### Added- Many updated French translations thanks to [@bubka](https://crowdin.com/profile/bubka).diff --git a/tests/Api/V1/Controllers/JournalLinkControllerTest.php b/tests/Api/V1/Controllers/JournalLinkControllerTest.phpindex 858f252c2f..069b9b5813 100644--- a/tests/Api/V1/Controllers/JournalLinkControllerTest.php+++ b/tests/Api/V1/Controllers/JournalLinkControllerTest.php@@ -316,7 +316,7 @@ class JournalLinkControllerTest extends TestCase$collector->shouldReceive('getJournals')->andReturn(new Collection([$transaction]));$journalRepos->shouldReceive('findNull')->andReturn(null);- $repository->shouldReceive('updateLink')->once()->andReturn($journalLink);+ //$repository->shouldReceive('updateLink')->once()->andReturn($journalLink);// data to submit$data = [diff --git a/tests/Feature/Controllers/Account/EditControllerTest.php b/tests/Feature/Controllers/Account/EditControllerTest.phpindex 8e567f0527..2dd3cbcde3 100644--- a/tests/Feature/Controllers/Account/EditControllerTest.php+++ b/tests/Feature/Controllers/Account/EditControllerTest.php@@ -25,6 +25,7 @@ namespace Tests\Feature\Controllers\Account;use Amount;+use FireflyIII\Models\AccountType;use FireflyIII\Models\Note;use FireflyIII\Models\TransactionCurrency;use FireflyIII\Models\TransactionJournal;@@ -70,6 +71,15 @@ class EditControllerTest extends TestCase$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'ccType'])->andReturn('');$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'ccMonthlyPaymentDate'])->andReturn('');$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'BIC'])->andReturn('BIC');+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'interest'])->andReturn('1');+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'interest_period'])->andReturn('monthly');++ // get all types:+ $accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Debt'])->andReturn(AccountType::find(11))->once();+ $accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Loan'])->andReturn(AccountType::find(9))->once();+ $accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Mortgage'])->andReturn(AccountType::find(12))->once();+ $accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Credit card'])->andReturn(AccountType::find(13))->once();+$this->be($this->user());$account = $this->user()->accounts()->where('account_type_id', 3)->whereNull('deleted_at')->first();@@ -103,6 +113,14 @@ class EditControllerTest extends TestCase$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'ccType'])->andReturn('');$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'ccMonthlyPaymentDate'])->andReturn('');$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'BIC'])->andReturn('BIC');+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'interest'])->andReturn('1');+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'interest_period'])->andReturn('monthly');++ // get all types:+ $accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Debt'])->andReturn(AccountType::find(11))->once();+ $accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Loan'])->andReturn(AccountType::find(9))->once();+ $accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Mortgage'])->andReturn(AccountType::find(12))->once();+ $accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Credit card'])->andReturn(AccountType::find(13))->once();$this->be($this->user());$account = $this->user()->accounts()->where('account_type_id', 3)->whereNull('deleted_at')->first();diff --git a/tests/Feature/Controllers/Account/IndexControllerTest.php b/tests/Feature/Controllers/Account/IndexControllerTest.phpindex f8aa6a9ae9..7dfc39e66f 100644--- a/tests/Feature/Controllers/Account/IndexControllerTest.php+++ b/tests/Feature/Controllers/Account/IndexControllerTest.php@@ -74,6 +74,9 @@ class IndexControllerTest extends TestCaseSteam::shouldReceive('balancesByAccounts')->andReturn([$account->id => '100']);Steam::shouldReceive('getLastActivities')->andReturn([]);+ $repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'interest'])->andReturn('1');+ $repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'interest_period'])->andReturn('monthly');+$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountNumber'])->andReturn('123');$this->be($this->user());diff --git a/tests/Feature/Controllers/BillControllerTest.php b/tests/Feature/Controllers/BillControllerTest.phpindex 67a2468328..8a29efb42a 100644--- a/tests/Feature/Controllers/BillControllerTest.php+++ b/tests/Feature/Controllers/BillControllerTest.php@@ -260,8 +260,7 @@ class BillControllerTest extends TestCase$repository->shouldReceive('store')->andReturn($bill);$attachHelper->shouldReceive('saveAttachmentsForModel');$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);- $ruleGroupRepos->shouldReceive('count')->andReturn(1);- $ruleGroupRepos->shouldReceive('getActiveGroups')->andReturn(new Collection([RuleGroup::first()]))->once();+$data = ['name' => 'New Bill ' . random_int(1000, 9999),'amount_min' => '100',@@ -296,8 +295,6 @@ class BillControllerTest extends TestCase$repository->shouldReceive('store')->andReturn($bill);$attachHelper->shouldReceive('saveAttachmentsForModel');$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);- $ruleGroupRepos->shouldReceive('count')->andReturn(1);- $ruleGroupRepos->shouldReceive('getActiveGroups')->andReturn(new Collection([RuleGroup::first()]))->once();$data = ['name' => 'New Bill ' . random_int(1000, 9999),@@ -333,8 +330,6 @@ class BillControllerTest extends TestCase$repository->shouldReceive('store')->andReturn(new Bill);$attachHelper->shouldReceive('saveAttachmentsForModel');$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);- $ruleGroupRepos->shouldReceive('count')->andReturn(0);- $ruleGroupRepos->shouldReceive('store')->once()->withArgs([['title' => 'Rule group for bills','description'=> 'A special rule group for all the rules that involve bills.']])->andReturn(RuleGroup::first());$data = ['name' => 'New Bill ' . random_int(1000, 9999),diff --git a/tests/Feature/Controllers/Rule/CreateControllerTest.php b/tests/Feature/Controllers/Rule/CreateControllerTest.phpindex f41453df93..87f54a9436 100644--- a/tests/Feature/Controllers/Rule/CreateControllerTest.php+++ b/tests/Feature/Controllers/Rule/CreateControllerTest.php@@ -62,26 +62,6 @@ class CreateControllerTest extends TestCase$response = $this->get(route('rules.create', [1]));$response->assertStatus(200);$response->assertSee('<ol class="breadcrumb">');- $response->assertViewHas('returnToBill', false);- $response->assertViewHas('bill', null);- }-- /**- * @covers \FireflyIII\Http\Controllers\Rule\CreateController- */- public function testCreateBill(): void- {- // mock stuff- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $billRepos = $this->mock(BillRepositoryInterface::class);- $journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);- $billRepos->shouldReceive('find')->withArgs([1])->andReturn(Bill::find(1))->once();-- $this->be($this->user());- $response = $this->get(route('rules.create', [1]) . '?return=true&fromBill=1');- $response->assertStatus(200);- $response->assertSee('<ol class="breadcrumb">');- $response->assertViewHas('returnToBill', true);}/**@@ -109,24 +89,6 @@ class CreateControllerTest extends TestCase$response->assertSee('<ol class="breadcrumb">');}- /**- * @covers \FireflyIII\Http\Controllers\Rule\CreateController- */- public function testCreateReturn(): void- {- // mock stuff- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $billRepos = $this->mock(BillRepositoryInterface::class);- $journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);-- $this->be($this->user());- $response = $this->get(route('rules.create', [1]) . '?return=true');- $response->assertStatus(200);- $response->assertSee('<ol class="breadcrumb">');- $response->assertViewHas('returnToBill', true);- }--/*** @covers \FireflyIII\Http\Controllers\Rule\CreateController* @covers \FireflyIII\Http\Requests\RuleFormRequestdiff --git a/tests/Feature/Controllers/Rule/SelectControllerTest.php b/tests/Feature/Controllers/Rule/SelectControllerTest.phpindex 87cca71aee..7b5754c0da 100644--- a/tests/Feature/Controllers/Rule/SelectControllerTest.php+++ b/tests/Feature/Controllers/Rule/SelectControllerTest.php@@ -103,9 +103,11 @@ class SelectControllerTest extends TestCasepublic function testTestTriggers(): void{$data = [- 'rule-trigger' => ['description_is'],- 'rule-trigger-value' => ['Bla bla'],- 'rule-trigger-stop' => ['1'],+ 'rule_triggers' => [+ 'name' => 'description',+ 'value' => 'Bla bla',+ 'stop_processing' => 1,+ ],];// mock stuff@@ -165,9 +167,11 @@ class SelectControllerTest extends TestCasepublic function testTestTriggersMax(): void{$data = [- 'rule-trigger' => ['description_is'],- 'rule-trigger-value' => ['Bla bla'],- 'rule-trigger-stop' => ['1'],+ 'rule_triggers' => [+ 'name' => 'description',+ 'value' => 'Bla bla',+ 'stop_processing' => 1,+ ],];$set = factory(Transaction::class, 10)->make();diff --git a/tests/Unit/Factory/TransactionJournalFactoryTest.php b/tests/Unit/Factory/TransactionJournalFactoryTest.phpindex 2d9503f173..434d52ebde 100644--- a/tests/Unit/Factory/TransactionJournalFactoryTest.php+++ b/tests/Unit/Factory/TransactionJournalFactoryTest.php@@ -67,6 +67,8 @@ class TransactionJournalFactoryTest extends TestCase$typeFactory->shouldReceive('find')->andReturn($type);$currencyRepos->shouldReceive('find')->andReturn($euro);+ $metaFactory->shouldReceive('updateOrCreate');+// mock factories:$transactionFactory->shouldReceive('setUser')->once();$billFactory->shouldReceive('setUser')->once();diff --git a/tests/Unit/Services/Internal/Update/JournalUpdateServiceTest.php b/tests/Unit/Services/Internal/Update/JournalUpdateServiceTest.phpindex f7e4637fc0..b8aa942191 100644--- a/tests/Unit/Services/Internal/Update/JournalUpdateServiceTest.php+++ b/tests/Unit/Services/Internal/Update/JournalUpdateServiceTest.php@@ -61,6 +61,7 @@ class JournalUpdateServiceTest extends TestCase$tagFactory->shouldReceive('setUser');$metaFactory->shouldReceive('setUser');+ $metaFactory->shouldReceive('updateOrCreate');/** @var TransactionJournal $journal */$journal = $this->user()->transactionJournals()->where('transaction_type_id', 2)->first();@@ -102,6 +103,7 @@ class JournalUpdateServiceTest extends TestCase$transactionFactory->shouldReceive('setUser');$tagFactory->shouldReceive('setUser');$metaFactory->shouldReceive('setUser');+ $metaFactory->shouldReceive('updateOrCreate');/** @var TransactionJournal $journal */@@ -194,6 +196,7 @@ class JournalUpdateServiceTest extends TestCase$transactionFactory->shouldReceive('createPair')->times(2);$tagFactory->shouldReceive('setUser');$metaFactory->shouldReceive('setUser');+ $metaFactory->shouldReceive('updateOrCreate');/** @var TransactionJournal $journal */