This fixes the tests.

This commit is contained in:
James Cole 2016-12-28 09:56:07 +01:00
parent 6151d4a0ec
commit 9c6a3e4ad5
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
4 changed files with 55 additions and 1 deletions

View File

@ -320,6 +320,14 @@ Breadcrumbs::register(
}
);
Breadcrumbs::register(
'categories.show.all', function (BreadCrumbGenerator $breadcrumbs, Category $category) {
$breadcrumbs->parent('categories.index');
$breadcrumbs->push(e($category->name) . '(' . strtolower(trans('firefly.all_periods')) . ')', route('categories.show.all', [$category->id]));
}
);
Breadcrumbs::register(
'categories.show.date', function (BreadCrumbGenerator $breadcrumbs, Category $category, Carbon $date) {

View File

@ -145,8 +145,10 @@ class CategoryRepository implements CategoryRepositoryInterface
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->orderBy('transaction_journals.date', 'ASC')->first(['transaction_journals.date']);
// both exist, the one that is earliest "wins".
if (!is_null($firstTransaction) && !is_null($first) && $firstTransaction->date->lt($first)) {
if (!is_null($firstTransaction) && !is_null($first) && Carbon::parse($firstTransaction->date)->lt($first)) {
$first = $firstTransaction->date;
}

View File

@ -128,6 +128,22 @@ class AccountControllerTest extends TestCase
$this->see('<ol class="breadcrumb">');
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::showWithDate
* @dataProvider dateRangeProvider
*
* @param string $range
*/
public function testShowAll(string $range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', route('accounts.show.all', [1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('<ol class="breadcrumb">');
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::showWithDate
* @dataProvider dateRangeProvider

View File

@ -132,6 +132,7 @@ class CategoryControllerTest extends TestCase
$collector->shouldReceive('setLimit')->andReturnSelf()->once();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
$collector->shouldReceive('setRange')->andReturnSelf()->once();
$collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();
$collector->shouldReceive('setCategory')->andReturnSelf()->once();
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->once();
@ -147,6 +148,32 @@ class CategoryControllerTest extends TestCase
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\CategoryController::showAll
* @dataProvider dateRangeProvider
*
* @param string $range
*/
public function testShowAll(string $range)
{
$collector = $this->mock(JournalCollectorInterface::class);
// collector stuff:
$collector->shouldReceive('setPage')->andReturnSelf()->once();
$collector->shouldReceive('setLimit')->andReturnSelf()->once();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
$collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();
$collector->shouldReceive('setCategory')->andReturnSelf()->once();
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->once();
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', route('categories.show.all', [1]));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\CategoryController::showByDate
* @dataProvider dateRangeProvider
@ -162,6 +189,7 @@ class CategoryControllerTest extends TestCase
$collector->shouldReceive('setLimit')->andReturnSelf()->once();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
$collector->shouldReceive('setRange')->andReturnSelf()->once();
$collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();
$collector->shouldReceive('setCategory')->andReturnSelf()->once();
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->once();