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

More test coverage.

parent 717d1852
Branches
Tags
No related merge requests found
<?php
/**
* WorldCat Similar Related Items Test Class
*
* PHP version 5
*
* Copyright (C) Villanova University 2010.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @category VuFind2
* @package Tests
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:unit_tests Wiki
*/
namespace VuFindTest\Related;
use VuFind\Related\WorldCatSimilar, VuFindSearch\Query\Query;
/**
* WorldCat Similar Related Items Test Class
*
* @category VuFind2
* @package Tests
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:unit_tests Wiki
*/
class WorldCatSimilarTest extends \VuFindTest\Unit\TestCase
{
/**
* Test results.
*
* @return void
*/
public function testGetResults()
{
$driver = $this->getMock(
'VuFind\RecordDriver\SolrDefault',
array('tryMethod', 'getPrimaryAuthor', 'getAllSubjectHeadings', 'getTitle')
);
$driver->expects($this->once())
->method('tryMethod')
->with($this->equalTo('getDeweyCallNumber'))
->will($this->returnValue('fakedc'));
$driver->expects($this->once())
->method('getPrimaryAuthor')
->will($this->returnValue('fakepa'));
$driver->expects($this->once())
->method('getAllSubjectHeadings')
->will($this->returnValue(array(array('fakesh1a', 'fakesh1b'), array('fakesh2'))));
$driver->expects($this->once())
->method('getTitle')
->will($this->returnValue('faketitle'));
$service = $this->getMock('VuFindSearch\Service', array('search'));
$expectedQuery = new Query('(srw.dd any "fakedc" or srw.au all "fakepa" or srw.su all "fakesh1a fakesh1b" or srw.su all "fakesh2" or srw.ti any "faketitle")');
$response = $this->getMock('VuFindSearch\Backend\WorldCat\Response\XML\RecordCollection', array('getRecords'), array(array('offset' => 0, 'total' => 0)));
$response->expects($this->once())
->method('getRecords')
->will($this->returnValue(array('fakeresponse')));
$service->expects($this->once())
->method('search')
->with($this->equalTo('WorldCat'), $this->equalTo($expectedQuery), $this->equalTo(0), $this->equalTo(5))
->will($this->returnValue($response));
$similar = new WorldCatSimilar($service);
$similar->init('', $driver);
$this->assertEquals(array('fakeresponse'), $similar->getResults());
}
}
\ No newline at end of file
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