Skip to content
Snippets Groups Projects
Commit b047f79e authored by Mantas Urnieža's avatar Mantas Urnieža
Browse files

Adding missing query param to Search object.

parent a87b1905
No related branches found
No related tags found
No related merge requests found
......@@ -78,6 +78,11 @@ class Search
*/
private $searchType;
/**
* @var string
*/
private $requestCache;
/**
* @var bool
*/
......@@ -640,6 +645,31 @@ class Search
return $this->searchType;
}
/**
* Set request cache.
*
* @param string $requestCache
*
* @return $this
*/
public function setRequestCache($requestCache)
{
$this->requestCache = $requestCache;
return $this;
}
/**
* Returns request cache.
*
* @return string
*/
public function getRequestCache()
{
return $this->requestCache;
}
/**
* Setter for preference.
*
......@@ -691,6 +721,7 @@ class Search
[
'scroll' => $this->getScroll(),
'search_type' => $this->getSearchType(),
'request_cache' => $this->getRequestCache(),
'preference' => $this->getPreference(),
]
);
......
......@@ -104,4 +104,48 @@ class SearchTest extends \PHPUnit_Framework_TestCase
$search->toArray()
);
}
/**
* Data provider for test testSettingQueryParams()
*
* @return array
*/
public function getTestSettingQueryParamsData()
{
$cases = [];
$search = new Search();
$search->setSearchType('dfs_query_then_fetch');
$cases['Only search_type is set'] = [
$search,
[
'search_type' => 'dfs_query_then_fetch',
],
];
$search = new Search();
$search->setRequestCache(true);
$cases['Only request_cache is set'] = [
$search,
[
'request_cache' => true,
],
];
return $cases;
}
/**
* @dataProvider getTestSettingQueryParamsData()
*
* @param Search $search
* @param array $expected
*/
public function testSettingQueryParams($search, $expected)
{
$this->assertEquals(
$expected,
$search->getQueryParams()
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment