mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Improve test coverage.
This commit is contained in:
@@ -237,6 +237,7 @@ class ReconcileControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ReconcileController::submit()
|
||||
* @covers \FireflyIII\Http\Requests\ReconciliationStoreRequest
|
||||
*/
|
||||
public function testSubmit()
|
||||
{
|
||||
@@ -288,6 +289,7 @@ class ReconcileControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ReconcileController::update
|
||||
* @covers \FireflyIII\Http\Requests\ReconciliationUpdateRequest
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
@@ -310,6 +312,7 @@ class ReconcileControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ReconcileController::update
|
||||
* @covers \FireflyIII\Http\Requests\ReconciliationUpdateRequest
|
||||
*/
|
||||
public function testUpdateNotReconcile()
|
||||
{
|
||||
@@ -326,6 +329,7 @@ class ReconcileControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ReconcileController::update
|
||||
* @covers \FireflyIII\Http\Requests\ReconciliationUpdateRequest
|
||||
*/
|
||||
public function testUpdateZero()
|
||||
{
|
||||
|
@@ -309,6 +309,7 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\AccountController::store
|
||||
* @covers \FireflyIII\Http\Requests\AccountFormRequest
|
||||
* @covers \FireflyIII\Http\Controllers\Controller::getPreviousUri
|
||||
*/
|
||||
public function testStore()
|
||||
@@ -337,6 +338,7 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\AccountController::store
|
||||
* @covers \FireflyIII\Http\Requests\AccountFormRequest
|
||||
* @covers \FireflyIII\Http\Controllers\Controller::getPreviousUri
|
||||
*/
|
||||
public function testStoreAnother()
|
||||
@@ -363,6 +365,7 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\AccountController::update
|
||||
* @covers \FireflyIII\Http\Requests\AccountFormRequest
|
||||
* @covers \FireflyIII\Http\Controllers\Controller::getPreviousUri
|
||||
*/
|
||||
public function testUpdate()
|
||||
@@ -389,6 +392,7 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\AccountController::update
|
||||
* @covers \FireflyIII\Http\Requests\AccountFormRequest
|
||||
* @covers \FireflyIII\Http\Controllers\Controller::getPreviousUri
|
||||
*/
|
||||
public function testUpdateAgain()
|
||||
|
@@ -161,6 +161,7 @@ class LinkControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Admin\LinkController::store
|
||||
* @covers \FireflyIII\Http\Requests\LinkTypeFormRequest
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
@@ -182,6 +183,7 @@ class LinkControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Admin\LinkController::store
|
||||
* @covers \FireflyIII\Http\Requests\LinkTypeFormRequest
|
||||
*/
|
||||
public function testStoreRedirect()
|
||||
{
|
||||
@@ -202,6 +204,7 @@ class LinkControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Admin\LinkController::update
|
||||
* @covers \FireflyIII\Http\Requests\LinkTypeFormRequest
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
@@ -225,6 +228,7 @@ class LinkControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Admin\LinkController::update
|
||||
* @covers \FireflyIII\Http\Requests\LinkTypeFormRequest
|
||||
*/
|
||||
public function testUpdateNonEditable()
|
||||
{
|
||||
@@ -246,6 +250,7 @@ class LinkControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Admin\LinkController::update
|
||||
* @covers \FireflyIII\Http\Requests\LinkTypeFormRequest
|
||||
*/
|
||||
public function testUpdateRedirect()
|
||||
{
|
||||
|
@@ -209,6 +209,8 @@ class BillControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::store
|
||||
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
||||
* @covers \FireflyIII\Http\Requests\Request
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
@@ -241,6 +243,8 @@ class BillControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::update
|
||||
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
||||
* @covers \FireflyIII\Http\Requests\Request
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
@@ -254,6 +258,7 @@ class BillControllerTest extends TestCase
|
||||
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||
|
||||
$data = [
|
||||
'id' => 1,
|
||||
'name' => 'Updated Bill ' . rand(1000, 9999),
|
||||
'match' => 'some more words',
|
||||
'amount_min' => '100',
|
||||
|
@@ -432,6 +432,7 @@ class CategoryControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::store
|
||||
* @covers \FireflyIII\Http\Requests\CategoryFormRequest
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
@@ -455,15 +456,17 @@ class CategoryControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::update
|
||||
* @covers \FireflyIII\Http\Requests\CategoryFormRequest
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
$category = Category::first();
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('update');
|
||||
$repository->shouldReceive('find')->andReturn(new Category);
|
||||
$repository->shouldReceive('find')->andReturn($category);
|
||||
|
||||
$this->session(['categories.edit.uri' => 'http://localhost']);
|
||||
|
||||
|
@@ -251,6 +251,7 @@ class CurrencyControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CurrencyController::store
|
||||
* @covers \FireflyIII\Http\Requests\CurrencyFormRequest
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
@@ -278,6 +279,7 @@ class CurrencyControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CurrencyController::store
|
||||
* @covers \FireflyIII\Http\Requests\CurrencyFormRequest
|
||||
*/
|
||||
public function testStoreNoRights()
|
||||
{
|
||||
@@ -305,6 +307,7 @@ class CurrencyControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CurrencyController::update
|
||||
* @covers \FireflyIII\Http\Requests\CurrencyFormRequest
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
@@ -319,6 +322,7 @@ class CurrencyControllerTest extends TestCase
|
||||
|
||||
$this->session(['currencies.edit.uri' => 'http://localhost']);
|
||||
$data = [
|
||||
'id' => 2,
|
||||
'name' => 'XA',
|
||||
'code' => 'XAX',
|
||||
'symbol' => 'a',
|
||||
|
@@ -117,6 +117,7 @@ class ExportControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ExportController::postIndex
|
||||
* @covers \FireflyIII\Http\Requests\ExportFormRequest
|
||||
*/
|
||||
public function testPostIndex()
|
||||
{
|
||||
|
@@ -334,7 +334,8 @@ class PiggyBankControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::store
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::store
|
||||
* @covers \FireflyIII\Http\Requests\PiggyBankFormRequest
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
@@ -359,7 +360,8 @@ class PiggyBankControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::update
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::update
|
||||
* @covers \FireflyIII\Http\Requests\PiggyBankFormRequest
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
@@ -371,6 +373,7 @@ class PiggyBankControllerTest extends TestCase
|
||||
|
||||
$this->session(['piggy-banks.edit.uri' => 'http://localhost']);
|
||||
$data = [
|
||||
'id' => 3,
|
||||
'name' => 'Updated Piggy ' . rand(999, 10000),
|
||||
'targetamount' => '100.123',
|
||||
'account_id' => 2,
|
||||
|
@@ -302,6 +302,7 @@ class ReportControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::postIndex
|
||||
* @covers \FireflyIII\Http\Requests\ReportFormRequest
|
||||
*/
|
||||
public function testPostIndexAccountOK()
|
||||
{
|
||||
@@ -328,6 +329,7 @@ class ReportControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::postIndex
|
||||
* @covers \FireflyIII\Http\Requests\ReportFormRequest
|
||||
*/
|
||||
public function testPostIndexAuditOK()
|
||||
{
|
||||
@@ -353,6 +355,7 @@ class ReportControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::postIndex
|
||||
* @covers \FireflyIII\Http\Requests\ReportFormRequest
|
||||
*/
|
||||
public function testPostIndexBudgetError()
|
||||
{
|
||||
@@ -381,6 +384,7 @@ class ReportControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::postIndex
|
||||
* @covers \FireflyIII\Http\Requests\ReportFormRequest
|
||||
*/
|
||||
public function testPostIndexBudgetOK()
|
||||
{
|
||||
@@ -409,6 +413,7 @@ class ReportControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::postIndex
|
||||
* @covers \FireflyIII\Http\Requests\ReportFormRequest
|
||||
*/
|
||||
public function testPostIndexCategoryError()
|
||||
{
|
||||
@@ -437,6 +442,7 @@ class ReportControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::postIndex
|
||||
* @covers \FireflyIII\Http\Requests\ReportFormRequest
|
||||
*/
|
||||
public function testPostIndexCategoryOK()
|
||||
{
|
||||
@@ -464,6 +470,7 @@ class ReportControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::postIndex
|
||||
* @covers \FireflyIII\Http\Requests\ReportFormRequest
|
||||
*/
|
||||
public function testPostIndexDefaultOK()
|
||||
{
|
||||
@@ -489,6 +496,7 @@ class ReportControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::postIndex
|
||||
* @covers \FireflyIII\Http\Requests\ReportFormRequest
|
||||
*/
|
||||
public function testPostIndexDefaultStartEnd()
|
||||
{
|
||||
@@ -514,6 +522,7 @@ class ReportControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::postIndex
|
||||
* @covers \FireflyIII\Http\Requests\ReportFormRequest
|
||||
*/
|
||||
public function testPostIndexTagError()
|
||||
{
|
||||
@@ -541,6 +550,7 @@ class ReportControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::postIndex
|
||||
* @covers \FireflyIII\Http\Requests\ReportFormRequest
|
||||
*/
|
||||
public function testPostIndexTagOK()
|
||||
{
|
||||
@@ -569,6 +579,7 @@ class ReportControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::postIndex
|
||||
* @covers \FireflyIII\Http\Requests\ReportFormRequest
|
||||
*/
|
||||
public function testPostIndexZeroAccounts()
|
||||
{
|
||||
|
@@ -300,6 +300,7 @@ class RuleControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleController::store
|
||||
* @covers \FireflyIII\Http\Requests\RuleFormRequest
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
@@ -449,6 +450,7 @@ class RuleControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleController::update
|
||||
* @covers \FireflyIII\Http\Requests\RuleFormRequest
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
|
@@ -170,7 +170,8 @@ class RuleGroupControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleGroupController::store
|
||||
* @covers \FireflyIII\Http\Controllers\RuleGroupController::store
|
||||
* @covers \FireflyIII\Http\Requests\RuleGroupFormRequest
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
@@ -211,7 +212,8 @@ class RuleGroupControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleGroupController::update
|
||||
* @covers \FireflyIII\Http\Controllers\RuleGroupController::update
|
||||
* @covers \FireflyIII\Http\Requests\RuleGroupFormRequest
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
@@ -221,13 +223,14 @@ class RuleGroupControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$data = [
|
||||
'id' => 1,
|
||||
'title' => 'C',
|
||||
'description' => 'XX',
|
||||
];
|
||||
$this->session(['rule-groups.edit.uri' => 'http://localhost']);
|
||||
|
||||
$repository->shouldReceive('update');
|
||||
$repository->shouldReceive('find')->andReturn(new RuleGroup);
|
||||
$repository->shouldReceive('find')->andReturn(RuleGroup::first());
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('rule-groups.update', [1]), $data);
|
||||
|
@@ -242,7 +242,8 @@ class TagControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TagController::store
|
||||
* @covers \FireflyIII\Http\Controllers\TagController::store
|
||||
* @covers \FireflyIII\Http\Requests\TagFormRequest
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
@@ -255,8 +256,10 @@ class TagControllerTest extends TestCase
|
||||
|
||||
$this->session(['tags.create.uri' => 'http://localhost']);
|
||||
$data = [
|
||||
'tag' => 'Hello new tag' . rand(999, 10000),
|
||||
'tagMode' => 'nothing',
|
||||
'tag' => 'Hello new tag' . rand(999, 10000),
|
||||
'tagMode' => 'nothing',
|
||||
'tag_position_has_tag' => 'true',
|
||||
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('tags.store'), $data);
|
||||
@@ -265,7 +268,8 @@ class TagControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TagController::update
|
||||
* @covers \FireflyIII\Http\Controllers\TagController::update
|
||||
* @covers \FireflyIII\Http\Requests\TagFormRequest
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
@@ -276,12 +280,13 @@ class TagControllerTest extends TestCase
|
||||
|
||||
$this->session(['tags.edit.uri' => 'http://localhost']);
|
||||
$data = [
|
||||
'id' => 1,
|
||||
'tag' => 'Hello updated tag' . rand(999, 10000),
|
||||
'tagMode' => 'nothing',
|
||||
];
|
||||
|
||||
$repository->shouldReceive('update');
|
||||
$repository->shouldReceive('find')->andReturn(new Tag);
|
||||
$repository->shouldReceive('find')->andReturn(Tag::first());
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('tags.update', [1]), $data);
|
||||
|
@@ -138,6 +138,7 @@ class BulkControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController::update
|
||||
* @covers \FireflyIII\Http\Requests\BulkEditJournalRequest
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
|
@@ -73,6 +73,7 @@ class LinkControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
|
||||
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
@@ -98,6 +99,7 @@ class LinkControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
|
||||
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
|
||||
*/
|
||||
public function testStoreAlreadyLinked()
|
||||
{
|
||||
@@ -122,6 +124,7 @@ class LinkControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
|
||||
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
|
||||
*/
|
||||
public function testStoreInvalid()
|
||||
{
|
||||
|
@@ -230,7 +230,9 @@ class SingleControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$account = $this->user()->accounts()->first();
|
||||
$accountRepos->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection([$account]));
|
||||
$accountRepos->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(
|
||||
new Collection([$account])
|
||||
);
|
||||
|
||||
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();
|
||||
|
||||
@@ -574,6 +576,7 @@ class SingleControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::store
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::groupedActiveAccountList
|
||||
* @covers \FireflyIII\Http\Requests\JournalFormRequest
|
||||
*/
|
||||
public function testStoreError()
|
||||
{
|
||||
@@ -610,6 +613,7 @@ class SingleControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::store
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::groupedActiveAccountList
|
||||
* @covers \FireflyIII\Http\Requests\JournalFormRequest
|
||||
*/
|
||||
public function testStoreSuccess()
|
||||
{
|
||||
@@ -659,8 +663,170 @@ class SingleControllerTest extends TestCase
|
||||
$response->assertSessionHas('info');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::store
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::groupedActiveAccountList
|
||||
* @covers \FireflyIII\Http\Requests\JournalFormRequest
|
||||
*/
|
||||
public function testStoreSuccessDeposit()
|
||||
{
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$attRepos = $this->mock(AttachmentHelperInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
|
||||
// mock results:
|
||||
$journal = new TransactionJournal();
|
||||
$journal->id = 1000;
|
||||
$journal->description = 'New deposit';
|
||||
$journalRepos->shouldReceive('store')->andReturn($journal);
|
||||
$this->expectsEvents(StoredTransactionJournal::class);
|
||||
|
||||
$errors = new MessageBag;
|
||||
$errors->add('attachments', 'Fake error');
|
||||
|
||||
$messages = new MessageBag;
|
||||
$messages->add('attachments', 'Fake error');
|
||||
|
||||
// mock attachment helper, trigger an error AND and info thing.
|
||||
$attRepos->shouldReceive('saveAttachmentsForModel');
|
||||
$attRepos->shouldReceive('getErrors')->andReturn($errors);
|
||||
$attRepos->shouldReceive('getMessages')->andReturn($messages);
|
||||
|
||||
$this->session(['transactions.create.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
|
||||
$data = [
|
||||
'what' => 'deposit',
|
||||
'amount' => '10',
|
||||
'amount_currency_id_amount' => 1,
|
||||
'destination_account_id' => 1,
|
||||
'source_account_name' => 'Some source',
|
||||
'date' => '2016-01-01',
|
||||
'description' => 'Test descr',
|
||||
];
|
||||
$response = $this->post(route('transactions.store', ['deposit']), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
$response->assertSessionHas('error');
|
||||
$response->assertSessionHas('info');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::store
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::groupedActiveAccountList
|
||||
* @covers \FireflyIII\Http\Requests\JournalFormRequest
|
||||
*/
|
||||
public function testStoreSuccessTransfer()
|
||||
{
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$attRepos = $this->mock(AttachmentHelperInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
|
||||
// mock results:
|
||||
$journal = new TransactionJournal();
|
||||
$journal->id = 1000;
|
||||
$journal->description = 'New transfer';
|
||||
$journalRepos->shouldReceive('store')->andReturn($journal);
|
||||
$this->expectsEvents(StoredTransactionJournal::class);
|
||||
|
||||
$errors = new MessageBag;
|
||||
$errors->add('attachments', 'Fake error');
|
||||
|
||||
$messages = new MessageBag;
|
||||
$messages->add('attachments', 'Fake error');
|
||||
|
||||
// mock attachment helper, trigger an error AND and info thing.
|
||||
$attRepos->shouldReceive('saveAttachmentsForModel');
|
||||
$attRepos->shouldReceive('getErrors')->andReturn($errors);
|
||||
$attRepos->shouldReceive('getMessages')->andReturn($messages);
|
||||
|
||||
$this->session(['transactions.create.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
|
||||
$data = [
|
||||
'what' => 'transfer',
|
||||
'amount' => '10',
|
||||
'amount_currency_id_amount' => 1,
|
||||
'destination_account_id' => 1,
|
||||
'source_account_id' => 2,
|
||||
'date' => '2016-01-01',
|
||||
'description' => 'Test descr',
|
||||
];
|
||||
$response = $this->post(route('transactions.store', ['transfer']), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
$response->assertSessionHas('error');
|
||||
$response->assertSessionHas('info');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::store
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::groupedActiveAccountList
|
||||
* @covers \FireflyIII\Http\Requests\JournalFormRequest
|
||||
*/
|
||||
public function testStoreSuccessTransferForeign()
|
||||
{
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$attRepos = $this->mock(AttachmentHelperInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
|
||||
// mock results:
|
||||
$journal = new TransactionJournal();
|
||||
$journal->id = 1000;
|
||||
$journal->description = 'New transfer';
|
||||
$journalRepos->shouldReceive('store')->andReturn($journal);
|
||||
$this->expectsEvents(StoredTransactionJournal::class);
|
||||
|
||||
$errors = new MessageBag;
|
||||
$errors->add('attachments', 'Fake error');
|
||||
|
||||
$messages = new MessageBag;
|
||||
$messages->add('attachments', 'Fake error');
|
||||
|
||||
// mock attachment helper, trigger an error AND and info thing.
|
||||
$attRepos->shouldReceive('saveAttachmentsForModel');
|
||||
$attRepos->shouldReceive('getErrors')->andReturn($errors);
|
||||
$attRepos->shouldReceive('getMessages')->andReturn($messages);
|
||||
|
||||
$this->session(['transactions.create.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
|
||||
$data = [
|
||||
'what' => 'transfer',
|
||||
'amount' => '10',
|
||||
'amount_currency_id_amount' => 1,
|
||||
'source_account_currency' => 1,
|
||||
'destination_account_currency' => 2,
|
||||
'destination_account_id' => 1,
|
||||
'source_account_id' => 2,
|
||||
'date' => '2016-01-01',
|
||||
'description' => 'Test descr',
|
||||
];
|
||||
$response = $this->post(route('transactions.store', ['transfer']), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
$response->assertSessionHas('error');
|
||||
$response->assertSessionHas('info');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::update
|
||||
* @covers \FireflyIII\Http\Requests\JournalFormRequest
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
|
@@ -63,11 +63,11 @@ class SplitControllerTest extends TestCase
|
||||
$attHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
|
||||
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
|
||||
$account = $destination->account;
|
||||
$transactions = factory(Transaction::class, 3)->make();
|
||||
$array = $transactions->toArray();
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
|
||||
$account = $destination->account;
|
||||
$transactions = factory(Transaction::class, 3)->make();
|
||||
$array = $transactions->toArray();
|
||||
$array[0]['category'] = '';
|
||||
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn($deposit);
|
||||
@@ -260,7 +260,8 @@ class SplitControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController::update
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController::update
|
||||
* @covers \FireflyIII\Http\Requests\SplitJournalFormRequest
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
@@ -315,8 +316,9 @@ class SplitControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController::update
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController::isOpeningBalance
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController::update
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController::isOpeningBalance
|
||||
* @covers \FireflyIII\Http\Requests\SplitJournalFormRequest
|
||||
*/
|
||||
public function testUpdateOpeningBalance()
|
||||
{
|
||||
@@ -356,4 +358,118 @@ class SplitControllerTest extends TestCase
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionMissing('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController::update
|
||||
* @covers \FireflyIII\Http\Requests\SplitJournalFormRequest
|
||||
*/
|
||||
public function testUpdateTransfer()
|
||||
{
|
||||
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$attHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$tasker = $this->mock(JournalTaskerInterface::class);
|
||||
$ruleRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$billRepos = $this->mock(BillRepositoryInterface::class);
|
||||
|
||||
$billRepos->shouldReceive('scan');
|
||||
$ruleRepos->shouldReceive('getActiveGroups')->andReturn(new Collection);
|
||||
|
||||
|
||||
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$data = [
|
||||
'id' => $transfer->id,
|
||||
'what' => 'transfer',
|
||||
'journal_description' => 'Some updated withdrawal',
|
||||
'journal_currency_id' => 1,
|
||||
'journal_source_account_id' => 1,
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
[
|
||||
'description' => 'Split #1',
|
||||
'source_account_id' => '1',
|
||||
'destination_account_id' => '2',
|
||||
'transaction_currency_id' => 1,
|
||||
'amount' => 1591,
|
||||
'category' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// mock stuff
|
||||
$journalRepos->shouldReceive('update')->andReturn($transfer);
|
||||
$journalRepos->shouldReceive('first')->andReturn($transfer);
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Withdrawal');
|
||||
|
||||
$attHelper->shouldReceive('saveAttachmentsForModel');
|
||||
$attHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.split.update', [$transfer->id]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect(route('index'));
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SplitController::update
|
||||
* @covers \FireflyIII\Http\Requests\SplitJournalFormRequest
|
||||
*/
|
||||
public function testUpdateWithdrawal()
|
||||
{
|
||||
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$attHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$tasker = $this->mock(JournalTaskerInterface::class);
|
||||
$ruleRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$billRepos = $this->mock(BillRepositoryInterface::class);
|
||||
|
||||
$billRepos->shouldReceive('scan');
|
||||
$ruleRepos->shouldReceive('getActiveGroups')->andReturn(new Collection);
|
||||
|
||||
|
||||
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
|
||||
$withdrawal = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 1)->first();
|
||||
$data = [
|
||||
'id' => $withdrawal->id,
|
||||
'what' => 'withdrawal',
|
||||
'journal_description' => 'Some updated withdrawal',
|
||||
'journal_currency_id' => 1,
|
||||
'journal_source_account_id' => 1,
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
[
|
||||
'description' => 'Split #1',
|
||||
'source_account_id' => '1',
|
||||
'destination_account_name' => 'some expense',
|
||||
'transaction_currency_id' => 1,
|
||||
'amount' => 1591,
|
||||
'category' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// mock stuff
|
||||
$journalRepos->shouldReceive('update')->andReturn($withdrawal);
|
||||
$journalRepos->shouldReceive('first')->andReturn($withdrawal);
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Withdrawal');
|
||||
|
||||
$attHelper->shouldReceive('saveAttachmentsForModel');
|
||||
$attHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.split.update', [$withdrawal->id]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect(route('index'));
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user