From f22ec63d3163daf02bda844c9acc32ad08671dda Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 10 Jan 2014 13:01:05 -0500 Subject: [PATCH] Added test. --- .../src/VuFindTest/Record/LoaderTest.php | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Record/LoaderTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Record/LoaderTest.php index 25c576ce23d..81a137fd5e9 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Record/LoaderTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Record/LoaderTest.php @@ -82,6 +82,46 @@ class LoaderTest extends TestCase $this->assertEquals($driver, $loader->load('test')); } + /** + * Test batch load. + * + * @return void + */ + public function testBatchLoad() + { + $driver1 = $this->getDriver('test1', 'VuFind'); + $driver2 = $this->getDriver('test2', 'VuFind'); + $driver3 = $this->getDriver('test3', 'Summon'); + $missing = $this->getDriver('missing', 'Missing'); + + $collection1 = $this->getCollection(array($driver1, $driver2)); + $collection2 = $this->getCollection(array($driver3)); + $collection3 = $this->getCollection(array()); + + $factory = $this->getMock('VuFind\RecordDriver\PluginManager'); + $factory->expects($this->once())->method('get') + ->with($this->equalTo('Missing')) + ->will($this->returnValue($missing)); + + $service = $this->getMock('VuFindSearch\Service'); + $service->expects($this->at(0))->method('retrieveBatch') + ->with($this->equalTo('VuFind'), $this->equalTo(array('test1', 'test2'))) + ->will($this->returnValue($collection1)); + $service->expects($this->at(1))->method('retrieveBatch') + ->with($this->equalTo('Summon'), $this->equalTo(array('test3'))) + ->will($this->returnValue($collection2)); + $service->expects($this->at(2))->method('retrieveBatch') + ->with($this->equalTo('WorldCat'), $this->equalTo(array('test4'))) + ->will($this->returnValue($collection3)); + + $loader = $this->getLoader($service, $factory); + $input = array( + array('source' => 'VuFind', 'id' => 'test1'), + 'VuFind|test2', 'Summon|test3', 'WorldCat|test4' + ); + $this->assertEquals(array($driver1, $driver2, $driver3, $missing), $loader->loadBatch($input)); + } + /** * Get test record driver object * -- GitLab