From 5c28adf266fec167630aff43179b14f92c32a725 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 18 Dec 2016 18:16:41 +0100 Subject: [PATCH] New tests. [skip ci] --- app/Http/breadcrumbs.php | 49 +++++++++++++-- resources/lang/en_US/firefly.php | 8 +-- resources/views/reports/audit/report.twig | 2 +- resources/views/reports/budget/month.twig | 2 +- resources/views/reports/category/month.twig | 2 +- resources/views/reports/default/month.twig | 2 +- .../views/reports/default/multi-year.twig | 2 +- resources/views/reports/default/year.twig | 2 +- .../Controllers/ReportControllerTest.php | 63 +++++++++---------- 9 files changed, 81 insertions(+), 51 deletions(-) diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php index 7f35b095b7..7f62296c49 100644 --- a/app/Http/breadcrumbs.php +++ b/app/Http/breadcrumbs.php @@ -515,16 +515,53 @@ Breadcrumbs::register( ); Breadcrumbs::register( - 'reports.report', function (BreadCrumbGenerator $breadcrumbs, Carbon $start, Carbon $end, $reportType, $accountIds) { + 'reports.report.audit', function (BreadCrumbGenerator $breadcrumbs, string $accountIds, Carbon $start, Carbon $end) { $breadcrumbs->parent('reports.index'); $monthFormat = (string)trans('config.month_and_day'); - $title = (string)trans( - 'firefly.report_' . $reportType, - ['start' => $start->formatLocalized($monthFormat), 'end' => $end->formatLocalized($monthFormat)] - ); + $startString = $start->formatLocalized($monthFormat); + $endString = $end->formatLocalized($monthFormat); + $title = (string)trans('firefly.report_audit', ['start' => $startString, 'end' => $endString]); - $breadcrumbs->push($title, route('reports.report', [$reportType, $start->format('Ymd'), $end->format('Ymd'), $accountIds])); + $breadcrumbs->push($title, route('reports.report.audit', [$accountIds, $start->format('Ymd'), $end->format('Ymd')])); +} +); +Breadcrumbs::register( + 'reports.report.budget', function (BreadCrumbGenerator $breadcrumbs, string $accountIds, string $budgetIds, Carbon $start, Carbon $end) { + $breadcrumbs->parent('reports.index'); + + $monthFormat = (string)trans('config.month_and_day'); + $startString = $start->formatLocalized($monthFormat); + $endString = $end->formatLocalized($monthFormat); + $title = (string)trans('firefly.report_budget', ['start' => $startString, 'end' => $endString]); + + $breadcrumbs->push($title, route('reports.report.budget', [$accountIds, $budgetIds, $start->format('Ymd'), $end->format('Ymd')])); +} +); + +Breadcrumbs::register( + 'reports.report.category', function (BreadCrumbGenerator $breadcrumbs, string $accountIds, string $categoryIds, Carbon $start, Carbon $end) { + $breadcrumbs->parent('reports.index'); + + $monthFormat = (string)trans('config.month_and_day'); + $startString = $start->formatLocalized($monthFormat); + $endString = $end->formatLocalized($monthFormat); + $title = (string)trans('firefly.report_category', ['start' => $startString, 'end' => $endString]); + + $breadcrumbs->push($title, route('reports.report.category', [$accountIds, $categoryIds, $start->format('Ymd'), $end->format('Ymd')])); +} +); + +Breadcrumbs::register( + 'reports.report.default', function (BreadCrumbGenerator $breadcrumbs, string $accountIds, Carbon $start, Carbon $end) { + $breadcrumbs->parent('reports.index'); + + $monthFormat = (string)trans('config.month_and_day'); + $startString = $start->formatLocalized($monthFormat); + $endString = $end->formatLocalized($monthFormat); + $title = (string)trans('firefly.report_default', ['start' => $startString, 'end' => $endString]); + + $breadcrumbs->push($title, route('reports.report.default', [$accountIds, $start->format('Ymd'), $end->format('Ymd')])); } ); diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 226834da8a..5b9ba90e21 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -632,10 +632,10 @@ return [ 'errors' => 'Errors', // reports: - 'report_default' => 'Default financial report for :start until :end', - 'report_audit' => 'Transaction history overview for :start until :end', - 'report_category' => 'Category report for :start until :end', - 'report_budget' => 'Budget report for :start until :end', + 'report_default' => 'Default financial report between :start and :end', + 'report_audit' => 'Transaction history overview between :start and :end', + 'report_category' => 'Category report between :start and :end', + 'report_budget' => 'Budget report between :start and :end', 'quick_link_reports' => 'Quick links', 'quick_link_default_report' => 'Default financial report', 'quick_link_audit_report' => 'Transaction history overview', diff --git a/resources/views/reports/audit/report.twig b/resources/views/reports/audit/report.twig index ef8b1af2dc..762406c3c0 100644 --- a/resources/views/reports/audit/report.twig +++ b/resources/views/reports/audit/report.twig @@ -1,7 +1,7 @@ {% extends "./layout/default" %} {% block breadcrumbs %} - {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, start, end, reportType, accountIds) }} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, accountIds, start, end) }} {% endblock %} {% block content %} diff --git a/resources/views/reports/budget/month.twig b/resources/views/reports/budget/month.twig index d8623ebf32..73e030e106 100644 --- a/resources/views/reports/budget/month.twig +++ b/resources/views/reports/budget/month.twig @@ -1,7 +1,7 @@ {% extends "./layout/default" %} {% block breadcrumbs %} - {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, accountIds, budgetIds, start, end) }} {% endblock %} {% block content %} diff --git a/resources/views/reports/category/month.twig b/resources/views/reports/category/month.twig index 679793d770..f01c9a5395 100644 --- a/resources/views/reports/category/month.twig +++ b/resources/views/reports/category/month.twig @@ -1,7 +1,7 @@ {% extends "./layout/default" %} {% block breadcrumbs %} - {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, accountIds, categoryIds, start, end) }} {% endblock %} {% block content %} diff --git a/resources/views/reports/default/month.twig b/resources/views/reports/default/month.twig index 352f5a2d1c..22a7ebe73d 100644 --- a/resources/views/reports/default/month.twig +++ b/resources/views/reports/default/month.twig @@ -1,7 +1,7 @@ {% extends "./layout/default" %} {% block breadcrumbs %} - {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, start, end, reportType, accountIds) }} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, accountIds, start, end) }} {% endblock %} {% block content %} diff --git a/resources/views/reports/default/multi-year.twig b/resources/views/reports/default/multi-year.twig index 527eb84740..7b70416735 100644 --- a/resources/views/reports/default/multi-year.twig +++ b/resources/views/reports/default/multi-year.twig @@ -1,7 +1,7 @@ {% extends "./layout/default" %} {% block breadcrumbs %} - {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, start, end, reportType, accountIds) }} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, accountIds, start, end) }} {% endblock %} {% block content %} diff --git a/resources/views/reports/default/year.twig b/resources/views/reports/default/year.twig index aad882010d..bea5536237 100644 --- a/resources/views/reports/default/year.twig +++ b/resources/views/reports/default/year.twig @@ -1,7 +1,7 @@ {% extends "./layout/default" %} {% block breadcrumbs %} - {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, start, end, reportType, accountIds) }} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, accountIds, start, end) }} {% endblock %} {% block content %} diff --git a/tests/acceptance/Controllers/ReportControllerTest.php b/tests/acceptance/Controllers/ReportControllerTest.php index 5ce19e0e61..d975bb4581 100644 --- a/tests/acceptance/Controllers/ReportControllerTest.php +++ b/tests/acceptance/Controllers/ReportControllerTest.php @@ -8,6 +8,8 @@ * * See the LICENSE file for details. */ +use FireflyIII\Generator\Report\Audit\MonthReportGenerator as AuditGenerator; +use FireflyIII\Generator\Report\ReportGeneratorInterface; /** @@ -28,85 +30,76 @@ class ReportControllerTest extends TestCase /** * @covers \FireflyIII\Http\Controllers\ReportController::auditReport - * Implement testAuditReport(). */ public function testAuditReport() { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $this->be($this->user()); + $this->call('get', route('reports.report.audit', [1, '20160101', '20160131'])); + $this->assertResponseStatus(200); + $this->see('