Commit 6080255b authored by Bas de Nooijer's avatar Bas de Nooijer

added modifier support to createDocument

parent 23a2e15d
......@@ -49,6 +49,7 @@ use Solarium\QueryType\Update\Query\Command\Commit as CommitCommand;
use Solarium\QueryType\Update\Query\Command\Delete as DeleteCommand;
use Solarium\QueryType\Update\Query\Command\Optimize as OptimizeCommand;
use Solarium\QueryType\Update\Query\Command\Rollback as RollbackCommand;
use Solarium\QueryType\Update\Query\Document\DocumentInterface;
/**
* Update query
......@@ -485,13 +486,13 @@ class Query extends BaseQuery
*
* @param array $fields
* @param array $boosts
* @return Document
* @param array $modifiers
* @return DocumentInterface
*/
public function createDocument($fields = array(), $boosts = array())
public function createDocument($fields = array(), $boosts = array(), $modifiers = array())
{
$class = $this->getDocumentClass();
return new $class($fields, $boosts);
return new $class($fields, $boosts, $modifiers);
}
}
......@@ -471,12 +471,14 @@ class QueryTest extends \PHPUnit_Framework_TestCase
$this->assertThat($doc, $this->isInstanceOf(__NAMESPACE__.'\\MyCustomDoc'));
}
public function testCreateDocumentWithFieldsAndBoosts()
public function testCreateDocumentWithFieldsAndBoostsAndModifiers()
{
$fields = array('id' => 1, 'name' => 'testname');
$boosts = array('name' => 2.7);
$modifiers = array('name' => 'set');
$doc = $this->query->createDocument($fields, $boosts);
$doc = $this->query->createDocument($fields, $boosts, $modifiers);
$doc->setKey('id');
$this->assertThat($doc, $this->isInstanceOf($this->query->getDocumentClass()));
......@@ -489,6 +491,11 @@ class QueryTest extends \PHPUnit_Framework_TestCase
2.7,
$doc->getFieldBoost('name')
);
$this->assertEquals(
$modifiers['name'],
$doc->getFieldModifier('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