Commit af7e6f04 authored by Bas de Nooijer's avatar Bas de Nooijer

- added unset property option to ReadWrite document

- updated ReadWrite unittest
parent 3f84f73e
...@@ -75,7 +75,7 @@ class Solarium_Autoloader ...@@ -75,7 +75,7 @@ class Solarium_Autoloader
*/ */
static public function load($class) static public function load($class)
{ {
if (substr($class,0,8) == 'Solarium') { if (substr($class, 0, 8) == 'Solarium') {
$class = str_replace( $class = str_replace(
array('Solarium', '_'), array('Solarium', '_'),
......
...@@ -218,4 +218,17 @@ class Solarium_Document_ReadWrite extends Solarium_Document_ReadOnly ...@@ -218,4 +218,17 @@ class Solarium_Document_ReadWrite extends Solarium_Document_ReadOnly
$this->setField($name, $value); $this->setField($name, $value);
} }
/**
* Unset field value
*
* Magic method for removing fields by unsetting object properties
*
* @param string $name
* @return void
*/
public function __unset($name)
{
$this->removeField($name);
}
} }
\ No newline at end of file
...@@ -212,6 +212,19 @@ class Solarium_Document_ReadWriteTest extends PHPUnit_Framework_TestCase ...@@ -212,6 +212,19 @@ class Solarium_Document_ReadWriteTest extends PHPUnit_Framework_TestCase
); );
} }
public function testUnsetFieldByProperty()
{
unset($this->_doc->name);
$expectedFields = $this->_fields;
unset($expectedFields['name']);
$this->assertEquals(
$expectedFields,
$this->_doc->getFields()
);
}
public function testSetFieldAsArray() public function testSetFieldAsArray()
{ {
$this->_doc['name'] = 'newname'; $this->_doc['name'] = 'newname';
......
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