diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index a0acba5a7e..17436055b6 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -60,48 +60,6 @@ class SearchController extends Controller $subTitle = trans('breadcrumbs.search_result', ['query' => $query]); return view('search.index', compact('query', 'fullQuery', 'subTitle')); - - // yes, hard coded values: - $minSearchLen = 1; - $limit = 20; - - // ui stuff: - $subTitle = ''; - - // query stuff - $query = null; - $result = []; - $rawQuery = $request->get('q'); - $hasModifiers = true; - $modifiers = []; - - if (!is_null($request->get('q')) && strlen($request->get('q')) >= $minSearchLen) { - // parse query, find modifiers: - // set limit for search - $searcher->setLimit($limit); - $searcher->parseQuery($request->get('q')); - - $transactions = $searcher->searchTransactions(); - $accounts = new Collection; - $categories = new Collection; - $tags = new Collection; - $budgets = new Collection; - - // no special search thing? - if (!$searcher->hasModifiers()) { - $hasModifiers = false; - $accounts = $searcher->searchAccounts(); - $categories = $searcher->searchCategories(); - $budgets = $searcher->searchBudgets(); - $tags = $searcher->searchTags(); - } - $query = $searcher->getWordsAsString(); - $subTitle = trans('firefly.search_results_for', ['query' => $query]); - $result = ['transactions' => $transactions, 'accounts' => $accounts, 'categories' => $categories, 'budgets' => $budgets, 'tags' => $tags]; - - } - - return view('search.index', compact('rawQuery', 'hasModifiers', 'modifiers', 'subTitle', 'limit', 'query', 'result')); } public function search(Request $request, SearchInterface $searcher) diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index e7659a80e8..2c8d67539c 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -58,7 +58,7 @@ class PiggyBank extends Model public static function routeBinder(PiggyBank $value) { if (auth()->check()) { - if ($value->account->user_id === auth()->user()->id) { + if (intval($value->account->user_id) === auth()->user()->id) { return $value; } } diff --git a/tests/Feature/Controllers/JsonControllerTest.php b/tests/Feature/Controllers/JsonControllerTest.php index 1863827c77..b453225d3f 100644 --- a/tests/Feature/Controllers/JsonControllerTest.php +++ b/tests/Feature/Controllers/JsonControllerTest.php @@ -207,21 +207,6 @@ class JsonControllerTest extends TestCase $response->assertExactJson([$category->name]); } - /** - * @covers \FireflyIII\Http\Controllers\JsonController::endTour - */ - public function testEndTour() - { - // mock stuff - $journalRepos = $this->mock(JournalRepositoryInterface::class); - $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); - - $this->be($this->user()); - $response = $this->post(route('json.end-tour')); - $response->assertStatus(200); - $response->assertExactJson(['true']); - } - /** * @covers \FireflyIII\Http\Controllers\JsonController::expenseAccounts */ @@ -280,20 +265,6 @@ class JsonControllerTest extends TestCase $response->assertExactJson([$tag->tag]); } - /** - * @covers \FireflyIII\Http\Controllers\JsonController::tour - */ - public function testTour() - { - // mock stuff - $journalRepos = $this->mock(JournalRepositoryInterface::class); - $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); - - $this->be($this->user()); - $response = $this->get(route('json.tour')); - $response->assertStatus(200); - } - /** * @covers \FireflyIII\Http\Controllers\JsonController::transactionJournals */ diff --git a/tests/Feature/Controllers/NewUserControllerTest.php b/tests/Feature/Controllers/NewUserControllerTest.php index 810060b424..34c5983a08 100644 --- a/tests/Feature/Controllers/NewUserControllerTest.php +++ b/tests/Feature/Controllers/NewUserControllerTest.php @@ -73,14 +73,13 @@ class NewUserControllerTest extends TestCase $accountRepos = $this->mock(AccountRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); - $accountRepos->shouldReceive('store')->times(3); + $accountRepos->shouldReceive('store')->times(2); $data = [ 'bank_name' => 'New bank', 'savings_balance' => '1000', 'bank_balance' => '100', - 'credit_card_limit' => '1000', ]; $this->be($this->emptyUser()); $response = $this->post(route('new-user.submit'), $data); @@ -97,7 +96,7 @@ class NewUserControllerTest extends TestCase $accountRepos = $this->mock(AccountRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); - $accountRepos->shouldReceive('store')->once(); + $accountRepos->shouldReceive('store')->twice(); $data = [ 'bank_name' => 'New bank', diff --git a/tests/Feature/Controllers/SearchControllerTest.php b/tests/Feature/Controllers/SearchControllerTest.php index ca0f76fcc4..6ed7c2bec3 100644 --- a/tests/Feature/Controllers/SearchControllerTest.php +++ b/tests/Feature/Controllers/SearchControllerTest.php @@ -30,15 +30,8 @@ class SearchControllerTest extends TestCase public function testIndex() { $search = $this->mock(SearchInterface::class); - $search->shouldReceive('setLimit')->once(); $search->shouldReceive('parseQuery')->once(); - $search->shouldReceive('hasModifiers')->once()->andReturn(false); $search->shouldReceive('getWordsAsString')->once()->andReturn('test'); - $search->shouldReceive('searchTransactions')->andReturn(new Collection)->once(); - $search->shouldReceive('searchBudgets')->andReturn(new Collection)->once(); - $search->shouldReceive('searchTags')->andReturn(new Collection)->once(); - $search->shouldReceive('searchCategories')->andReturn(new Collection)->once(); - $search->shouldReceive('searchAccounts')->andReturn(new Collection)->once(); $this->be($this->user()); $response = $this->get(route('search.index') . '?q=test'); $response->assertStatus(200);