This fixes the tests.

This commit is contained in:
James Cole 2017-07-15 22:41:57 +02:00
parent fa00ba2edd
commit 1d6ca91c01
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
5 changed files with 3 additions and 82 deletions

View File

@ -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)

View File

@ -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;
}
}

View File

@ -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
*/

View File

@ -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',

View File

@ -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);