mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
This fixes the tests.
This commit is contained in:
parent
fa00ba2edd
commit
1d6ca91c01
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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',
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user