Fix tests

This commit is contained in:
James Cole 2018-01-17 12:29:00 +01:00
parent 80f96abf08
commit e2af0caa41
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
4 changed files with 20 additions and 32 deletions

View File

@ -129,7 +129,6 @@ class Transaction extends Twig_Extension
if (isset($transaction->transaction_journal_budget_id)) {
$name = app('steam')->tryDecrypt($transaction->transaction_journal_budget_name);
$txt = sprintf('<a href="%s" title="%s">%s</a>', route('budgets.show', [$transaction->transaction_journal_budget_id]), $name, $name);
$cache->store($txt);
return $txt;
}
@ -138,7 +137,6 @@ class Transaction extends Twig_Extension
if (isset($transaction->transaction_budget_id)) {
$name = app('steam')->tryDecrypt($transaction->transaction_budget_name);
$txt = sprintf('<a href="%s" title="%s">%s</a>', route('budgets.show', [$transaction->transaction_budget_id]), $name, $name);
$cache->store($txt);
return $txt;
}

View File

@ -345,8 +345,9 @@
#{{ link.source.id }}: {{ link.source.description }}</a>
({{ link.source|journalTotalAmount }})
{% endif %}
{% if link.comment != "" %}
<br/><em>{{ link.comment }}</em>
{% if link.notes.count == 1 %}
<br/>
{{ link.notes.first.text|markdown }}
{% endif %}
</td>
</tr>
@ -459,9 +460,9 @@
</div>
</div>
<div class="form-group">
<label for="comments" class="col-sm-2 control-label">{{ 'comments'|_ }}</label>
<label for="notes" class="col-sm-2 control-label">{{ 'notes'|_ }}</label>
<div class="col-sm-10">
<textarea id="comments" name="comments" class="form-control"></textarea>
<textarea id="notes" name="notes" class="form-control"></textarea>
</div>
</div>

View File

@ -159,8 +159,6 @@ class CategoryControllerTest extends TestCase
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf();
$collector->shouldReceive('setLimit')->andReturnSelf();
Steam::shouldReceive('positive')->once()->andReturn('1');
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$response = $this->get(route('categories.no-category'));
@ -231,8 +229,6 @@ class CategoryControllerTest extends TestCase
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf();
$collector->shouldReceive('setLimit')->andReturnSelf();
Steam::shouldReceive('positive')->once()->andReturn('1');
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$response = $this->get(route('categories.no-category', ['2016-01-01']));
@ -253,11 +249,10 @@ class CategoryControllerTest extends TestCase
{
$transaction = factory(Transaction::class)->make();
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
// mock stuff
$repository = $this->mock(CategoryRepositoryInterface::class);
$repository->shouldReceive('firstUseDate')->once()->andReturn(new Carbon);
$repository->shouldReceive('spentInPeriod')->andReturn('0');
$repository->shouldReceive('earnedInPeriod')->andReturn('0');
@ -267,16 +262,13 @@ class CategoryControllerTest extends TestCase
$collector = $this->mock(JournalCollectorInterface::class);
$collector->shouldReceive('setPage')->andReturnSelf()->once();
$collector->shouldReceive('setLimit')->andReturnSelf()->once();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->twice();
$collector->shouldReceive('setRange')->andReturnSelf()->twice();
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf()->twice();
$collector->shouldReceive('setTypes')->andReturnSelf()->once();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
$collector->shouldReceive('setRange')->andReturnSelf()->once();
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf()->once();
$collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();
$collector->shouldReceive('withCategoryInformation')->andReturnSelf()->once();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->twice();
$collector->shouldReceive('getJournals')->andReturn(new Collection)->once();
$collector->shouldReceive('setCategory')->andReturnSelf()->twice();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->once();
$collector->shouldReceive('setCategory')->andReturnSelf()->once();
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([$transaction], 0, 10))->once();
$this->be($this->user());
@ -313,7 +305,6 @@ class CategoryControllerTest extends TestCase
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([$transaction], 0, 10))->once();
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('firstUseDate')->andReturn(new Carbon);
$this->be($this->user());
@ -338,7 +329,7 @@ class CategoryControllerTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$collector = $this->mock(JournalCollectorInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
@ -355,7 +346,6 @@ class CategoryControllerTest extends TestCase
$collector->shouldReceive('getJournals')->andReturn(new Collection)->atLeast(1);
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([$transaction], 0, 10))->once();
$repository->shouldReceive('firstUseDate')->once()->andReturn(new Carbon('1900-01-01'));
$repository->shouldReceive('spentInPeriod')->andReturn('-1');
$repository->shouldReceive('earnedInPeriod')->andReturn('1');
@ -377,11 +367,10 @@ class CategoryControllerTest extends TestCase
public function testShowEmpty(string $range)
{
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
// mock stuff
$repository = $this->mock(CategoryRepositoryInterface::class);
$repository->shouldReceive('firstUseDate')->once()->andReturn(new Carbon);
$repository->shouldReceive('spentInPeriod')->andReturn('0');
$repository->shouldReceive('earnedInPeriod')->andReturn('0');
@ -391,16 +380,14 @@ class CategoryControllerTest extends TestCase
$collector = $this->mock(JournalCollectorInterface::class);
$collector->shouldReceive('setPage')->andReturnSelf()->once();
$collector->shouldReceive('setLimit')->andReturnSelf()->once();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->twice();
$collector->shouldReceive('setRange')->andReturnSelf()->twice();
$collector->shouldReceive('setTypes')->andReturnSelf()->times(1);
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf()->twice();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
$collector->shouldReceive('setRange')->andReturnSelf()->once();
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf()->once();
$collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();
$collector->shouldReceive('withCategoryInformation')->andReturnSelf()->once();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->twice();
$collector->shouldReceive('setCategory')->andReturnSelf()->twice();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->once();
$collector->shouldReceive('setCategory')->andReturnSelf()->once();
$collector->shouldReceive('getJournals')->andReturn(new Collection)->times(1);
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->once();
$this->be($this->user());

View File

@ -81,6 +81,8 @@ class CategoryControllerTest extends TestCase
$category = factory(Category::class)->make();
$repository->shouldReceive('getCategories')->andReturn(new Collection([$category]));
$repository->shouldReceive('spentInPeriod')->andReturn('-1');
$repository->shouldReceive('earnedInPeriod')->andReturn('1');
$this->be($this->user());
$response = $this->get(route('report-data.category.operations', ['1', '20120101', '20120131']));