Commit cab90c78 authored by Douglas Greenshields's avatar Douglas Greenshields

- added clear method for readwrite documents for easy clearing of fields and boosts

parent 607a89a0
......@@ -202,6 +202,17 @@ class Solarium_Document_ReadWrite extends Solarium_Document_ReadOnly
return $this->_boost;
}
/**
* Clear all fields
*
* @return void
**/
public function clear()
{
$this->_fields = array();
$this->_fieldBoosts = array();
}
/**
* Set field value
*
......
......@@ -273,4 +273,29 @@ class Solarium_Document_ReadWriteTest extends PHPUnit_Framework_TestCase
);
}
public function testClearFields()
{
$this->_doc->clear();
$expectedFields = array();
$this->assertEquals(
$expectedFields,
$this->_doc->getFields()
);
}
public function testClearFieldsBoostRemoval()
{
$this->_doc->setFieldBoost('name', 3.2);
$this->_doc->clear();
$expectedFields = array();
$this->assertEquals(
null,
$this->_doc->getFieldBoost('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