Commit 917fc7d8 authored by Bas de Nooijer's avatar Bas de Nooijer

Merge pull request #19 from shieldo/clear_documents

Clear documents
parents 666bf48d 2a6f316f
...@@ -202,6 +202,17 @@ class Solarium_Document_ReadWrite extends Solarium_Document_ReadOnly ...@@ -202,6 +202,17 @@ class Solarium_Document_ReadWrite extends Solarium_Document_ReadOnly
return $this->_boost; return $this->_boost;
} }
/**
* Clear all fields
*
* @return void
**/
public function clear()
{
$this->_fields = array();
$this->_fieldBoosts = array();
}
/** /**
* Set field value * Set field value
* *
......
...@@ -273,4 +273,29 @@ class Solarium_Document_ReadWriteTest extends PHPUnit_Framework_TestCase ...@@ -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