From c9b215684ce453ecaf4c7363170b8d59869ce9fd Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 5 Feb 2016 19:25:17 +0100 Subject: [PATCH] Also fixed tests. --- app/Http/Controllers/SearchController.php | 10 +++++----- tests/acceptance/Controllers/SearchControllerTest.php | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 2e75c9b45e..b634a85379 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -38,11 +38,11 @@ class SearchController extends Controller $words = explode(' ', $query); $subTitle = trans('firefly.search_results_for', ['query' => $query]); - $transactions = [];//$searcher->searchTransactions($words); - $accounts = [];//$searcher->searchAccounts($words); - $categories = [];//$searcher->searchCategories($words); - $budgets = [];//$searcher->searchBudgets($words); - $tags = [];//$searcher->searchTags($words); + $transactions = $searcher->searchTransactions($words); + $accounts = $searcher->searchAccounts($words); + $categories = $searcher->searchCategories($words); + $budgets = $searcher->searchBudgets($words); + $tags = $searcher->searchTags($words); $result = ['transactions' => $transactions, 'accounts' => $accounts, 'categories' => $categories, 'budgets' => $budgets, 'tags' => $tags]; } diff --git a/tests/acceptance/Controllers/SearchControllerTest.php b/tests/acceptance/Controllers/SearchControllerTest.php index 0d9838e37c..9e94467fa6 100644 --- a/tests/acceptance/Controllers/SearchControllerTest.php +++ b/tests/acceptance/Controllers/SearchControllerTest.php @@ -6,6 +6,7 @@ * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ +use Illuminate\Support\Collection; /** @@ -19,6 +20,13 @@ class SearchControllerTest extends TestCase */ public function testIndex() { + $searcher = $this->mock('FireflyIII\Support\Search\SearchInterface'); + $searcher->shouldReceive('searchTransactions')->once()->with(['test'])->andReturn(new Collection); + $searcher->shouldReceive('searchAccounts')->once()->with(['test'])->andReturn(new Collection); + $searcher->shouldReceive('searchCategories')->once()->with(['test'])->andReturn(new Collection); + $searcher->shouldReceive('searchBudgets')->once()->with(['test'])->andReturn(new Collection); + $searcher->shouldReceive('searchTags')->once()->with(['test'])->andReturn(new Collection); + $this->be($this->user()); $this->call('GET', '/search?q=test&search='); $this->assertResponseStatus(200);