mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Code cleanup and realign.
This commit is contained in:
@@ -27,7 +27,6 @@ namespace Tests\Feature\Controllers\Account;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
|
@@ -30,8 +30,9 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class DeleteControllerTest
|
||||
@@ -46,6 +47,7 @@ class DeleteControllerTest extends TestCase
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\DeleteController
|
||||
* @covers \FireflyIII\Http\Controllers\Controller
|
||||
|
@@ -26,16 +26,16 @@ namespace Tests\Feature\Controllers\Account;
|
||||
|
||||
use Amount;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Note;
|
||||
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 Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class EditControllerTest
|
||||
@@ -50,6 +50,7 @@ class EditControllerTest extends TestCase
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\EditController
|
||||
*/
|
||||
|
@@ -32,8 +32,8 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class ConfigurationControllerTest
|
||||
@@ -217,7 +217,7 @@ class ReconcileControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('store')->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('getReconciliation')->andReturn(new Account);
|
||||
$repository->shouldReceive('findNull')->andReturn(new Account);
|
||||
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(),'currency_id'])->andReturn('1');
|
||||
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
|
||||
$data = [
|
||||
'transactions' => [1, 2, 3],
|
||||
|
@@ -147,7 +147,7 @@ class ShowControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ShowController
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ShowController
|
||||
* @expectedExceptionMessage End is after start!
|
||||
*/
|
||||
public function testShowBrokenBadDates(): void
|
||||
@@ -165,7 +165,7 @@ class ShowControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ShowController
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ShowController
|
||||
* @expectedExceptionMessage Expected a transaction
|
||||
*/
|
||||
public function testShowBrokenInitial(): void
|
||||
|
@@ -97,8 +97,8 @@ class UpdateControllerTest extends TestCase
|
||||
FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
|
||||
FireflyConfig::shouldReceive('set')->withArgs(['last_update_check', Mockery::any()])->once()->andReturn(new Configuration);
|
||||
|
||||
$version = config('firefly.version');
|
||||
$date = new Carbon;
|
||||
$version = config('firefly.version');
|
||||
$date = new Carbon;
|
||||
$date->subDays(5);
|
||||
$releases = [
|
||||
new Release(['id' => 'x', 'title' => $version . '.1', 'content' => '', 'updated' => $date]),
|
||||
|
@@ -96,7 +96,7 @@ class UserControllerTest extends TestCase
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
//$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->once()->andReturn(false);
|
||||
$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->times(3)->andReturn(true);
|
||||
$user = $this->user();
|
||||
$user = $this->user();
|
||||
$repository->shouldReceive('all')->andReturn(new Collection([$user]));
|
||||
|
||||
$this->be($user);
|
||||
|
@@ -139,7 +139,7 @@ class AttachmentControllerTest extends TestCase
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$repository->shouldReceive('get')->andReturn(new Collection([Attachment::first()]))->once();
|
||||
$repository->shouldReceive('exists')->andReturn(true)->once();
|
||||
|
||||
|
@@ -74,8 +74,8 @@ class TwoFactorControllerTest extends TestCase
|
||||
|
||||
$falsePreference = new Preference;
|
||||
$falsePreference->data = false;
|
||||
$langPreference = new Preference;
|
||||
$langPreference->data = 'en_US';
|
||||
$langPreference = new Preference;
|
||||
$langPreference->data = 'en_US';
|
||||
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($falsePreference)->twice();
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn(null)->once();
|
||||
|
@@ -27,7 +27,6 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
@@ -65,9 +64,9 @@ class BillControllerTest extends TestCase
|
||||
public function testCreate(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
@@ -83,9 +82,9 @@ class BillControllerTest extends TestCase
|
||||
public function testDelete(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
@@ -101,10 +100,10 @@ class BillControllerTest extends TestCase
|
||||
public function testDestroy(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@@ -121,9 +120,9 @@ class BillControllerTest extends TestCase
|
||||
public function testEdit(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
@@ -140,11 +139,11 @@ class BillControllerTest extends TestCase
|
||||
public function testIndex(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$bill = factory(Bill::class)->make();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$bill = factory(Bill::class)->make();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$collection = new Collection([$bill]);
|
||||
$repository->shouldReceive('getPaginator')->andReturn(new LengthAwarePaginator($collection, 1, 50))->once();
|
||||
@@ -166,12 +165,12 @@ class BillControllerTest extends TestCase
|
||||
public function testRescan(): void
|
||||
{
|
||||
// mock stuff
|
||||
$rule = Rule::first();
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journal = factory(TransactionJournal::class)->make();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$rule = Rule::first();
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journal = factory(TransactionJournal::class)->make();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('getRulesForBill')->andReturn(new Collection([$rule]));
|
||||
|
||||
@@ -196,10 +195,10 @@ class BillControllerTest extends TestCase
|
||||
public function testRescanInactive(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
@@ -214,11 +213,11 @@ class BillControllerTest extends TestCase
|
||||
public function testShow(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$repository->shouldReceive('getYearAverage')->andReturn('0');
|
||||
$repository->shouldReceive('getOverallAverage')->andReturn('0');
|
||||
$repository->shouldReceive('nextExpectedMatch')->andReturn(new Carbon);
|
||||
@@ -252,10 +251,10 @@ class BillControllerTest extends TestCase
|
||||
$this->be($this->user());
|
||||
$bill = $this->user()->bills()->first();
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('store')->andReturn($bill);
|
||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||
@@ -286,11 +285,11 @@ class BillControllerTest extends TestCase
|
||||
public function testStoreCreateAnother(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$bill = $this->user()->bills()->first();
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$bill = $this->user()->bills()->first();
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('store')->andReturn($bill);
|
||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||
@@ -314,41 +313,6 @@ class BillControllerTest extends TestCase
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::store
|
||||
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
||||
* @covers \FireflyIII\Http\Requests\Request
|
||||
*/
|
||||
public function testStoreNoGroup(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('store')->andReturn(new Bill);
|
||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||
|
||||
$data = [
|
||||
'name' => 'New Bill ' . random_int(1000, 9999),
|
||||
'amount_min' => '100',
|
||||
'transaction_currency_id' => 1,
|
||||
'skip' => 0,
|
||||
'create_another' => '1',
|
||||
'strict' => 1,
|
||||
'amount_max' => '100',
|
||||
'date' => '2016-01-01',
|
||||
'repeat_freq' => 'monthly',
|
||||
];
|
||||
$this->session(['bills.create.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('bills.store'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::store
|
||||
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
||||
@@ -357,10 +321,10 @@ class BillControllerTest extends TestCase
|
||||
public function testStoreError(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('store')->andReturn(null);
|
||||
|
||||
@@ -381,6 +345,41 @@ class BillControllerTest extends TestCase
|
||||
$response->assertRedirect(route('bills.create'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::store
|
||||
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
||||
* @covers \FireflyIII\Http\Requests\Request
|
||||
*/
|
||||
public function testStoreNoGroup(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('store')->andReturn(new Bill);
|
||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||
|
||||
$data = [
|
||||
'name' => 'New Bill ' . random_int(1000, 9999),
|
||||
'amount_min' => '100',
|
||||
'transaction_currency_id' => 1,
|
||||
'skip' => 0,
|
||||
'create_another' => '1',
|
||||
'strict' => 1,
|
||||
'amount_max' => '100',
|
||||
'date' => '2016-01-01',
|
||||
'repeat_freq' => 'monthly',
|
||||
];
|
||||
$this->session(['bills.create.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('bills.store'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::update
|
||||
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
||||
@@ -389,10 +388,10 @@ class BillControllerTest extends TestCase
|
||||
public function testUpdate(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('update')->andReturn(new Bill);
|
||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||
|
@@ -24,13 +24,9 @@ declare(strict_types=1);
|
||||
namespace Tests\Feature\Controllers\Category;
|
||||
|
||||
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
@@ -38,7 +34,10 @@ use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Navigation;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class ShowControllerTest
|
||||
@@ -200,7 +199,7 @@ class ShowControllerTest extends TestCase
|
||||
public function testShowEmpty(string $range): void
|
||||
{
|
||||
$latestJournal = $this->user()->transactionJournals()
|
||||
->orderBy('date','DESC')->first();
|
||||
->orderBy('date', 'DESC')->first();
|
||||
|
||||
Log::debug(sprintf('Test testShowEmpty(%s)', $range));
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
@@ -29,8 +29,9 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class CurrencyControllerTest
|
||||
*
|
||||
|
@@ -22,11 +22,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use Mockery;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
@@ -34,6 +33,7 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@@ -111,11 +111,11 @@ class HomeControllerTest extends TestCase
|
||||
public function testIndex(string $range): void
|
||||
{
|
||||
// mock stuff
|
||||
$account = factory(Account::class)->make();
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$billRepos = $this->mock(BillRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$account = factory(Account::class)->make();
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$billRepos = $this->mock(BillRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('count')->andReturn(1);
|
||||
|
@@ -167,7 +167,6 @@ class IndexControllerTest extends TestCase
|
||||
$ynabPrerequisites->shouldReceive('setUser')->times(2);
|
||||
|
||||
|
||||
|
||||
$repository->shouldReceive('create')->withArgs(['fake'])->andReturn($importJob);
|
||||
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'has_prereq'])->andReturn($importJob)->once();
|
||||
|
||||
|
@@ -107,6 +107,28 @@ class JavascriptControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JavascriptController::variables
|
||||
* @covers \FireflyIII\Http\Controllers\JavascriptController::getDateRangeConfig
|
||||
*
|
||||
* @param string $range
|
||||
*
|
||||
* @dataProvider dateRangeProvider
|
||||
*/
|
||||
public function testVariablesCustom(string $range): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn(new Account);
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$this->session(['is_custom_range' => true]);
|
||||
$response = $this->get(route('javascript.variables'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JavascriptController::variables
|
||||
@@ -132,27 +154,4 @@ class JavascriptControllerTest extends TestCase
|
||||
$response = $this->get(route('javascript.variables'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JavascriptController::variables
|
||||
* @covers \FireflyIII\Http\Controllers\JavascriptController::getDateRangeConfig
|
||||
*
|
||||
* @param string $range
|
||||
*
|
||||
* @dataProvider dateRangeProvider
|
||||
*/
|
||||
public function testVariablesCustom(string $range): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn(new Account);
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$this->session(['is_custom_range' => true]);
|
||||
$response = $this->get(route('javascript.variables'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
|
@@ -108,23 +108,6 @@ class AutoCompleteControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\AutoCompleteController
|
||||
*/
|
||||
public function testCurrencyNames(): void
|
||||
{
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$currency = TransactionCurrency::find(1);
|
||||
$repository->shouldReceive('get')->andReturn(new Collection([$currency]))->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.currency-names'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertExactJson(['Euro']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\AutoCompleteController
|
||||
*/
|
||||
@@ -159,6 +142,22 @@ class AutoCompleteControllerTest extends TestCase
|
||||
$response->assertExactJson([$category->name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\AutoCompleteController
|
||||
*/
|
||||
public function testCurrencyNames(): void
|
||||
{
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$currency = TransactionCurrency::find(1);
|
||||
$repository->shouldReceive('get')->andReturn(new Collection([$currency]))->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.currency-names'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertExactJson(['Euro']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\AutoCompleteController
|
||||
*/
|
||||
|
@@ -117,9 +117,9 @@ class BoxControllerTest extends TestCase
|
||||
*/
|
||||
public function testBalanceTransactions(): void
|
||||
{
|
||||
$transaction = new Transaction;
|
||||
$transaction = new Transaction;
|
||||
$transaction->transaction_currency_id = 1;
|
||||
$transaction->transaction_amount ='5';
|
||||
$transaction->transaction_amount = '5';
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
@@ -171,17 +171,20 @@ class BoxControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\BoxController::netWorth()
|
||||
*/
|
||||
public function testNetWorthVirtual(): void
|
||||
public function testNetWorthFuture(): void
|
||||
{
|
||||
$account = $this->user()->accounts()->first();
|
||||
$account->virtual_balance = '1000';
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$account]));
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
|
||||
|
||||
$start = new Carbon;
|
||||
$start->addMonths(6)->startOfMonth();
|
||||
$end = clone $start;
|
||||
$end->endOfMonth();
|
||||
$this->session(['start' => $start, 'end' => $end]);
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.box.net-worth'));
|
||||
$response->assertStatus(200);
|
||||
@@ -207,20 +210,17 @@ class BoxControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\BoxController::netWorth()
|
||||
*/
|
||||
public function testNetWorthFuture(): void
|
||||
public function testNetWorthVirtual(): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
|
||||
$account = $this->user()->accounts()->first();
|
||||
$account->virtual_balance = '1000';
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$account]));
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
|
||||
|
||||
$start = new Carbon;
|
||||
$start->addMonths(6)->startOfMonth();
|
||||
$end = clone $start;
|
||||
$end->endOfMonth();
|
||||
$this->session(['start' => $start, 'end' => $end]);
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.box.net-worth'));
|
||||
$response->assertStatus(200);
|
||||
|
@@ -228,9 +228,9 @@ class ProfileControllerTest extends TestCase
|
||||
$listPref->data = '50';
|
||||
Preferences::shouldReceive('get')->withArgs(['list-length', '10'])->andReturn($listPref)->once();
|
||||
|
||||
$secretPref= new Preference;
|
||||
$secretPref = new Preference;
|
||||
$secretPref->data = 'X';
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->twice()->andReturn(null,$secretPref);
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->twice()->andReturn(null, $secretPref);
|
||||
|
||||
// set pref
|
||||
Preferences::shouldReceive('set')->once()->withArgs(['twoFactorAuthEnabled', 1]);
|
||||
@@ -313,7 +313,7 @@ class ProfileControllerTest extends TestCase
|
||||
{
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->once()->andReturn(false);
|
||||
$data = [
|
||||
$data = [
|
||||
'email' => $this->user()->email,
|
||||
];
|
||||
$this->be($this->user());
|
||||
@@ -467,7 +467,7 @@ class ProfileControllerTest extends TestCase
|
||||
*/
|
||||
public function testRegenerate(): void
|
||||
{
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->once()->andReturn(false);
|
||||
$token = '';
|
||||
$currentToken = Preference::where('user_id', $this->user()->id)->where('name', 'access_token')->first();
|
||||
|
@@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
namespace tests\Feature\Controllers\Rule;
|
||||
|
||||
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
|
@@ -75,32 +75,6 @@ class BulkControllerTest extends TestCase
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
|
||||
*/
|
||||
public function testEditNull(): void
|
||||
{
|
||||
// mock stuff:
|
||||
$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('firstNull')->andReturn(new TransactionJournal, null);
|
||||
$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();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.bulk.edit', $transfers));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('Bulk edit a number of transactions');
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController::edit
|
||||
*/
|
||||
@@ -136,6 +110,32 @@ class BulkControllerTest extends TestCase
|
||||
$response->assertSee('multiple destination accounts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
|
||||
*/
|
||||
public function testEditNull(): void
|
||||
{
|
||||
// mock stuff:
|
||||
$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('firstNull')->andReturn(new TransactionJournal, null);
|
||||
$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();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.bulk.edit', $transfers));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('Bulk edit a number of transactions');
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController::update
|
||||
* @covers \FireflyIII\Http\Requests\BulkEditJournalRequest
|
||||
|
@@ -107,35 +107,6 @@ class LinkControllerTest extends TestCase
|
||||
$response->assertRedirect(route('transactions.show', [1]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
|
||||
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
|
||||
*/
|
||||
public function testStoreSame(): void
|
||||
{
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$data = [
|
||||
'link_other' => 8,
|
||||
'link_type' => '1_inward',
|
||||
];
|
||||
$journal = $this->user()->transactionJournals()->first();
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn($journal);
|
||||
$journalRepos->shouldReceive('findNull')->andReturn($journal);
|
||||
$repository->shouldReceive('findLink')->andReturn(false);
|
||||
$repository->shouldReceive('storeLink')->andReturn(new TransactionJournalLink);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.link.store', [$journal->id]), $data);
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('error');
|
||||
$response->assertRedirect(route('transactions.show', [1]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
|
||||
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
|
||||
@@ -167,7 +138,7 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreInvalid(): void
|
||||
{
|
||||
$data = [
|
||||
$data = [
|
||||
'link_other' => 0,
|
||||
'link_type' => '1_inward',
|
||||
];
|
||||
@@ -183,6 +154,33 @@ class LinkControllerTest extends TestCase
|
||||
$response->assertRedirect(route('transactions.show', [1]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
|
||||
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
|
||||
*/
|
||||
public function testStoreSame(): void
|
||||
{
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$data = [
|
||||
'link_other' => 8,
|
||||
'link_type' => '1_inward',
|
||||
];
|
||||
$journal = $this->user()->transactionJournals()->first();
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn($journal);
|
||||
$journalRepos->shouldReceive('findNull')->andReturn($journal);
|
||||
$repository->shouldReceive('findLink')->andReturn(false);
|
||||
$repository->shouldReceive('storeLink')->andReturn(new TransactionJournalLink);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.link.store', [$journal->id]), $data);
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('error');
|
||||
$response->assertRedirect(route('transactions.show', [1]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::switchLink
|
||||
*/
|
||||
|
@@ -202,8 +202,8 @@ class MassControllerTest extends TestCase
|
||||
'amount' => [$deposit->id => 1600],
|
||||
'amount_currency_id_amount_' . $deposit->id => 1,
|
||||
'date' => [$deposit->id => '2014-07-24'],
|
||||
'source_name' => [$deposit->id => 'Job'],
|
||||
'destination_id' => [$deposit->id => 1],
|
||||
'source_name' => [$deposit->id => 'Job'],
|
||||
'destination_id' => [$deposit->id => 1],
|
||||
'category' => [$deposit->id => 'Salary'],
|
||||
];
|
||||
|
||||
|
@@ -29,7 +29,6 @@ use FireflyIII\Events\StoredTransactionJournal;
|
||||
use FireflyIII\Events\UpdatedTransactionJournal;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@@ -849,7 +848,6 @@ class SingleControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
|
||||
|
||||
|
||||
|
||||
$linkRepos->shouldReceive('get')->andReturn(new Collection);
|
||||
$linkRepos->shouldReceive('getLinks')->andReturn(new Collection);
|
||||
$attRepos->shouldReceive('saveAttachmentsForModel');
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
namespace Tests\Feature\Controllers\Transaction;
|
||||
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@@ -77,7 +76,6 @@ class SplitControllerTest extends TestCase
|
||||
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
|
||||
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
|
||||
$account = $destination->account;
|
||||
@@ -131,7 +129,6 @@ class SplitControllerTest extends TestCase
|
||||
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
|
||||
|
||||
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
|
||||
$budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
||||
|
||||
@@ -292,15 +289,15 @@ class SplitControllerTest extends TestCase
|
||||
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
|
||||
$deposit = $this->user()->transactionJournals()->where('transaction_type_id', 2)->first();
|
||||
$data = [
|
||||
'id' => $deposit->id,
|
||||
'what' => 'deposit',
|
||||
'journal_description' => 'Updated salary',
|
||||
'journal_currency_id' => 1,
|
||||
'id' => $deposit->id,
|
||||
'what' => 'deposit',
|
||||
'journal_description' => 'Updated salary',
|
||||
'journal_currency_id' => 1,
|
||||
'journal_destination_id' => 1,
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
[
|
||||
'transaction_description' => 'Split #1',
|
||||
'source_name' => 'Job',
|
||||
@@ -342,15 +339,15 @@ class SplitControllerTest extends TestCase
|
||||
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
|
||||
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
|
||||
$data = [
|
||||
'id' => $opening->id,
|
||||
'what' => 'opening balance',
|
||||
'journal_description' => 'Updated salary',
|
||||
'journal_currency_id' => 1,
|
||||
'id' => $opening->id,
|
||||
'what' => 'opening balance',
|
||||
'journal_description' => 'Updated salary',
|
||||
'journal_currency_id' => 1,
|
||||
'journal_destination_id' => 1,
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
[
|
||||
'transaction_description' => 'Split #1',
|
||||
'source_name' => 'Job',
|
||||
@@ -390,18 +387,18 @@ class SplitControllerTest extends TestCase
|
||||
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$data = [
|
||||
'id' => $transfer->id,
|
||||
'what' => 'transfer',
|
||||
'journal_description' => 'Some updated withdrawal',
|
||||
'journal_currency_id' => 1,
|
||||
'journal_source_id' => 1,
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
'id' => $transfer->id,
|
||||
'what' => 'transfer',
|
||||
'journal_description' => 'Some updated withdrawal',
|
||||
'journal_currency_id' => 1,
|
||||
'journal_source_id' => 1,
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
[
|
||||
'transaction_description' => 'Split #1',
|
||||
'source_id' => '1',
|
||||
'source_id' => '1',
|
||||
'destination_id' => '2',
|
||||
'transaction_currency_id' => 1,
|
||||
'amount' => 1591,
|
||||
@@ -446,15 +443,15 @@ class SplitControllerTest extends TestCase
|
||||
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
|
||||
$withdrawal = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 1)->first();
|
||||
$data = [
|
||||
'id' => $withdrawal->id,
|
||||
'what' => 'withdrawal',
|
||||
'journal_description' => 'Some updated withdrawal',
|
||||
'journal_currency_id' => 1,
|
||||
'journal_source_id' => 1,
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
'id' => $withdrawal->id,
|
||||
'what' => 'withdrawal',
|
||||
'journal_description' => 'Some updated withdrawal',
|
||||
'journal_currency_id' => 1,
|
||||
'journal_source_id' => 1,
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
[
|
||||
'transaction_description' => 'Split #1',
|
||||
'source_id' => '1',
|
||||
|
@@ -65,7 +65,7 @@ class TransactionControllerTest extends TestCase
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
|
||||
// mock stuff
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$repository->shouldReceive('firstNull')->twice()->andReturn($transfer);
|
||||
@@ -99,7 +99,7 @@ class TransactionControllerTest extends TestCase
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
|
||||
// mock stuff
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$repository->shouldReceive('firstNull')->twice()->andReturn($transfer);
|
||||
@@ -143,7 +143,7 @@ class TransactionControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
|
||||
@@ -186,7 +186,7 @@ class TransactionControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
|
||||
@@ -204,7 +204,7 @@ class TransactionControllerTest extends TestCase
|
||||
$collector->shouldReceive('getJournals')->andReturn($collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.index', ['transfer', '2016-01-01','2015-12-31']));
|
||||
$response = $this->get(route('transactions.index', ['transfer', '2016-01-01', '2015-12-31']));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
@@ -229,7 +229,7 @@ class TransactionControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
|
||||
@@ -272,7 +272,7 @@ class TransactionControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
|
||||
|
Reference in New Issue
Block a user