Skip to content
Snippets Groups Projects
Commit d9eeea47 authored by Demian Katz's avatar Demian Katz
Browse files

Improved test coverage.

parent 71884204
No related merge requests found
...@@ -77,7 +77,8 @@ class MultiIndexListenerTest extends TestCase ...@@ -77,7 +77,8 @@ class MultiIndexListenerTest extends TestCase
array('or', '~') array('or', '~')
) )
) )
) ),
'FilterQuery' => 'format:Book',
) )
); );
...@@ -150,6 +151,47 @@ class MultiIndexListenerTest extends TestCase ...@@ -150,6 +151,47 @@ class MultiIndexListenerTest extends TestCase
$this->assertEquals(array('field_1', 'field_2'), $facets); $this->assertEquals(array('field_1', 'field_2'), $facets);
} }
/**
* Test that loading a record overrides the shard settings.
*
* @return void
*/
public function testAllShardsUsedForRecordRetrieval()
{
$params = new ParamBag(
array(
'shards' => array(self::$shards['b'], self::$shards['c']),
)
);
$event = new Event(
'pre', $this->backend,
array('params' => $params, 'context' => 'retrieve')
);
$this->listener->onSearchPre($event);
$shards = $params->get('shards');
$this->assertEquals(
array(implode(',', array(self::$shards['a'], self::$shards['b'], self::$shards['c']))),
$shards
);
}
/**
* Test attaching listener.
*
* @return void
*/
public function testAttach()
{
$mock = $this->getMock('Zend\EventManager\SharedEventManagerInterface');
$mock->expects($this->once())->method('attach')->with(
$this->equalTo('VuFind\Search'),
$this->equalTo('pre'),
$this->equalTo(array($this->listener, 'onSearchPre'))
);
$this->listener->attach($mock);
}
/** /**
* Apply strip to empty specs. * Apply strip to empty specs.
* *
...@@ -193,7 +235,8 @@ class MultiIndexListenerTest extends TestCase ...@@ -193,7 +235,8 @@ class MultiIndexListenerTest extends TestCase
array('onephrase', 300) array('onephrase', 300)
) )
) )
) ),
'FilterQuery' => 'format:Book',
) )
), ),
$specs $specs
...@@ -209,7 +252,7 @@ class MultiIndexListenerTest extends TestCase ...@@ -209,7 +252,7 @@ class MultiIndexListenerTest extends TestCase
{ {
$specs = $this->callMethod($this->listener, 'getSearchSpecs', array(array('A', 'B', 'C', 'D', 'E'))); $specs = $this->callMethod($this->listener, 'getSearchSpecs', array(array('A', 'B', 'C', 'D', 'E')));
$this->assertEquals( $this->assertEquals(
array('test' => array('QueryFields' => array())), array('test' => array('QueryFields' => array(), 'FilterQuery' => 'format:Book')),
$specs $specs
); );
} }
......
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