Commit 77ee7bcc authored by Bas de Nooijer's avatar Bas de Nooijer

Merge pull request #31 from shieldo/enforce_null

corrected setField method of read/write documents
parents bc46d920 954040b4
......@@ -124,7 +124,7 @@ class Solarium_Document_ReadWrite extends Solarium_Document_ReadOnly
*/
public function setField($key, $value, $boost = null)
{
if ($value == null) {
if ($value === null) {
$this->removeField($key);
} else {
$this->_fields[$key] = $value;
......
......@@ -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()
{
$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