Commit 2db071c4 authored by Bas de Nooijer's avatar Bas de Nooijer

Added support for empty params (needed for the 'q' param in dismax to use 'q.alt')

parent 0b4e71f8
......@@ -211,7 +211,7 @@ class Solarium_Client_Request extends Solarium_Configurable
*/
public function addParam($key, $value, $overwrite = false)
{
if ($value !== '' && $value !== null) {
if ($value !== null) {
if (!$overwrite && isset($this->_params[$key])) {
if (!is_array($this->_params[$key])) {
$this->_params[$key] = array($this->_params[$key]);
......
......@@ -212,17 +212,23 @@ class Solarium_Client_RequestTest extends PHPUnit_Framework_TestCase
{
$params = array(
'param1' => 1,
'param2' => 2,
'param3' => 3,
);
$this->_request->setParams($params);
$this->_request->addParam('param2', 2);
$this->_request->addParam('param2', '');
$this->_request->addParam('param3', '');
$params['param2'] = 2;
$this->_request->addParam('param2', ''); // this should add an empty value to param2
$this->_request->addParam('param3', '' , true); // this should overwrite param2 with an empty value
$this->_request->addParam('param4', ''); // this should add an empty param (for instance "q=" in dismax)
$this->_request->addParam('param5', null); // this param should be ignored
$this->assertEquals(
$params,
array(
'param1' => 1,
'param2' => array(2,''),
'param3' => '',
'param4' => '',
),
$this->_request->getParams()
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment