mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Expand tests.
This commit is contained in:
parent
28debb46be
commit
46f4fa1a7d
@ -1030,7 +1030,7 @@ class TransactionControllerTest extends TestCase
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionController::index
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionController::mapTypes
|
||||
*
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
@ -1074,7 +1074,7 @@ class TransactionControllerTest extends TestCase
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionController::__construct
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionController::index
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionController::mapTypes
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testIndexWithRange()
|
||||
{
|
||||
|
@ -23,7 +23,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers\Account;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -40,7 +47,14 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testEdit()
|
||||
{
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
||||
$transaction = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
$repository->shouldReceive('first')->andReturn($journal);
|
||||
$repository->shouldReceive('getFirstPosTransaction')->andReturn($transaction);
|
||||
$repository->shouldReceive('getJournalDate')->andReturn('2018-01-01');
|
||||
$repository->shouldReceive('getJournalCategoryName')->andReturn('');
|
||||
$repository->shouldReceive('getJournalBudgetid')->andReturn(0);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('accounts.reconcile.edit', [$journal->id]));
|
||||
@ -56,7 +70,6 @@ class ReconcileControllerTest extends TestCase
|
||||
public function testEditRedirect()
|
||||
{
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', '!=', 5)->first();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('accounts.reconcile.edit', [$journal->id]));
|
||||
$response->assertStatus(302);
|
||||
@ -68,6 +81,10 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testOverview()
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('getTransactionsById')->andReturn(new Collection())->twice();
|
||||
|
||||
$parameters = [
|
||||
'startBalance' => '0',
|
||||
'endBalance' => '10',
|
||||
@ -104,6 +121,8 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testReconcile()
|
||||
{
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('accounts.reconcile', [1, '20170101', '20170131']));
|
||||
$response->assertStatus(200);
|
||||
@ -133,6 +152,9 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testReconcileNoDates()
|
||||
{
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('accounts.reconcile', [1]));
|
||||
$response->assertStatus(200);
|
||||
@ -148,6 +170,9 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testReconcileNoEndDate()
|
||||
{
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('accounts.reconcile', [1, '20170101']));
|
||||
$response->assertStatus(200);
|
||||
@ -169,13 +194,16 @@ class ReconcileControllerTest extends TestCase
|
||||
$response->assertStatus(302);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ReconcileController::show()
|
||||
*/
|
||||
public function testShow()
|
||||
{
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('getAssetTransaction')->once()->andReturn($journal->transactions()->first());
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('accounts.reconcile.show', [$journal->id]));
|
||||
$response->assertStatus(200);
|
||||
@ -201,6 +229,13 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testSubmit()
|
||||
{
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('reconcileById')->andReturn(true);
|
||||
$journalRepos->shouldReceive('store')->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('getReconciliation')->andReturn(new Account);
|
||||
$repository->shouldReceive('findNull')->andReturn(new Account);
|
||||
$data = [
|
||||
'transactions' => [1, 2, 3],
|
||||
'reconcile' => 'create',
|
||||
@ -220,6 +255,9 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testTransactions()
|
||||
{
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('accounts.reconcile.transactions', [1, '20170101', '20170131']));
|
||||
$response->assertStatus(200);
|
||||
@ -242,6 +280,13 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([new Account]));
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([new Account]));
|
||||
$journalRepos->shouldReceive('getNoteText')->andReturn('');
|
||||
$journalRepos->shouldReceive('update')->once();
|
||||
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
||||
$data = [
|
||||
'amount' => '5',
|
||||
@ -284,4 +329,5 @@ class ReconcileControllerTest extends TestCase
|
||||
$response->assertSessionHas('error');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ class AccountControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('get')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
@ -74,8 +75,9 @@ class AccountControllerTest extends TestCase
|
||||
public function testDelete()
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAccountsByType')->withArgs([[AccountType::ASSET]])->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -95,8 +97,9 @@ class AccountControllerTest extends TestCase
|
||||
public function testDestroy()
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('findNull')->withArgs([0])->once()->andReturn(null);
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
@ -115,15 +118,15 @@ class AccountControllerTest extends TestCase
|
||||
*/
|
||||
public function testEdit()
|
||||
{
|
||||
$note = new Note();
|
||||
$note = new Note();
|
||||
$note->text = 'This is a test';
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
||||
$repository->shouldReceive('get')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('find')->once()->andReturn(new TransactionCurrency());
|
||||
$accountRepos->shouldReceive('getNote')->andReturn($note)->once();
|
||||
$accountRepos->shouldReceive('getOpeningBalanceAmount')->andReturnNull();
|
||||
$accountRepos->shouldReceive('getOpeningBalanceDate')->andReturnNull();
|
||||
@ -144,13 +147,15 @@ class AccountControllerTest extends TestCase
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
*
|
||||
*/
|
||||
public function testIndex(string $range)
|
||||
{
|
||||
// mock stuff
|
||||
$account = factory(Account::class)->make();
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$account = factory(Account::class)->make();
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]));
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
Steam::shouldReceive('balancesByAccounts')->andReturn([$account->id => '100']);
|
||||
@ -179,6 +184,10 @@ class AccountControllerTest extends TestCase
|
||||
// mock stuff:
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$tasker->shouldReceive('amountOutInPeriod')->withAnyArgs()->andReturn('-1');
|
||||
$tasker->shouldReceive('amountInInPeriod')->withAnyArgs()->andReturn('1');
|
||||
@ -214,6 +223,7 @@ class AccountControllerTest extends TestCase
|
||||
{
|
||||
// mock
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$date = new Carbon;
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
@ -236,6 +246,7 @@ class AccountControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
@ -250,6 +261,8 @@ class AccountControllerTest extends TestCase
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('getJournals')->andReturn(new Collection);
|
||||
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('accounts.show', [1, '2016-01-01']));
|
||||
@ -266,6 +279,8 @@ class AccountControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$date = new Carbon;
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
@ -285,6 +300,7 @@ class AccountControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('store')->once()->andReturn(factory(Account::class)->make());
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -312,6 +328,7 @@ class AccountControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('store')->once()->andReturn(factory(Account::class)->make());
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -337,6 +354,7 @@ class AccountControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('update')->once();
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -362,6 +380,7 @@ class AccountControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('update')->once();
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
|
@ -23,6 +23,8 @@ declare(strict_types=1);
|
||||
namespace Tests\Feature\Controllers\Admin;
|
||||
|
||||
use FireflyIII\Models\LinkType;
|
||||
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -51,10 +53,13 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testDeleteEditable()
|
||||
{
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
// create editable link type just in case:
|
||||
LinkType::create(['editable' => 1, 'inward' => 'hello', 'outward' => 'bye', 'name' => 'Test type']);
|
||||
|
||||
$linkType = LinkType::where('editable', 1)->first();
|
||||
$repository->shouldReceive('get')->once()->andReturn(new Collection([$linkType]));
|
||||
$repository->shouldReceive('countJournals')->andReturn(2);
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('admin.links.delete', [$linkType->id]));
|
||||
$response->assertStatus(200);
|
||||
@ -65,7 +70,8 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testDeleteNonEditable()
|
||||
{
|
||||
$linkType = LinkType::where('editable', 0)->first();
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$linkType = LinkType::where('editable', 0)->first();
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('admin.links.delete', [$linkType->id]));
|
||||
$response->assertStatus(302);
|
||||
@ -77,10 +83,14 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testDestroy()
|
||||
{
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
|
||||
// create editable link type just in case:
|
||||
LinkType::create(['editable' => 1, 'inward' => 'hellox', 'outward' => 'byex', 'name' => 'Test typeX']);
|
||||
|
||||
$linkType = LinkType::where('editable', 1)->first();
|
||||
$repository->shouldReceive('find')->andReturn($linkType);
|
||||
$repository->shouldReceive('destroy');
|
||||
$this->be($this->user());
|
||||
$this->session(['link_types.delete.uri' => 'http://localhost']);
|
||||
$response = $this->post(route('admin.links.destroy', [$linkType->id]));
|
||||
@ -119,6 +129,8 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$repository->shouldReceive('get')->andReturn(new Collection);
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('admin.links.index'));
|
||||
$response->assertStatus(200);
|
||||
@ -140,11 +152,15 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
$data = [
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$data = [
|
||||
'name' => 'test ' . rand(1, 1000),
|
||||
'inward' => 'test inward' . rand(1, 1000),
|
||||
'outward' => 'test outward' . rand(1, 1000),
|
||||
];
|
||||
$repository->shouldReceive('store')->once()->andReturn(LinkType::first());
|
||||
$repository->shouldReceive('find')->andReturn(LinkType::first());
|
||||
|
||||
$this->session(['link_types.create.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('admin.links.store'), $data);
|
||||
@ -157,12 +173,14 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreRedirect()
|
||||
{
|
||||
$data = [
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$data = [
|
||||
'name' => 'test ' . rand(1, 1000),
|
||||
'inward' => 'test inward' . rand(1, 1000),
|
||||
'outward' => 'test outward' . rand(1, 1000),
|
||||
'create_another' => '1',
|
||||
];
|
||||
$repository->shouldReceive('store')->once()->andReturn(new LinkType);
|
||||
$this->session(['link_types.create.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('admin.links.store'), $data);
|
||||
@ -175,9 +193,11 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
// create editable link type just in case:
|
||||
$linKType = LinkType::create(['editable' => 1, 'inward' => 'helloxz', 'outward' => 'bzyex', 'name' => 'Test tyzpeX']);
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
|
||||
// create editable link type just in case:
|
||||
$linkType = LinkType::create(['editable' => 1, 'inward' => 'helloxz', 'outward' => 'bzyex', 'name' => 'Test tyzpeX']);
|
||||
$repository->shouldReceive('update')->once()->andReturn(new $linkType);
|
||||
|
||||
$data = [
|
||||
'name' => 'test ' . rand(1, 1000),
|
||||
@ -186,7 +206,7 @@ class LinkControllerTest extends TestCase
|
||||
];
|
||||
$this->session(['link_types.edit.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('admin.links.update', [$linKType->id]), $data);
|
||||
$response = $this->post(route('admin.links.update', [$linkType->id]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
@ -196,7 +216,7 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateNonEditable()
|
||||
{
|
||||
// create editable link type just in case:
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$linkType = LinkType::where('editable', 0)->first();
|
||||
|
||||
$data = [
|
||||
@ -217,6 +237,7 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateRedirect()
|
||||
{
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
// create editable link type just in case:
|
||||
$linkType = LinkType::create(['editable' => 1, 'inward' => 'healox', 'outward' => 'byaex', 'name' => 'Test tyapeX']);
|
||||
|
||||
@ -226,6 +247,7 @@ class LinkControllerTest extends TestCase
|
||||
'outward' => 'test outward' . rand(1, 1000),
|
||||
'return_to_edit' => '1',
|
||||
];
|
||||
$repository->shouldReceive('update')->once()->andReturn(new $linkType);
|
||||
$this->session(['link_types.edit.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('admin.links.update', [$linkType->id]), $data);
|
||||
|
@ -42,6 +42,7 @@ class AttachmentControllerTest extends TestCase
|
||||
public function testDelete()
|
||||
{
|
||||
// mock stuff
|
||||
$attachRepository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$this->be($this->user());
|
||||
@ -110,6 +111,7 @@ class AttachmentControllerTest extends TestCase
|
||||
*/
|
||||
public function testEdit()
|
||||
{
|
||||
$attachRepository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$this->be($this->user());
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@ -30,6 +31,7 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -47,6 +49,7 @@ class BillControllerTest extends TestCase
|
||||
public function testCreate()
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -63,6 +66,7 @@ class BillControllerTest extends TestCase
|
||||
public function testDelete()
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -79,6 +83,7 @@ class BillControllerTest extends TestCase
|
||||
public function testDestroy()
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
@ -97,6 +102,7 @@ class BillControllerTest extends TestCase
|
||||
public function testEdit()
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -115,6 +121,7 @@ class BillControllerTest extends TestCase
|
||||
public function testIndex()
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$bill = factory(Bill::class)->make();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
@ -125,7 +132,6 @@ class BillControllerTest extends TestCase
|
||||
$repository->shouldReceive('getPaidDatesInRange')->twice()->andReturn(new Collection([new Carbon, new Carbon, new Carbon]));
|
||||
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('bills.index'));
|
||||
$response->assertStatus(200);
|
||||
@ -139,6 +145,7 @@ class BillControllerTest extends TestCase
|
||||
public function testRescan()
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journal = factory(TransactionJournal::class)->make();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
@ -158,7 +165,9 @@ class BillControllerTest extends TestCase
|
||||
public function testRescanInactive()
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
@ -173,6 +182,7 @@ class BillControllerTest extends TestCase
|
||||
public function testShow()
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
@ -204,10 +214,13 @@ class BillControllerTest extends TestCase
|
||||
public function testStore()
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('store')->andReturn(new Bill);
|
||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||
|
||||
$data = [
|
||||
'name' => 'New Bill ' . rand(1000, 9999),
|
||||
@ -233,10 +246,13 @@ class BillControllerTest extends TestCase
|
||||
public function testUpdate()
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('update')->andReturn(new Bill);
|
||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||
|
||||
$data = [
|
||||
'name' => 'Updated Bill ' . rand(1000, 9999),
|
||||
|
@ -86,6 +86,7 @@ class BudgetControllerTest extends TestCase
|
||||
public function testCreate()
|
||||
{
|
||||
// mock stuff
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -102,6 +103,7 @@ class BudgetControllerTest extends TestCase
|
||||
public function testDelete()
|
||||
{
|
||||
// mock stuff
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -137,6 +139,7 @@ class BudgetControllerTest extends TestCase
|
||||
public function testEdit()
|
||||
{
|
||||
// mock stuff
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -291,8 +294,12 @@ class BudgetControllerTest extends TestCase
|
||||
public function testInfoIncome()
|
||||
{
|
||||
// mock stuff
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$repository->shouldReceive('getAvailableBudget')->andReturn('100.123');
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('budgets.income.info', ['20170101', '20170131']));
|
||||
@ -302,13 +309,15 @@ class BudgetControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BudgetController::infoIncome
|
||||
* @dataProvider dateRangeProvider
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testInfoIncomeExpanded(string $range)
|
||||
{
|
||||
// mock stuff
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAvailableBudget')->andReturn('100.123');
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
@ -323,11 +332,11 @@ class BudgetControllerTest extends TestCase
|
||||
*
|
||||
* @param string $range
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testNoBudget(string $range)
|
||||
{
|
||||
// mock stuff
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
@ -362,6 +371,7 @@ class BudgetControllerTest extends TestCase
|
||||
public function testNoBudgetAll(string $range)
|
||||
{
|
||||
// mock stuff
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
@ -398,6 +408,7 @@ class BudgetControllerTest extends TestCase
|
||||
public function testNoBudgetDate(string $range)
|
||||
{
|
||||
// mock stuff
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
@ -491,6 +502,7 @@ class BudgetControllerTest extends TestCase
|
||||
public function testShowByBadBudgetLimit()
|
||||
{
|
||||
// mock stuff
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
|
@ -34,7 +34,6 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Navigation;
|
||||
use Steam;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -52,7 +51,9 @@ class CategoryControllerTest extends TestCase
|
||||
public function testCreate()
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
@ -68,6 +69,8 @@ class CategoryControllerTest extends TestCase
|
||||
public function testDelete()
|
||||
{
|
||||
// mock stuff
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -84,11 +87,12 @@ class CategoryControllerTest extends TestCase
|
||||
public function testDestroy()
|
||||
{
|
||||
// mock stuff
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
$categoryRepos->shouldReceive('destroy')->andReturn(true);
|
||||
|
||||
$this->session(['categories.delete.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
@ -103,6 +107,8 @@ class CategoryControllerTest extends TestCase
|
||||
public function testEdit()
|
||||
{
|
||||
// mock stuff
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -121,11 +127,12 @@ class CategoryControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff
|
||||
$category = factory(Category::class)->make();
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('getCategories')->andReturn(new Collection([$category]))->once();
|
||||
$repository->shouldReceive('lastUseDate')->andReturn(new Carbon)->once();
|
||||
$categoryRepos->shouldReceive('getCategories')->andReturn(new Collection([$category]))->once();
|
||||
$categoryRepos->shouldReceive('lastUseDate')->andReturn(new Carbon)->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('categories.index'));
|
||||
@ -145,6 +152,8 @@ class CategoryControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -175,12 +184,13 @@ class CategoryControllerTest extends TestCase
|
||||
*
|
||||
* @param string $range
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testNoCategoryAll(string $range)
|
||||
{
|
||||
// mock stuff
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -215,6 +225,8 @@ class CategoryControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -235,7 +247,7 @@ class CategoryControllerTest extends TestCase
|
||||
Navigation::shouldReceive('startOfPeriod')->andReturn(new Carbon);
|
||||
Navigation::shouldReceive('endOfPeriod')->andReturn(new Carbon);
|
||||
Navigation::shouldReceive('periodShow')->andReturn('Some date');
|
||||
Navigation::shouldReceive('blockPeriods')->andReturn([['period' =>'1M','start' => new Carbon, 'end' => new Carbon]])->once();
|
||||
Navigation::shouldReceive('blockPeriods')->andReturn([['period' => '1M', 'start' => new Carbon, 'end' => new Carbon]])->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
@ -256,15 +268,15 @@ class CategoryControllerTest extends TestCase
|
||||
public function testShow(string $range)
|
||||
{
|
||||
$transaction = factory(Transaction::class)->make();
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn('0');
|
||||
$repository->shouldReceive('earnedInPeriod')->andReturn('0');
|
||||
$categoryRepos->shouldReceive('spentInPeriod')->andReturn('0');
|
||||
$categoryRepos->shouldReceive('earnedInPeriod')->andReturn('0');
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getAccountsByType')->once()->andReturn(new Collection);
|
||||
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
@ -287,7 +299,7 @@ class CategoryControllerTest extends TestCase
|
||||
Navigation::shouldReceive('startOfPeriod')->andReturn(new Carbon);
|
||||
Navigation::shouldReceive('endOfPeriod')->andReturn(new Carbon);
|
||||
Navigation::shouldReceive('periodShow')->andReturn('Some date');
|
||||
Navigation::shouldReceive('blockPeriods')->andReturn([['period' =>'1M','start' => new Carbon, 'end' => new Carbon]])->once();
|
||||
Navigation::shouldReceive('blockPeriods')->andReturn([['period' => '1M', 'start' => new Carbon, 'end' => new Carbon]])->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
@ -309,6 +321,7 @@ class CategoryControllerTest extends TestCase
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$collector->shouldReceive('setPage')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setLimit')->andReturnSelf()->once();
|
||||
@ -422,6 +435,7 @@ class CategoryControllerTest extends TestCase
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
@ -446,6 +460,7 @@ class CategoryControllerTest extends TestCase
|
||||
{
|
||||
$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);
|
||||
|
@ -29,10 +29,12 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Preferences;
|
||||
use Steam;
|
||||
@ -57,9 +59,10 @@ class AccountControllerTest extends TestCase
|
||||
*/
|
||||
public function testExpenseAccounts(string $range)
|
||||
{
|
||||
$account = factory(Account::class)->make();
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$account = factory(Account::class)->make();
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$accountRepos->shouldReceive('getAccountsByType')->withArgs([[AccountType::EXPENSE, AccountType::BENEFICIARY]])->andReturn(new Collection([$account]));
|
||||
$generator->shouldReceive('singleSet')->andReturn([]);
|
||||
@ -200,8 +203,9 @@ class AccountControllerTest extends TestCase
|
||||
*/
|
||||
public function testFrontpage(string $range)
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
// change the preference:
|
||||
Preferences::setForUser($this->user(), 'frontPageAccounts', []);
|
||||
@ -211,6 +215,7 @@ class AccountControllerTest extends TestCase
|
||||
Steam::shouldReceive('balanceInRange')->andReturn([]);
|
||||
$generator->shouldReceive('multiSet')->andReturn([]);
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('chart.account.frontpage'));
|
||||
@ -292,7 +297,7 @@ class AccountControllerTest extends TestCase
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('chart.account.period', [1, '2012-01-01','2012-01-31']));
|
||||
$response = $this->get(route('chart.account.period', [1, '2012-01-01', '2012-01-31']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
@ -302,6 +307,8 @@ class AccountControllerTest extends TestCase
|
||||
*/
|
||||
public function testReport()
|
||||
{
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$generator->shouldReceive('multiSet')->andreturn([]);
|
||||
Steam::shouldReceive('balanceInRange')->andReturn(['2012-01-01' => '0']);
|
||||
|
@ -94,6 +94,9 @@ class BudgetControllerTest extends TestCase
|
||||
*/
|
||||
public function testBudgetLimitWrongLimit()
|
||||
{
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('chart.budget.budget-limit', [1, 8]));
|
||||
$response->assertStatus(500);
|
||||
@ -108,10 +111,13 @@ class BudgetControllerTest extends TestCase
|
||||
*/
|
||||
public function testExpenseAsset(string $range)
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$transactions = factory(Transaction::class, 10)->make();
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
|
||||
$collector->shouldReceive('setAllAssetAccounts')->once()->andReturnSelf();
|
||||
$collector->shouldReceive('setBudget')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
@ -137,6 +143,9 @@ class BudgetControllerTest extends TestCase
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$catRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
|
||||
|
||||
$transactions = factory(Transaction::class, 10)->make();
|
||||
$categories = factory(Category::class, 10)->make();
|
||||
@ -169,6 +178,8 @@ class BudgetControllerTest extends TestCase
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$transactions = factory(Transaction::class, 10)->make();
|
||||
$accounts = factory(Account::class, 10)->make();
|
||||
|
||||
|
@ -51,9 +51,11 @@ class BudgetReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testAccountExpense()
|
||||
{
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
|
||||
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setBudgets')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
|
||||
@ -72,6 +74,7 @@ class BudgetReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testBudgetExpense()
|
||||
{
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
|
||||
|
@ -32,6 +32,8 @@ use FireflyIII\Helpers\Filter\TransferFilter;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -50,8 +52,13 @@ class TagReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testAccountExpense()
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$tag = $this->user()->tags()->first();
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
|
||||
@ -62,7 +69,9 @@ class TagReportControllerTest extends TestCase
|
||||
$generator->shouldReceive('pieChart')->andReturn([])->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('chart.tag.account-expense', ['1', 'housing', '20120101', '20120131', 0]));
|
||||
|
||||
|
||||
$response = $this->get(route('chart.tag.account-expense', ['1', $tag->tag, '20120101', '20120131', 0]));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
@ -71,8 +80,13 @@ class TagReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testAccountIncome()
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$tag = $this->user()->tags()->first();
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
|
||||
@ -83,7 +97,8 @@ class TagReportControllerTest extends TestCase
|
||||
$generator->shouldReceive('pieChart')->andReturn([])->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('chart.tag.account-income', ['1', 'housing', '20120101', '20120131', 0]));
|
||||
|
||||
$response = $this->get(route('chart.tag.account-income', ['1', $tag->tag, '20120101', '20120131', 0]));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
@ -92,8 +107,13 @@ class TagReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testBudgetExpense()
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$tag = $this->user()->tags()->first();
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
|
||||
@ -104,7 +124,7 @@ class TagReportControllerTest extends TestCase
|
||||
$generator->shouldReceive('pieChart')->andReturn([])->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('chart.tag.budget-expense', ['1', 'housing', '20120101', '20120131', 0]));
|
||||
$response = $this->get(route('chart.tag.budget-expense', ['1', $tag->tag, '20120101', '20120131', 0]));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
@ -113,8 +133,13 @@ class TagReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testCategoryExpense()
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$tag = $this->user()->tags()->first();
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
|
||||
@ -125,7 +150,7 @@ class TagReportControllerTest extends TestCase
|
||||
$generator->shouldReceive('pieChart')->andReturn([])->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('chart.tag.category-expense', ['1', 'housing', '20120101', '20120131', 0]));
|
||||
$response = $this->get(route('chart.tag.category-expense', ['1', $tag->tag, '20120101', '20120131', 0]));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
@ -137,16 +162,22 @@ class TagReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testMainChart()
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$set = new Collection;
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$tag = $this->user()->tags()->first();
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$set = new Collection;
|
||||
for ($i = 0; $i < 10; ++$i) {
|
||||
$transaction = factory(Transaction::class)->make();
|
||||
$tag = factory(Tag::class)->make();
|
||||
$transaction->transactionJournal->tags()->save($tag);
|
||||
$set->push($transaction);
|
||||
}
|
||||
|
||||
$tag = $this->user()->tags()->first();
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::WITHDRAWAL, TransactionType::TRANSFER]])->andReturnSelf();
|
||||
@ -161,7 +192,7 @@ class TagReportControllerTest extends TestCase
|
||||
$generator->shouldReceive('multiSet')->andReturn([])->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('chart.tag.main', ['1', 'housing', '20120101', '20120131']));
|
||||
$response = $this->get(route('chart.tag.main', ['1', $tag->tag, '20120101', '20120131']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
@ -170,8 +201,13 @@ class TagReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testTagExpense()
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$tag = $this->user()->tags()->first();
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
|
||||
@ -182,7 +218,7 @@ class TagReportControllerTest extends TestCase
|
||||
$generator->shouldReceive('pieChart')->andReturn([])->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('chart.tag.tag-expense', ['1', 'housing', '20120101', '20120131', 0]));
|
||||
$response = $this->get(route('chart.tag.tag-expense', ['1', $tag->tag, '20120101', '20120131', 0]));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
@ -191,8 +227,13 @@ class TagReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testTagIncome()
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$tag = $this->user()->tags()->first();
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
|
||||
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
|
||||
@ -203,7 +244,7 @@ class TagReportControllerTest extends TestCase
|
||||
$generator->shouldReceive('pieChart')->andReturn([])->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('chart.tag.tag-income', ['1', 'housing', '20120101', '20120131', 0]));
|
||||
$response = $this->get(route('chart.tag.tag-income', ['1', $tag->tag, '20120101', '20120131', 0]));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ class CurrencyControllerTest extends TestCase
|
||||
public function testCannotCreate()
|
||||
{
|
||||
// mock stuff
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
@ -104,6 +105,7 @@ class CurrencyControllerTest extends TestCase
|
||||
public function testCreate()
|
||||
{
|
||||
// mock stuff
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
@ -123,6 +125,8 @@ class CurrencyControllerTest extends TestCase
|
||||
public function testDefaultCurrency()
|
||||
{
|
||||
// mock stuff
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
@ -182,6 +186,7 @@ class CurrencyControllerTest extends TestCase
|
||||
public function testEdit()
|
||||
{
|
||||
// mock stuff
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
|
@ -57,8 +57,6 @@ class HelpControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController::show
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController::getHelpText
|
||||
* @throws \Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testShowBackupFromCache()
|
||||
{
|
||||
@ -88,8 +86,6 @@ class HelpControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController::show
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController::getHelpText
|
||||
* @throws \Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testShowBackupFromGithub()
|
||||
{
|
||||
|
@ -88,6 +88,7 @@ class ConfigurationControllerTest extends TestCase
|
||||
$job = $this->user()->importJobs()->where('key', 'configuring')->first();
|
||||
$data = ['some' => 'config'];
|
||||
$configurator = $this->mock(FileConfigurator::class);
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$configurator->shouldReceive('setJob')->once();
|
||||
$configurator->shouldReceive('isJobConfigured')->once()->andReturn(false);
|
||||
$configurator->shouldReceive('configureJob')->once()->withArgs([$data]);
|
||||
@ -108,6 +109,7 @@ class ConfigurationControllerTest extends TestCase
|
||||
$job = $this->user()->importJobs()->where('key', 'configuring')->first();
|
||||
$data = ['some' => 'config'];
|
||||
$configurator = $this->mock(FileConfigurator::class);
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$configurator->shouldReceive('setJob')->once();
|
||||
$configurator->shouldReceive('isJobConfigured')->once()->andReturn(true);
|
||||
|
||||
|
@ -55,6 +55,7 @@ class IndexControllerTest extends TestCase
|
||||
*/
|
||||
public function testDownload()
|
||||
{
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
//$job = $this->user()->importJobs()->where('key', 'testImport')->first();
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('import.download', ['testImport']));
|
||||
@ -67,7 +68,7 @@ class IndexControllerTest extends TestCase
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('import.index'));
|
||||
$response->assertStatus(200);
|
||||
@ -79,6 +80,7 @@ class IndexControllerTest extends TestCase
|
||||
*/
|
||||
public function testStart()
|
||||
{
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$routine = $this->mock(FileRoutine::class);
|
||||
$routine->shouldReceive('setJob')->once();
|
||||
$routine->shouldReceive('run')->once()->andReturn(true);
|
||||
@ -94,6 +96,7 @@ class IndexControllerTest extends TestCase
|
||||
*/
|
||||
public function testStartFailed()
|
||||
{
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$routine = $this->mock(FileRoutine::class);
|
||||
$routine->shouldReceive('setJob')->once();
|
||||
$routine->shouldReceive('run')->once()->andReturn(false);
|
||||
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
use FireflyIII\Factory\AccountFactory;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
@ -50,7 +51,7 @@ class JavascriptControllerTest extends TestCase
|
||||
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]))
|
||||
->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->once();
|
||||
$currencyRepos->shouldReceive('findByCode')->withArgs(['EUR'])->andReturn(new TransactionCurrency);
|
||||
$currencyRepos->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(new TransactionCurrency);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('javascript.accounts'));
|
||||
@ -81,6 +82,10 @@ class JavascriptControllerTest extends TestCase
|
||||
*/
|
||||
public function testVariables(string $range)
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn(new Account);
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('javascript.variables'));
|
||||
@ -97,6 +102,11 @@ class JavascriptControllerTest extends TestCase
|
||||
*/
|
||||
public function testVariablesCustom(string $range)
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn(new Account);
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$this->session(['is_custom_range' => true]);
|
||||
|
@ -23,7 +23,12 @@ declare(strict_types=1);
|
||||
namespace Tests\Feature\Controllers\Json;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -58,6 +63,17 @@ class BoxControllerTest extends TestCase
|
||||
*/
|
||||
public function testBalance()
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
|
||||
// try a collector for income:
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
$collector->shouldReceive('setTypes')->andReturnSelf();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('getJournals')->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.box.balance'));
|
||||
$response->assertStatus(200);
|
||||
@ -68,6 +84,10 @@ class BoxControllerTest extends TestCase
|
||||
*/
|
||||
public function testBills()
|
||||
{
|
||||
$billRepos = $this->mock(BillRepositoryInterface::class);
|
||||
$billRepos->shouldReceive('getBillsPaidInRange')->andReturn('0');
|
||||
$billRepos->shouldReceive('getBillsUnpaidInRange')->andReturn('0');
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.box.bills'));
|
||||
$response->assertStatus(200);
|
||||
@ -78,6 +98,10 @@ class BoxControllerTest extends TestCase
|
||||
*/
|
||||
public function testNetWorth()
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.box.net-worth'));
|
||||
$response->assertStatus(200);
|
||||
@ -88,6 +112,11 @@ class BoxControllerTest extends TestCase
|
||||
*/
|
||||
public function testNetWorthFuture()
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$start = new Carbon;
|
||||
$start->addMonths(6)->startOfMonth();
|
||||
$end = clone $start;
|
||||
|
@ -22,8 +22,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -80,10 +82,12 @@ class NewUserControllerTest extends TestCase
|
||||
public function testSubmit()
|
||||
{
|
||||
// mock stuff
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('store')->times(2);
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$data = [
|
||||
'bank_name' => 'New bank',
|
||||
@ -103,10 +107,12 @@ class NewUserControllerTest extends TestCase
|
||||
public function testSubmitSingle()
|
||||
{
|
||||
// mock stuff
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('store')->twice();
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$data = [
|
||||
'bank_name' => 'New bank',
|
||||
|
@ -48,9 +48,10 @@ class PiggyBankControllerTest extends TestCase
|
||||
public function testAdd()
|
||||
{
|
||||
// mock stuff
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$piggyRepos->shouldReceive('getCurrentAmount')->andReturn('0');
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('piggy-banks.add', [1]));
|
||||
$response->assertStatus(200);
|
||||
@ -62,8 +63,10 @@ class PiggyBankControllerTest extends TestCase
|
||||
public function testAddMobile()
|
||||
{
|
||||
// mock stuff
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$piggyRepos->shouldReceive('getCurrentAmount')->andReturn('0');
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('piggy-banks.add-money-mobile', [1]));
|
||||
|
@ -98,15 +98,17 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testBalanceAmountDefaultNoBudget()
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$account = factory(Account::class)->make();
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$account = factory(Account::class)->make();
|
||||
|
||||
$popupHelper->shouldReceive('balanceForNoBudget')->once()->andReturn(new Collection);
|
||||
$budgetRepos->shouldReceive('find')->andReturn(new Budget)->once()->withArgs([0]);
|
||||
$accountRepos->shouldReceive('find')->andReturn($account)->once()->withArgs([1]);
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$arguments = [
|
||||
'attributes' => [
|
||||
@ -132,11 +134,12 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testBalanceAmountDefaultRole()
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$budget = factory(Budget::class)->make();
|
||||
$account = factory(Account::class)->make();
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$budget = factory(Budget::class)->make();
|
||||
$account = factory(Account::class)->make();
|
||||
|
||||
$budgetRepos->shouldReceive('find')->andReturn($budget)->once()->withArgs([1]);
|
||||
$accountRepos->shouldReceive('find')->andReturn($account)->once()->withArgs([1]);
|
||||
@ -167,9 +170,10 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testBalanceAmountDiffRole()
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
|
||||
$budget = factory(Budget::class)->make();
|
||||
$account = factory(Account::class)->make();
|
||||
@ -204,10 +208,11 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testBalanceAmountTagRole()
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budget = factory(Budget::class)->make();
|
||||
$account = factory(Account::class)->make();
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budget = factory(Budget::class)->make();
|
||||
$account = factory(Account::class)->make();
|
||||
|
||||
$budgetRepos->shouldReceive('find')->andReturn($budget)->once()->withArgs([1]);
|
||||
$accountRepos->shouldReceive('find')->andReturn($account)->once()->withArgs([1]);
|
||||
@ -238,9 +243,11 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testBudgetSpentAmount()
|
||||
{
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$budget = factory(Budget::class)->make();
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$budget = factory(Budget::class)->make();
|
||||
|
||||
$budgetRepos->shouldReceive('find')->andReturn($budget)->once()->withArgs([1]);
|
||||
$popupHelper->shouldReceive('byBudget')->andReturn(new Collection);
|
||||
@ -269,6 +276,9 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testCategoryEntry()
|
||||
{
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$category = factory(Category::class)->make();
|
||||
@ -300,9 +310,12 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testExpenseEntry()
|
||||
{
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$account = factory(Account::class)->make();
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$account = factory(Account::class)->make();
|
||||
|
||||
$accountRepos->shouldReceive('find')->withArgs([1])->andReturn($account)->once();
|
||||
$popupHelper->shouldReceive('byExpenses')->andReturn(new Collection);
|
||||
@ -331,9 +344,12 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testIncomeEntry()
|
||||
{
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$account = factory(Account::class)->make();
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$account = factory(Account::class)->make();
|
||||
|
||||
$accountRepos->shouldReceive('find')->withArgs([1])->andReturn($account)->once();
|
||||
$popupHelper->shouldReceive('byIncome')->andReturn(new Collection);
|
||||
|
@ -115,7 +115,6 @@ class ProfileControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::index
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::__construct
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
@ -155,6 +154,7 @@ class ProfileControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostChangeEmailExisting()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'email' => 'existing@example.com',
|
||||
];
|
||||
@ -173,7 +173,8 @@ class ProfileControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostChangeEmailSame()
|
||||
{
|
||||
$data = [
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$data = [
|
||||
'email' => $this->user()->email,
|
||||
];
|
||||
$this->be($this->user());
|
||||
@ -277,6 +278,7 @@ class ProfileControllerTest extends TestCase
|
||||
public function testPostDeleteAccountWrong()
|
||||
{
|
||||
// mock stuff
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$data = [
|
||||
@ -345,6 +347,7 @@ class ProfileControllerTest extends TestCase
|
||||
*/
|
||||
public function testUndoEmailChangeBadHash()
|
||||
{
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$hash = hash('sha256', 'previous@example.comX');
|
||||
$tokenPreference = new Preference;
|
||||
$tokenPreference->data = 'token';
|
||||
@ -369,6 +372,7 @@ class ProfileControllerTest extends TestCase
|
||||
*/
|
||||
public function testUndoEmailChangeBadToken()
|
||||
{
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
Preferences::shouldReceive('findByName')->once()->andReturn(new Collection);
|
||||
|
||||
$response = $this->get(route('profile.undo-email-change', ['token', 'some-hash']));
|
||||
|
@ -26,6 +26,7 @@ use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -42,15 +43,8 @@ class OperationsControllerTest extends TestCase
|
||||
*/
|
||||
public function testExpenses()
|
||||
{
|
||||
$transactions = factory(Transaction::class, 10)->make();
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::WITHDRAWAL, TransactionType::TRANSFER]])->andReturnSelf();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('addFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf();
|
||||
$collector->shouldReceive('getJournals')->andReturn($transactions);
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$tasker->shouldReceive('getExpenseReport')->andReturn([]);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('report-data.operations.expenses', ['1', '20160101', '20160131']));
|
||||
@ -62,15 +56,8 @@ class OperationsControllerTest extends TestCase
|
||||
*/
|
||||
public function testIncome()
|
||||
{
|
||||
$transactions = factory(Transaction::class, 10)->make();
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::DEPOSIT, TransactionType::TRANSFER]])->andReturnSelf();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('addFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf();
|
||||
$collector->shouldReceive('getJournals')->andReturn($transactions);
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$tasker->shouldReceive('getIncomeReport')->andReturn([]);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('report-data.operations.income', ['1', '20160101', '20160131']));
|
||||
@ -82,16 +69,9 @@ class OperationsControllerTest extends TestCase
|
||||
*/
|
||||
public function testOperations()
|
||||
{
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$transactions = factory(Transaction::class, 10)->make();
|
||||
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::DEPOSIT, TransactionType::TRANSFER]])->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::WITHDRAWAL, TransactionType::TRANSFER]])->andReturnSelf()->once();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('addFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf();
|
||||
$collector->shouldReceive('getJournals')->andReturn($transactions);
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$tasker->shouldReceive('getExpenseReport')->andReturn([]);
|
||||
$tasker->shouldReceive('getIncomeReport')->andReturn([]);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('report-data.operations.operations', ['1', '20160101', '20160131']));
|
||||
|
@ -57,10 +57,14 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testAccountReport()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
|
||||
$generator = $this->mock(AcYRG::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
|
||||
$generator->shouldReceive('setStartDate')->once();
|
||||
$generator->shouldReceive('setEndDate')->once();
|
||||
$generator->shouldReceive('setAccounts')->once();
|
||||
@ -77,6 +81,9 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testAuditReport()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
|
||||
$generator = $this->mock(AYRG::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
@ -96,6 +103,9 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testBudgetReport()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
|
||||
$generator = $this->mock(BYRG::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
@ -115,6 +125,9 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testCategoryReport()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
|
||||
$generator = $this->mock(CYRG::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
@ -134,6 +147,9 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testDefaultReport()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
|
||||
$generator = $this->mock(SYRG::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
@ -152,6 +168,9 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testDefaultReportBadDate()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -167,6 +186,9 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
|
||||
$helper = $this->mock(ReportHelperInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
@ -186,6 +208,8 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testOptions()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -200,6 +224,8 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testOptionsAccount()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$account = new Account();
|
||||
$account->name = 'Something';
|
||||
$account->id = 3;
|
||||
@ -222,6 +248,8 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testOptionsBudget()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
@ -240,6 +268,8 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testOptionsCategory()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
@ -257,6 +287,8 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testOptionsTag()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$tag = factory(Tag::class)->make();
|
||||
@ -273,7 +305,12 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexAccountOK()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->times(3);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$data = [
|
||||
@ -286,7 +323,7 @@ class ReportControllerTest extends TestCase
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('reports.index.post'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect(route('reports.report.account', ['1', '4', '20160101', '20160131']));
|
||||
$response->assertRedirect(route('reports.report.account', ['1', '1', '20160101', '20160131']));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -294,8 +331,13 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexAuditOK()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@ -314,8 +356,14 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexBudgetError()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@ -336,8 +384,15 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexBudgetOK()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
$budgetRepository->shouldReceive('findNull')->andReturn($this->user()->budgets()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@ -357,8 +412,14 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexCategoryError()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@ -379,8 +440,14 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexCategoryOK()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$categoryRepos->shouldReceive('findNull')->andReturn($this->user()->categories()->find(1))->twice();
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@ -400,8 +467,13 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexDefaultOK()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@ -420,8 +492,13 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexDefaultStartEnd()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@ -440,8 +517,13 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexTagError()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@ -462,8 +544,15 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexTagOK()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$tag = $this->user()->tags()->find(1);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
$tagRepos->shouldReceive('findByTag')->andReturn($tag)->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@ -475,7 +564,7 @@ class ReportControllerTest extends TestCase
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('reports.index.post'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect(route('reports.report.tag', ['1', 'housing', '20160101', '20160131']));
|
||||
$response->assertRedirect(route('reports.report.tag', ['1', $tag->tag, '20160101', '20160131']));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -483,7 +572,11 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexZeroAccounts()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$data = [
|
||||
@ -504,8 +597,18 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testTagReport()
|
||||
{
|
||||
$generator = $this->mock(TYRG::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$generator = $this->mock(TYRG::class);
|
||||
$tag = $this->user()->tags()->find(1);
|
||||
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$generator->shouldReceive('setStartDate')->once();
|
||||
$generator->shouldReceive('setEndDate')->once();
|
||||
@ -514,7 +617,7 @@ class ReportControllerTest extends TestCase
|
||||
$generator->shouldReceive('generate')->once()->andReturn('here-be-report');
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('reports.report.tag', [1, 'TagJanuary', '20160101', '20161231']));
|
||||
$response = $this->get(route('reports.report.tag', [1, $tag->tag, '20160101', '20161231']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Jobs\ExecuteRuleOnExistingTransactions;
|
||||
use FireflyIII\Jobs\Job;
|
||||
use FireflyIII\Models\Rule;
|
||||
@ -147,10 +148,12 @@ class RuleControllerTest extends TestCase
|
||||
public function testEdit()
|
||||
{
|
||||
// mock stuff
|
||||
$groupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('getPrimaryTrigger')->andReturn(new Rule);
|
||||
$groupRepos->shouldReceive('get')->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rules.edit', [1]));
|
||||
@ -176,10 +179,12 @@ class RuleControllerTest extends TestCase
|
||||
$this->session(['_old_input' => $old]);
|
||||
|
||||
// mock stuff
|
||||
$groupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('getPrimaryTrigger')->andReturn(new Rule);
|
||||
$groupRepos->shouldReceive('get')->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rules.edit', [1]));
|
||||
@ -192,6 +197,11 @@ class RuleControllerTest extends TestCase
|
||||
*/
|
||||
public function testExecute()
|
||||
{
|
||||
$account = $this->user()->accounts()->find(1);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||
$this->session(['first' => new Carbon('2010-01-01')]);
|
||||
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
|
||||
Queue::fake();
|
||||
|
||||
$data = [
|
||||
|
@ -47,6 +47,7 @@ class TagControllerTest extends TestCase
|
||||
public function testCreate()
|
||||
{
|
||||
// mock stuff
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -62,6 +63,7 @@ class TagControllerTest extends TestCase
|
||||
public function testDelete()
|
||||
{
|
||||
// mock stuff
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -94,6 +96,7 @@ class TagControllerTest extends TestCase
|
||||
public function testEdit()
|
||||
{
|
||||
// mock stuff
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
|
@ -46,8 +46,14 @@ class BulkControllerTest extends TestCase
|
||||
public function testEdit()
|
||||
{
|
||||
// mock stuff:
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Transfer');
|
||||
$journalRepos->shouldReceive('isJournalReconciled')->andReturn(false);
|
||||
|
||||
$transfers = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(4)->get()->pluck('id')->toArray();
|
||||
|
||||
@ -65,44 +71,21 @@ class BulkControllerTest extends TestCase
|
||||
public function testEditMultiple()
|
||||
{
|
||||
// mock stuff:
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')
|
||||
->andReturn(new Collection([1, 2, 3]), new Collection, new Collection, new Collection);
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')
|
||||
->andReturn(new Collection, new Collection([1, 2, 3]), new Collection, new Collection);
|
||||
$journalRepos->shouldReceive('getTransactionType')
|
||||
->andReturn('Withdrawal', 'Opening balance');
|
||||
$journalRepos->shouldReceive('isJournalReconciled')
|
||||
->andReturn(true, false);
|
||||
|
||||
// default transactions
|
||||
$collection = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(2)->get();
|
||||
|
||||
// add deposit (with multiple sources)
|
||||
$collection->push(
|
||||
TransactionJournal::where('transaction_type_id', 2)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->groupBy('transaction_journals.id')
|
||||
->orderBy('ct', 'DESC')
|
||||
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')])
|
||||
);
|
||||
|
||||
// add withdrawal (with multiple destinations)
|
||||
$collection->push(
|
||||
TransactionJournal::where('transaction_type_id', 1)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->groupBy('transaction_journals.id')
|
||||
->orderBy('ct', 'DESC')
|
||||
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')])
|
||||
);
|
||||
|
||||
// add reconcile transaction
|
||||
$collection->push(
|
||||
TransactionJournal::where('transaction_type_id', 5)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->groupBy('transaction_journals.id')
|
||||
->orderBy('ct', 'DESC')
|
||||
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')])
|
||||
);
|
||||
|
||||
// add opening balance:
|
||||
$collection->push(TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first());
|
||||
$collection = $this->user()->transactionJournals()->take(4)->get();
|
||||
$allIds = $collection->pluck('id')->toArray();
|
||||
$route = route('transactions.bulk.edit', join(',', $allIds));
|
||||
$this->be($this->user());
|
||||
@ -123,44 +106,22 @@ class BulkControllerTest extends TestCase
|
||||
public function testEditMultipleNothingLeft()
|
||||
{
|
||||
// mock stuff:
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')
|
||||
->andReturn(new Collection([1, 2, 3]), new Collection, new Collection, new Collection);
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')
|
||||
->andReturn(new Collection, new Collection([1, 2, 3]), new Collection, new Collection);
|
||||
$journalRepos->shouldReceive('getTransactionType')
|
||||
->andReturn('Withdrawal', 'Opening balance');
|
||||
$journalRepos->shouldReceive('isJournalReconciled')
|
||||
->andReturn(true, true);
|
||||
|
||||
|
||||
// default transactions
|
||||
$collection = new Collection;
|
||||
|
||||
// add deposit (with multiple sources)
|
||||
$collection->push(
|
||||
TransactionJournal::where('transaction_type_id', 2)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->groupBy('transaction_journals.id')
|
||||
->orderBy('ct', 'DESC')
|
||||
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')])
|
||||
);
|
||||
|
||||
// add withdrawal (with multiple destinations)
|
||||
$collection->push(
|
||||
TransactionJournal::where('transaction_type_id', 1)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->groupBy('transaction_journals.id')
|
||||
->orderBy('ct', 'DESC')
|
||||
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')])
|
||||
);
|
||||
|
||||
// add reconcile transaction
|
||||
$collection->push(
|
||||
TransactionJournal::where('transaction_type_id', 5)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->groupBy('transaction_journals.id')
|
||||
->orderBy('ct', 'DESC')
|
||||
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')])
|
||||
);
|
||||
|
||||
// add opening balance:
|
||||
$collection->push(TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first());
|
||||
$collection = $this->user()->transactionJournals()->take(4)->get();
|
||||
$allIds = $collection->pluck('id')->toArray();
|
||||
$route = route('transactions.bulk.edit', join(',', $allIds));
|
||||
$this->be($this->user());
|
||||
@ -181,7 +142,6 @@ class BulkControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
|
||||
$tags = ['a', 'b', 'c'];
|
||||
$collection = TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->take(4)->get();
|
||||
$allIds = $collection->pluck('id')->toArray();
|
||||
@ -198,7 +158,7 @@ class BulkControllerTest extends TestCase
|
||||
$repository->shouldReceive('find')->times(4)->andReturn(new TransactionJournal);
|
||||
|
||||
$repository->shouldReceive('updateCategory')->times(4)->andReturn(new TransactionJournal())
|
||||
->withArgs([Mockery::any(), $data['category']]);
|
||||
->withArgs([Mockery::any(), $data['category']]);
|
||||
|
||||
$repository->shouldReceive('updateBudget')->times(4)->andReturn(new TransactionJournal())
|
||||
->withArgs([Mockery::any(), $data['budget_id']]);
|
||||
@ -207,7 +167,6 @@ class BulkControllerTest extends TestCase
|
||||
->withArgs([Mockery::any(), $tags]);
|
||||
|
||||
|
||||
|
||||
$route = route('transactions.bulk.update');
|
||||
$this->be($this->user());
|
||||
$response = $this->post($route, $data);
|
||||
|
@ -48,9 +48,16 @@ class ConvertControllerTest extends TestCase
|
||||
public function testIndexDepositTransfer()
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getActiveAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->once()->andReturn(new Collection);
|
||||
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection)->once();
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection)->once();
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||
$response = $this->get(route('transactions.convert.index', ['transfer', $deposit->id]));
|
||||
@ -64,9 +71,15 @@ class ConvertControllerTest extends TestCase
|
||||
public function testIndexDepositWithdrawal()
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getActiveAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->once()->andReturn(new Collection);
|
||||
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection)->once();
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection)->once();
|
||||
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.convert.index', ['withdrawal', $deposit->id]));
|
||||
@ -80,9 +93,13 @@ class ConvertControllerTest extends TestCase
|
||||
public function testIndexSameType()
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getActiveAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->once()->andReturn(new Collection);
|
||||
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||
$response = $this->get(route('transactions.convert.index', ['deposit', $deposit->id]));
|
||||
@ -96,9 +113,13 @@ class ConvertControllerTest extends TestCase
|
||||
public function testIndexSplit()
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getActiveAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->once()->andReturn(new Collection);
|
||||
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
@ -117,9 +138,15 @@ class ConvertControllerTest extends TestCase
|
||||
public function testIndexTransferDeposit()
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getActiveAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->once()->andReturn(new Collection);
|
||||
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection)->once();
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection)->once();
|
||||
|
||||
$transfer = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->first();
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.convert.index', ['deposit', $transfer->id]));
|
||||
@ -133,9 +160,15 @@ class ConvertControllerTest extends TestCase
|
||||
public function testIndexTransferWithdrawal()
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getActiveAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->once()->andReturn(new Collection);
|
||||
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection)->once();
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection)->once();
|
||||
|
||||
$transfer = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->first();
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.convert.index', ['withdrawal', $transfer->id]));
|
||||
@ -149,9 +182,15 @@ class ConvertControllerTest extends TestCase
|
||||
public function testIndexWithdrawalDeposit()
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getActiveAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->once()->andReturn(new Collection);
|
||||
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection)->once();
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection)->once();
|
||||
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->first();
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.convert.index', ['deposit', $withdrawal->id]));
|
||||
@ -165,9 +204,15 @@ class ConvertControllerTest extends TestCase
|
||||
public function testIndexWithdrawalTransfer()
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getActiveAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->once()->andReturn(new Collection);
|
||||
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1')->once();
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection)->once();
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection)->once();
|
||||
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->first();
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.convert.index', ['transfer', $withdrawal->id]));
|
||||
@ -183,12 +228,18 @@ class ConvertControllerTest extends TestCase
|
||||
public function testPostIndexDepositTransfer()
|
||||
{
|
||||
// mock stuff
|
||||
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('convert')->andReturn(new MessageBag);
|
||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('find')->andReturn(new Account);
|
||||
$account = $this->user()->accounts()->first();
|
||||
$repository->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
$repository->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($account)->once();
|
||||
|
||||
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||
$data = ['source_account_asset' => 1];
|
||||
@ -206,12 +257,16 @@ class ConvertControllerTest extends TestCase
|
||||
public function testPostIndexDepositWithdrawal()
|
||||
{
|
||||
// mock stuff
|
||||
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('convert')->andReturn(new MessageBag);
|
||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('store')->andReturn(new Account);
|
||||
$account = $this->user()->accounts()->first();
|
||||
$repository->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
$repository->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||
$data = ['destination_account_expense' => 'New expense name.'];
|
||||
@ -236,6 +291,11 @@ class ConvertControllerTest extends TestCase
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getCashAccount')->andReturn(new Account)->once();
|
||||
|
||||
$account = $this->user()->accounts()->first();
|
||||
$repository->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
$repository->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
|
||||
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||
$data = ['destination_account_expense' => ''];
|
||||
$this->be($this->user());
|
||||
@ -251,6 +311,10 @@ class ConvertControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexErrored()
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$account = $this->user()->accounts()->first();
|
||||
|
||||
|
||||
// mock stuff
|
||||
$messageBag = new MessageBag;
|
||||
$messageBag->add('fake', 'fake error');
|
||||
@ -258,6 +322,11 @@ class ConvertControllerTest extends TestCase
|
||||
$repository->shouldReceive('convert')->andReturn($messageBag);
|
||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$repository->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
$repository->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($account)->once();
|
||||
|
||||
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->first();
|
||||
$data = [
|
||||
'destination_account_asset' => 2,
|
||||
@ -276,7 +345,8 @@ class ConvertControllerTest extends TestCase
|
||||
public function testPostIndexSameType()
|
||||
{
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('convert')->andReturn(new MessageBag);
|
||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -298,6 +368,7 @@ class ConvertControllerTest extends TestCase
|
||||
public function testPostIndexSplit()
|
||||
{
|
||||
// mock stuff
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('convert')->andReturn(new MessageBag);
|
||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
@ -332,6 +403,10 @@ class ConvertControllerTest extends TestCase
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('store')->andReturn(new Account)->once();
|
||||
|
||||
$account = $this->user()->accounts()->first();
|
||||
$repository->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
$repository->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
|
||||
$transfer = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->first();
|
||||
$data = ['source_account_revenue' => 'New rev'];
|
||||
$this->be($this->user());
|
||||
@ -355,6 +430,10 @@ class ConvertControllerTest extends TestCase
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('store')->andReturn(new Account)->once();
|
||||
|
||||
$account = $this->user()->accounts()->first();
|
||||
$repository->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
$repository->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->first();
|
||||
$data = ['source_account_revenue' => 'New revenue name.'];
|
||||
$this->be($this->user());
|
||||
@ -378,6 +457,10 @@ class ConvertControllerTest extends TestCase
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getCashAccount')->andReturn(new Account)->once();
|
||||
|
||||
$account = $this->user()->accounts()->first();
|
||||
$repository->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
$repository->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->first();
|
||||
$data = ['source_account_revenue' => ''];
|
||||
$this->be($this->user());
|
||||
@ -399,12 +482,14 @@ class ConvertControllerTest extends TestCase
|
||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('find')->andReturn(new Account);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn(new Account);
|
||||
|
||||
$account = $this->user()->accounts()->first();
|
||||
$repository->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
$repository->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]))->twice();
|
||||
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->first();
|
||||
$data = [
|
||||
'destination_account_asset' => 2,
|
||||
];
|
||||
$data = ['destination_account_asset' => 2,];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.convert.index', ['transfer', $withdrawal->id]), $data);
|
||||
$response->assertStatus(302);
|
||||
|
@ -41,6 +41,10 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.link.delete', [1]));
|
||||
$response->assertStatus(200);
|
||||
@ -51,8 +55,12 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testDestroy()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
|
||||
$repository->shouldReceive('destroyLink');
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
|
||||
$this->session(['journal_links.delete.uri' => 'http://localhost/']);
|
||||
@ -117,11 +125,15 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreInvalid()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$data = [
|
||||
'link_other' => 0,
|
||||
'link_type' => '1_inward',
|
||||
];
|
||||
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.link.store', [1]), $data);
|
||||
$response->assertStatus(302);
|
||||
@ -134,7 +146,9 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testSwitchLink()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('switchLink')->andReturn(false);
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.link.switch', [1]));
|
||||
|
@ -46,6 +46,10 @@ class MassControllerTest extends TestCase
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
|
||||
$withdrawals = TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->take(2)->get()->pluck('id')->toArray();
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.mass.delete', $withdrawals));
|
||||
@ -60,6 +64,7 @@ class MassControllerTest extends TestCase
|
||||
*/
|
||||
public function testDestroy()
|
||||
{
|
||||
|
||||
$deposits = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->take(2)->get();
|
||||
$depositIds = $deposits->pluck('id')->toArray();
|
||||
|
||||
@ -85,6 +90,20 @@ class MassControllerTest extends TestCase
|
||||
*/
|
||||
public function testEdit()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
$transfers = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(2)->get();
|
||||
$transfersArray = $transfers->pluck('id')->toArray();
|
||||
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
// mock data for edit page:
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Transfer');
|
||||
$journalRepos->shouldReceive('isJournalReconciled')->andReturn(false);
|
||||
$journalRepos->shouldReceive('getFirstPosTransaction')->andReturn($transfers->first()->transactions()->first());
|
||||
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||
@ -93,10 +112,10 @@ class MassControllerTest extends TestCase
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection);
|
||||
|
||||
$transfers = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(2)->get()->pluck('id')->toArray();
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.mass.edit', $transfers));
|
||||
$response = $this->get(route('transactions.mass.edit', $transfersArray));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('Edit a number of transactions');
|
||||
// has bread crumb
|
||||
@ -108,45 +127,30 @@ class MassControllerTest extends TestCase
|
||||
*/
|
||||
public function testEditMultiple()
|
||||
{
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection);
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')
|
||||
->andReturn(new Collection([1, 2, 3]), new Collection, new Collection, new Collection);
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')
|
||||
->andReturn(new Collection, new Collection([1, 2, 3]), new Collection, new Collection);
|
||||
$journalRepos->shouldReceive('getTransactionType')
|
||||
->andReturn('Withdrawal', 'Opening balance');
|
||||
$journalRepos->shouldReceive('isJournalReconciled')
|
||||
->andReturn(true, false);
|
||||
|
||||
|
||||
// default transactions
|
||||
$collection = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(2)->get();
|
||||
|
||||
// add deposit (with multiple sources)
|
||||
$collection->push(
|
||||
TransactionJournal::where('transaction_type_id', 2)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->groupBy('transaction_journals.id')
|
||||
->orderBy('ct', 'DESC')
|
||||
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')])
|
||||
);
|
||||
|
||||
// add withdrawal (with multiple destinations)
|
||||
$collection->push(
|
||||
TransactionJournal::where('transaction_type_id', 1)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->groupBy('transaction_journals.id')
|
||||
->orderBy('ct', 'DESC')
|
||||
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')])
|
||||
);
|
||||
|
||||
// add reconcile transaction
|
||||
$collection->push(
|
||||
TransactionJournal::where('transaction_type_id', 5)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->groupBy('transaction_journals.id')
|
||||
->orderBy('ct', 'DESC')
|
||||
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')])
|
||||
);
|
||||
|
||||
// add opening balance:
|
||||
$collection->push(TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first());
|
||||
$collection = $this->user()->transactionJournals()->take(4)->get();
|
||||
$allIds = $collection->pluck('id')->toArray();
|
||||
$route = route('transactions.mass.edit', join(',', $allIds));
|
||||
$this->be($this->user());
|
||||
@ -165,20 +169,28 @@ class MassControllerTest extends TestCase
|
||||
*/
|
||||
public function testEditMultipleNothingLeft()
|
||||
{
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection);
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')
|
||||
->andReturn(new Collection([1, 2, 3]), new Collection, new Collection, new Collection);
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')
|
||||
->andReturn(new Collection, new Collection([1, 2, 3]), new Collection, new Collection);
|
||||
$journalRepos->shouldReceive('getTransactionType')
|
||||
->andReturn('Withdrawal', 'Opening balance');
|
||||
$journalRepos->shouldReceive('isJournalReconciled')
|
||||
->andReturn(true, true);
|
||||
|
||||
// default transactions
|
||||
$collection = new Collection;
|
||||
$collection->push(
|
||||
TransactionJournal::where('transaction_type_id', 1)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->groupBy('transaction_journals.id')
|
||||
->orderBy('ct', 'DESC')
|
||||
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')])
|
||||
);
|
||||
$collection = $this->user()->transactionJournals()->take(4)->get();
|
||||
$allIds = $collection->pluck('id')->toArray();
|
||||
|
||||
$this->be($this->user());
|
||||
@ -198,11 +210,13 @@ class MassControllerTest extends TestCase
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)
|
||||
->whereNull('deleted_at')
|
||||
->first();
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('update')->once();
|
||||
$repository->shouldReceive('find')->once()->andReturn($deposit);
|
||||
$repository->shouldReceive('getTransactionType')->andReturn('Deposit');
|
||||
|
||||
$this->session(['transactions.mass-edit.uri' => 'http://localhost']);
|
||||
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace Tests\Feature\Controllers\Transaction;
|
||||
|
||||
use DB;
|
||||
use Exception;
|
||||
use FireflyIII\Events\StoredTransactionJournal;
|
||||
use FireflyIII\Events\UpdatedTransactionJournal;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
@ -32,8 +33,12 @@ use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalTaskerInterface;
|
||||
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Support\Collection;
|
||||
@ -55,12 +60,26 @@ class SingleControllerTest extends TestCase
|
||||
*/
|
||||
public function testCloneTransaction()
|
||||
{
|
||||
$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')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$account = $this->user()->accounts()->first();
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]));
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]));
|
||||
$journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0);
|
||||
$journalRepos->shouldReceive('getJournalCategoryName')->andReturn('');
|
||||
$journalRepos->shouldReceive('getTags')->andReturn([]);
|
||||
|
||||
$note = new Note();
|
||||
$note->id = 5;
|
||||
$note->text = 'I see you...';
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('getNote')->andReturn($note)->once();
|
||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getNote')->andReturn($note)->once();
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)->whereNull('deleted_at')->where('user_id', $this->user()->id)->first();
|
||||
@ -75,13 +94,18 @@ class SingleControllerTest extends TestCase
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$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')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$accounts = $this->user()->accounts()->where('account_type_id', 3)->get();
|
||||
Steam::shouldReceive('phpBytes')->andReturn(2048);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getActiveAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn($accounts);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn($accounts);
|
||||
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection)->once();
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$piggyRepos->shouldReceive('getPiggyBanksWithAmount')->andReturn(new Collection)->once();
|
||||
|
||||
$this->be($this->user());
|
||||
@ -96,6 +120,14 @@ class SingleControllerTest extends TestCase
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
$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')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)->whereNull('deleted_at')->where('user_id', $this->user()->id)->first();
|
||||
$response = $this->get(route('transactions.delete', [$withdrawal->id]));
|
||||
@ -109,10 +141,15 @@ class SingleControllerTest extends TestCase
|
||||
*/
|
||||
public function testDestroy()
|
||||
{
|
||||
// mock
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('destroy')->once();
|
||||
$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);
|
||||
$journalRepos->shouldReceive('destroy')->once();
|
||||
|
||||
$this->session(['transactions.delete.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
@ -129,15 +166,20 @@ class SingleControllerTest extends TestCase
|
||||
*/
|
||||
public function testEdit()
|
||||
{
|
||||
$account = $this->user()->accounts()->first();
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||
$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')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$account = $this->user()->accounts()->first();
|
||||
$accountRepos->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('countTransactions')->andReturn(2)->once();
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Withdrawal')->once();
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->once();
|
||||
@ -164,15 +206,19 @@ class SingleControllerTest extends TestCase
|
||||
*/
|
||||
public function testEditCashDeposit()
|
||||
{
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||
$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);
|
||||
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();
|
||||
|
||||
$account = $this->user()->accounts()->first();
|
||||
$cash = $this->user()->accounts()->where('account_type_id', 2)->first();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$account = $this->user()->accounts()->first();
|
||||
$cash = $this->user()->accounts()->where('account_type_id', 2)->first();
|
||||
|
||||
$journalRepos->shouldReceive('countTransactions')->andReturn(2)->once();
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Deposit')->once();
|
||||
@ -194,8 +240,6 @@ class SingleControllerTest extends TestCase
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->where('transaction_journals.user_id', $this->user()->id)->first(['transactions.*']);
|
||||
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn($deposit->transactionJournal);
|
||||
|
||||
$response = $this->get(route('transactions.edit', [$deposit->transaction_journal_id]));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
@ -209,15 +253,20 @@ class SingleControllerTest extends TestCase
|
||||
*/
|
||||
public function testEditCashWithdrawal()
|
||||
{
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||
$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);
|
||||
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$accountRepos->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();
|
||||
|
||||
$account = $this->user()->accounts()->first();
|
||||
$cash = $this->user()->accounts()->where('account_type_id', 2)->first();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$account = $this->user()->accounts()->first();
|
||||
$cash = $this->user()->accounts()->where('account_type_id', 2)->first();
|
||||
|
||||
$journalRepos->shouldReceive('countTransactions')->andReturn(2)->once();
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Withdrawal')->once();
|
||||
@ -238,9 +287,7 @@ class SingleControllerTest extends TestCase
|
||||
->where('transaction_journals.transaction_type_id', 1)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->where('transaction_journals.user_id', $this->user()->id)->first(['transactions.*']);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn($withdrawal->transactionJournal);
|
||||
|
||||
$response = $this->get(route('transactions.edit', [$withdrawal->transaction_journal_id]));
|
||||
$response = $this->get(route('transactions.edit', [$withdrawal->transaction_journal_id]));
|
||||
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
@ -254,8 +301,14 @@ class SingleControllerTest extends TestCase
|
||||
*/
|
||||
public function testEditReconcile()
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('getTransactionType')->andReturn('Reconciliation')->once();
|
||||
$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('getTransactionType')->andReturn('Reconciliation')->once();
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
$reconcile = TransactionJournal::where('transaction_type_id', 5)
|
||||
@ -265,8 +318,6 @@ class SingleControllerTest extends TestCase
|
||||
->orderBy('ct', 'DESC')
|
||||
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')]);
|
||||
|
||||
$repository->shouldReceive('first')->once()->andReturn($reconcile);
|
||||
|
||||
$response = $this->get(route('transactions.edit', [$reconcile->id]));
|
||||
$response->assertStatus(302);
|
||||
}
|
||||
@ -277,7 +328,13 @@ class SingleControllerTest extends TestCase
|
||||
*/
|
||||
public function testEditRedirect()
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$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);
|
||||
|
||||
$this->be($this->user());
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)
|
||||
@ -286,9 +343,9 @@ class SingleControllerTest extends TestCase
|
||||
->groupBy('transaction_journals.id')
|
||||
->orderBy('ct', 'DESC')
|
||||
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')]);
|
||||
$repository->shouldReceive('first')->once()->andReturn($withdrawal);
|
||||
$repository->shouldReceive('getTransactionType')->andReturn('Withdrawal');
|
||||
$repository->shouldReceive('countTransactions')->andReturn(3);
|
||||
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Withdrawal');
|
||||
$journalRepos->shouldReceive('countTransactions')->andReturn(3);
|
||||
$response = $this->get(route('transactions.edit', [$withdrawal->id]));
|
||||
|
||||
|
||||
@ -301,10 +358,16 @@ class SingleControllerTest extends TestCase
|
||||
*/
|
||||
public function testEditTransferWithForeignAmount()
|
||||
{
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||
$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);
|
||||
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$accountRepos->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();
|
||||
|
||||
$this->be($this->user());
|
||||
@ -319,9 +382,7 @@ class SingleControllerTest extends TestCase
|
||||
->whereNotNull('transactions.foreign_amount')
|
||||
->first(['transaction_journals.*']);
|
||||
|
||||
$account = $this->user()->accounts()->first();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn($withdrawal);
|
||||
$account = $this->user()->accounts()->first();
|
||||
$journalRepos->shouldReceive('countTransactions')->andReturn(2)->once();
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Transfer')->once();
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->once();
|
||||
@ -346,10 +407,16 @@ class SingleControllerTest extends TestCase
|
||||
*/
|
||||
public function testEditWithForeignAmount()
|
||||
{
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||
$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);
|
||||
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$accountRepos->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection)->once();
|
||||
|
||||
$this->be($this->user());
|
||||
@ -364,9 +431,7 @@ class SingleControllerTest extends TestCase
|
||||
->whereNotNull('transactions.foreign_amount')
|
||||
->first(['transaction_journals.*']);
|
||||
|
||||
$account = $this->user()->accounts()->first();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn($withdrawal);
|
||||
$account = $this->user()->accounts()->first();
|
||||
$journalRepos->shouldReceive('countTransactions')->andReturn(2)->once();
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Withdrawal')->once();
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]))->once();
|
||||
@ -392,12 +457,19 @@ class SingleControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreError()
|
||||
{
|
||||
|
||||
$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:
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$journal = new TransactionJournal();
|
||||
$journal->description = 'New journal';
|
||||
$repository->shouldReceive('store')->andReturn($journal);
|
||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('store')->andReturn($journal);
|
||||
$this->session(['transactions.create.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
|
||||
@ -418,17 +490,23 @@ class SingleControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::store
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::groupedActiveAccountList
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testStoreSuccess()
|
||||
{
|
||||
|
||||
$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:
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$journal = new TransactionJournal();
|
||||
$journal->id = 1000;
|
||||
$journal->description = 'New journal';
|
||||
$repository->shouldReceive('store')->andReturn($journal);
|
||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('store')->andReturn($journal);
|
||||
$this->expectsEvents(StoredTransactionJournal::class);
|
||||
|
||||
$errors = new MessageBag;
|
||||
@ -438,10 +516,9 @@ class SingleControllerTest extends TestCase
|
||||
$messages->add('attachments', 'Fake error');
|
||||
|
||||
// mock attachment helper, trigger an error AND and info thing.
|
||||
$attachmentRepo = $this->mock(AttachmentHelperInterface::class);
|
||||
$attachmentRepo->shouldReceive('saveAttachmentsForModel');
|
||||
$attachmentRepo->shouldReceive('getErrors')->andReturn($errors);
|
||||
$attachmentRepo->shouldReceive('getMessages')->andReturn($messages);
|
||||
$attRepos->shouldReceive('saveAttachmentsForModel');
|
||||
$attRepos->shouldReceive('getErrors')->andReturn($errors);
|
||||
$attRepos->shouldReceive('getMessages')->andReturn($messages);
|
||||
|
||||
$this->session(['transactions.create.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
@ -464,23 +541,43 @@ class SingleControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::update
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
$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);
|
||||
$tasker = $this->mock(JournalTaskerInterface::class);
|
||||
$linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Withdrawal');
|
||||
|
||||
$linkRepos->shouldReceive('get')->andReturn(new Collection);
|
||||
$linkRepos->shouldReceive('getLinks')->andReturn(new Collection);
|
||||
$attRepos->shouldReceive('saveAttachmentsForModel');
|
||||
$attRepos->shouldReceive('getErrors')->andReturn(new MessageBag);
|
||||
$attRepos->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||
$tasker->shouldReceive('getPiggyBankEvents')->andReturn(new Collection);
|
||||
$tasker->shouldReceive('getTransactionsOverview')->andReturn([]);
|
||||
|
||||
// mock
|
||||
$this->expectsEvents(UpdatedTransactionJournal::class);
|
||||
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$journal = new TransactionJournal();
|
||||
try {
|
||||
$this->expectsEvents(UpdatedTransactionJournal::class);
|
||||
} catch (Exception $e) {
|
||||
$this->assertTrue(false, 'expectsEvents failed!');
|
||||
}
|
||||
|
||||
$journal = new TransactionJournal();
|
||||
$type = TransactionType::find(1);
|
||||
$journal->id = 1000;
|
||||
$journal->description = 'New journal';
|
||||
$journal->transactionType()->associate($type);
|
||||
|
||||
$repository->shouldReceive('update')->andReturn($journal);
|
||||
$repository->shouldReceive('first')->times(2)->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('update')->andReturn($journal);
|
||||
|
||||
$this->session(['transactions.edit.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
|
@ -24,14 +24,15 @@ namespace Tests\Feature\Controllers\Transaction;
|
||||
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalTaskerInterface;
|
||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Tests\TestCase;
|
||||
@ -57,12 +58,15 @@ class SplitControllerTest extends TestCase
|
||||
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
|
||||
$account = $destination->account;
|
||||
$transactions = factory(Transaction::class, 3)->make();
|
||||
$tasker = $this->mock(JournalTaskerInterface::class);
|
||||
$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();
|
||||
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn($deposit);
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]));
|
||||
@ -73,6 +77,7 @@ class SplitControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->once();
|
||||
$journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0);
|
||||
$journalRepos->shouldReceive('getCategoryName')->andReturn('');
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('0');
|
||||
|
||||
|
||||
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
|
||||
@ -101,11 +106,13 @@ class SplitControllerTest extends TestCase
|
||||
$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);
|
||||
$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();
|
||||
$tasker = $this->mock(JournalTaskerInterface::class);
|
||||
|
||||
|
||||
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
|
||||
$accountRepository->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])
|
||||
@ -122,6 +129,7 @@ class SplitControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->once();
|
||||
$journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0);
|
||||
$journalRepos->shouldReceive('getCategoryName')->andReturn('');
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('0');
|
||||
|
||||
|
||||
$old = [
|
||||
@ -189,7 +197,12 @@ class SplitControllerTest extends TestCase
|
||||
*/
|
||||
public function testEditOpeningBalance()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$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);
|
||||
|
||||
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn($opening);
|
||||
@ -210,22 +223,25 @@ class SplitControllerTest extends TestCase
|
||||
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$transactions = factory(Transaction::class, 1)->make();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$attHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$tasker = $this->mock(JournalTaskerInterface::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;
|
||||
|
||||
$repository->shouldReceive('first')->once()->andReturn($deposit);
|
||||
$repository->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]));
|
||||
$repository->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]));
|
||||
$repository->shouldReceive('getTransactionType')->once()->andReturn('Deposit');
|
||||
$repository->shouldReceive('getJournalDate')->once()->andReturn('2018-01-01');
|
||||
$repository->shouldReceive('getMetaField')->andReturn('');
|
||||
$repository->shouldReceive('getNoteText')->andReturn('Some note')->once();
|
||||
$repository->shouldReceive('getJournalBudgetId')->andReturn(0);
|
||||
$repository->shouldReceive('getCategoryName')->andReturn('');
|
||||
$transactions = factory(Transaction::class, 1)->make();
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
|
||||
$account = $destination->account;
|
||||
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn($deposit);
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$account]));
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$account]));
|
||||
$journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Deposit');
|
||||
$journalRepos->shouldReceive('getJournalDate')->once()->andReturn('2018-01-01');
|
||||
$journalRepos->shouldReceive('getMetaField')->andReturn('');
|
||||
$journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->once();
|
||||
$journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0);
|
||||
$journalRepos->shouldReceive('getCategoryName')->andReturn('');
|
||||
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1');
|
||||
|
||||
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
|
||||
$accountRepository->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])
|
||||
@ -247,6 +263,19 @@ class SplitControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
$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']);
|
||||
$deposit = $this->user()->transactionJournals()->where('transaction_type_id', 2)->first();
|
||||
$data = [
|
||||
@ -270,14 +299,12 @@ class SplitControllerTest extends TestCase
|
||||
];
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('update')->andReturn($deposit);
|
||||
$repository->shouldReceive('first')->andReturn($deposit);
|
||||
$repository->shouldReceive('getTransactionType')->andReturn('Deposit');
|
||||
$journalRepos->shouldReceive('update')->andReturn($deposit);
|
||||
$journalRepos->shouldReceive('first')->andReturn($deposit);
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Deposit');
|
||||
|
||||
$attachmentRepos = $this->mock(AttachmentHelperInterface::class);
|
||||
$attachmentRepos->shouldReceive('saveAttachmentsForModel');
|
||||
$attachmentRepos->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||
$attHelper->shouldReceive('saveAttachmentsForModel');
|
||||
$attHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.split.update', [$deposit->id]), $data);
|
||||
@ -292,7 +319,13 @@ class SplitControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateOpeningBalance()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$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);
|
||||
|
||||
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
|
||||
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
|
||||
$data = [
|
||||
|
@ -24,7 +24,10 @@ declare(strict_types=1);
|
||||
namespace Tests;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
use Log;
|
||||
@ -37,19 +40,20 @@ use Mockery;
|
||||
*/
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
use CreatesApplication;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param string $range
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function changeDateRange(User $user, $range)
|
||||
{
|
||||
$valid = ['1D', '1W', '1M', '3M', '6M', '1Y', 'custom'];
|
||||
if (in_array($range, $valid)) {
|
||||
Preference::where('user_id', $user->id)->where('name', 'viewRange')->delete();
|
||||
try {
|
||||
Preference::where('user_id', $user->id)->where('name', 'viewRange')->delete();
|
||||
} catch (Exception $e) {
|
||||
// don't care.
|
||||
}
|
||||
|
||||
Preference::create(
|
||||
[
|
||||
'user_id' => $user->id,
|
||||
@ -69,6 +73,8 @@ abstract class TestCase extends BaseTestCase
|
||||
}
|
||||
}
|
||||
|
||||
use CreatesApplication;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@ -141,4 +147,14 @@ abstract class TestCase extends BaseTestCase
|
||||
//$this->app->instance($class, $externalMock);
|
||||
return $externalMock;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* TODO test split transaction.
|
||||
*
|
||||
* Class TransactionTransformerTest
|
||||
*/
|
||||
class TransactionTransformerTest extends TestCase
|
||||
@ -48,7 +50,7 @@ class TransactionTransformerTest extends TestCase
|
||||
* Basic journal (withdrawal)
|
||||
*
|
||||
* @covers \FireflyIII\Transformers\TransactionTransformer::transform
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testBasic()
|
||||
{
|
||||
@ -131,7 +133,7 @@ class TransactionTransformerTest extends TestCase
|
||||
* Basic journal (withdrawal)
|
||||
*
|
||||
* @covers \FireflyIII\Transformers\TransactionTransformer::transform
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testDeposit()
|
||||
{
|
||||
@ -214,7 +216,7 @@ class TransactionTransformerTest extends TestCase
|
||||
* Deposit cannot have a budget
|
||||
*
|
||||
* @covers \FireflyIII\Transformers\TransactionTransformer::transform
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testDepositBudget()
|
||||
{
|
||||
@ -306,7 +308,7 @@ class TransactionTransformerTest extends TestCase
|
||||
* Basic journal (withdrawal) with a foreign amount.
|
||||
*
|
||||
* @covers \FireflyIII\Transformers\TransactionTransformer::transform
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testForeignAmount()
|
||||
{
|
||||
@ -397,7 +399,7 @@ class TransactionTransformerTest extends TestCase
|
||||
* Basic journal (withdrawal) with a budget
|
||||
*
|
||||
* @covers \FireflyIII\Transformers\TransactionTransformer::transform
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testJournalBudget()
|
||||
{
|
||||
@ -494,7 +496,7 @@ class TransactionTransformerTest extends TestCase
|
||||
* Basic journal (withdrawal) with a category
|
||||
*
|
||||
* @covers \FireflyIII\Transformers\TransactionTransformer::transform
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testJournalCategory()
|
||||
{
|
||||
@ -591,7 +593,7 @@ class TransactionTransformerTest extends TestCase
|
||||
* Basic journal (opening balance)
|
||||
*
|
||||
* @covers \FireflyIII\Transformers\TransactionTransformer::transform
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testOpeningBalanceNeg()
|
||||
{
|
||||
@ -675,7 +677,7 @@ class TransactionTransformerTest extends TestCase
|
||||
* Basic journal (opening balance)
|
||||
*
|
||||
* @covers \FireflyIII\Transformers\TransactionTransformer::transform
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testOpeningBalancePos()
|
||||
{
|
||||
@ -759,7 +761,7 @@ class TransactionTransformerTest extends TestCase
|
||||
* Basic journal (reconciliation)
|
||||
*
|
||||
* @covers \FireflyIII\Transformers\TransactionTransformer::transform
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testReconciliationNeg()
|
||||
{
|
||||
@ -843,7 +845,7 @@ class TransactionTransformerTest extends TestCase
|
||||
* Basic journal (reconciliation)
|
||||
*
|
||||
* @covers \FireflyIII\Transformers\TransactionTransformer::transform
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testReconciliationPos()
|
||||
{
|
||||
@ -927,7 +929,7 @@ class TransactionTransformerTest extends TestCase
|
||||
* Basic journal (withdrawal) with budget on the transactions.
|
||||
*
|
||||
* @covers \FireflyIII\Transformers\TransactionTransformer::transform
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testTransactionBudget()
|
||||
{
|
||||
@ -1026,7 +1028,7 @@ class TransactionTransformerTest extends TestCase
|
||||
* Basic journal (withdrawal) with a category on the transactions
|
||||
*
|
||||
* @covers \FireflyIII\Transformers\TransactionTransformer::transform
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testTransactionCategory()
|
||||
{
|
||||
@ -1124,7 +1126,7 @@ class TransactionTransformerTest extends TestCase
|
||||
* Basic journal (withdrawal) with a description for transactions.
|
||||
*
|
||||
* @covers \FireflyIII\Transformers\TransactionTransformer::transform
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testTransactionDescription()
|
||||
{
|
||||
@ -1207,7 +1209,7 @@ class TransactionTransformerTest extends TestCase
|
||||
* Basic journal (transfer)
|
||||
*
|
||||
* @covers \FireflyIII\Transformers\TransactionTransformer::transform
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testTransferOne()
|
||||
{
|
||||
@ -1290,7 +1292,7 @@ class TransactionTransformerTest extends TestCase
|
||||
* Basic journal (transfer)
|
||||
*
|
||||
* @covers \FireflyIII\Transformers\TransactionTransformer::transform
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function testTransferTwo()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user