The Gitlab instance will be restarted on Monday April 28th at 2AM. There will be a short interruption of service.

Skip to content
Snippets Groups Projects
Commit 4547348d authored by David Maus's avatar David Maus
Browse files

Expect ParamBag as return value for HandlerMap D/A/I

* VuFindSearch/Backend/AbstractHandlerMap.php: Expect ParamBag as
  return value for D/A/I.
parent 4ae34005
No related merge requests found
......@@ -65,9 +65,9 @@ abstract class AbstractHandlerMap
final public function prepare($function, ParamBag $params)
{
$final = $params->getArrayCopy();
$defaults = $this->getDefaults($function);
$invariants = $this->getInvariants($function);
$appends = $this->getAppends($function);
$defaults = $this->getDefaults($function)->getArrayCopy();
$invariants = $this->getInvariants($function)->getArrayCopy();
$appends = $this->getAppends($function)->getArrayCopy();
$final = array_replace($defaults, $final);
$final = array_merge_recursive($final, $appends);
......@@ -81,25 +81,25 @@ abstract class AbstractHandlerMap
*
* @param string $function Name of search function
*
* @return array Query invariants
* @return ParamBag Query invariants
*/
abstract protected function getInvariants($function);
abstract public function getInvariants($function);
/**
* Return query defaults for search function.
*
* @param string $function Name of search function
*
* @return array Query defaults
* @return ParamBag Query defaults
*/
abstract protected function getDefaults($function);
abstract public function getDefaults($function);
/**
* Return query appends for search function.
*
* @param string $function Name of search function
*
* @return array Query appends
* @return ParamBag Query appends
*/
abstract protected function getAppends($function);
abstract public function getAppends($function);
}
\ No newline at end of file
......@@ -55,13 +55,19 @@ class AbstractHandlerMapTest extends TestCase
$map = $this->getMockForAbstractClass('VuFindSearch\Backend\AbstractHandlerMap');
$map->expects($this->once())
->method('getDefaults')
->will($this->returnValue(array('p1' => array('default'), 'p2' => array('default'))));
->will(
$this->returnValue(
new ParamBag(array('p1' => array('default'), 'p2' => array('default')))
)
);
$map->expects($this->once())
->method('getAppends')
->will($this->returnValue(array()));
->will($this->returnValue(new ParamBag()));
$map->expects($this->once())
->method('getInvariants')
->will($this->returnValue(array()));
->will(
$this->returnValue(new ParamBag())
);
$params = new ParamBag(array('p2' => array('non-default')));
$map->prepare('f', $params);
......@@ -80,13 +86,13 @@ class AbstractHandlerMapTest extends TestCase
$map = $this->getMockForAbstractClass('VuFindSearch\Backend\AbstractHandlerMap');
$map->expects($this->once())
->method('getDefaults')
->will($this->returnValue(array()));
->will($this->returnValue(new ParamBag()));
$map->expects($this->once())
->method('getAppends')
->will($this->returnValue(array('p1' => 'append')));
->will($this->returnValue(new ParamBag(array('p1' => 'append'))));
$map->expects($this->once())
->method('getInvariants')
->will($this->returnValue(array()));
->will($this->returnValue(new ParamBag()));
$params = new ParamBag(array('p1' => array('something')));
$map->prepare('f', $params);
......@@ -104,13 +110,13 @@ class AbstractHandlerMapTest extends TestCase
$map = $this->getMockForAbstractClass('VuFindSearch\Backend\AbstractHandlerMap');
$map->expects($this->once())
->method('getDefaults')
->will($this->returnValue(array()));
->will($this->returnValue(new ParamBag()));
$map->expects($this->once())
->method('getAppends')
->will($this->returnValue(array('p1' => array('append'))));
->will($this->returnValue(new ParamBag(array('p1' => array('append')))));
$map->expects($this->once())
->method('getInvariants')
->will($this->returnValue(array('p1' => array('invariant'))));
->will($this->returnValue(new ParamBag(array('p1' => array('invariant')))));
$params = new ParamBag(array('p1' => array('something')));
$map->prepare('f', $params);
......
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