Tests for search [skip ci]

This commit is contained in:
James Cole 2014-12-30 18:44:49 +01:00
parent ba7c01c6bc
commit 94fcfacec4
2 changed files with 40 additions and 1 deletions

View File

@ -17,7 +17,7 @@ class SearchController extends BaseController
$subTitle = null;
$rawQuery = null;
$result = [];
if (!is_null(Input::get('q'))) {
if (!is_null(Input::get('q')) && strlen(Input::get('q')) > 0) {
$rawQuery = trim(Input::get('q'));
$words = explode(' ', $rawQuery);
$subTitle = 'Results for "' . e($rawQuery) . '"';

View File

@ -0,0 +1,39 @@
<?php
/**
* Class SearchControllerCest
*/
class SearchControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
public function index(FunctionalTester $I)
{
$I->wantTo('search for "salary"');
$I->amOnPage('/search?q=salary');
$I->see('Transactions');
$I->see('Results for "salary"');
}
public function indexNoQuery(FunctionalTester $I)
{
$I->wantTo('Search for empty string');
$I->amOnPage('/search?q=');
$I->see('Search for &quot;&quot;');
}
}