mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-14 02:32:04 -06:00
Update tests
This commit is contained in:
parent
33294dd9f0
commit
049c93465a
@ -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:
|
||||
|
@ -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).
|
||||
|
@ -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 = [
|
||||
|
@ -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();
|
||||
|
@ -74,6 +74,9 @@ class IndexControllerTest extends TestCase
|
||||
Steam::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());
|
||||
|
@ -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),
|
||||
|
@ -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\RuleFormRequest
|
||||
|
@ -103,9 +103,11 @@ class SelectControllerTest extends TestCase
|
||||
public 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 TestCase
|
||||
public 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();
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user