Commit 954040b4 authored by Douglas Greenshields's avatar Douglas Greenshields

corrected setField method of read/write documents so passing in false but not...

corrected setField method of read/write documents so passing in false but not null value does not mean field is removed
parent bc46d920
...@@ -124,7 +124,7 @@ class Solarium_Document_ReadWrite extends Solarium_Document_ReadOnly ...@@ -124,7 +124,7 @@ class Solarium_Document_ReadWrite extends Solarium_Document_ReadOnly
*/ */
public function setField($key, $value, $boost = null) public function setField($key, $value, $boost = null)
{ {
if ($value == null) { if ($value === null) {
$this->removeField($key); $this->removeField($key);
} else { } else {
$this->_fields[$key] = $value; $this->_fields[$key] = $value;
......
...@@ -128,6 +128,20 @@ class Solarium_Document_ReadWriteTest extends PHPUnit_Framework_TestCase ...@@ -128,6 +128,20 @@ class Solarium_Document_ReadWriteTest extends PHPUnit_Framework_TestCase
); );
} }
public function testSetFieldWithFalsyValue()
{
$falsy_value = '';
$this->_doc->setField('name', $falsy_value);
$expectedFields = $this->_fields;
$expectedFields['name'] = $falsy_value;
$this->assertEquals(
$expectedFields,
$this->_doc->getFields()
);
}
public function testRemoveField() public function testRemoveField()
{ {
$this->_doc->removeField('name'); $this->_doc->removeField('name');
......
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