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

Updated test cases to use search manager.

parent 4c10c429
Branches
Tags
No related merge requests found
...@@ -41,6 +41,7 @@ namespace VuFind\Tests; ...@@ -41,6 +41,7 @@ namespace VuFind\Tests;
abstract class TestCase extends \PHPUnit_Framework_TestCase abstract class TestCase extends \PHPUnit_Framework_TestCase
{ {
protected $searchManager = false;
/** /**
* Call protected or private method for side-effect and result. * Call protected or private method for side-effect and result.
...@@ -100,4 +101,21 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase ...@@ -100,4 +101,21 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
$reflectionProperty->setAccessible(true); $reflectionProperty->setAccessible(true);
return $reflectionProperty->setValue($object, $value); return $reflectionProperty->setValue($object, $value);
} }
/**
* Get a search manager instance for testing search objects.
*
* @return \VuFind\Search\Manager
*/
public function getSearchManager()
{
if (!$this->searchManager) {
$this->searchManager = new \VuFind\Search\Manager(
array('default_namespace' => 'VuFind\Search')
);
$serviceManager = new \Zend\ServiceManager\ServiceManager();
$this->searchManager->setServiceLocator($serviceManager);
}
return $this->searchManager;
}
} }
\ No newline at end of file
...@@ -49,10 +49,11 @@ class ParamsTest extends \VuFind\Tests\TestCase ...@@ -49,10 +49,11 @@ class ParamsTest extends \VuFind\Tests\TestCase
public function testSpellingReplacements() public function testSpellingReplacements()
{ {
// Use Solr options since base options is an abstract class. // Use Solr options since base options is an abstract class.
$options = new \VuFind\Search\Solr\Options(); $sm = $this->getSearchManager()->setSearchClassId('Solr');
$options = $sm->getOptionsInstance();
// Create Params object for testing purposes. // Create Params object for testing purposes.
$params = new \VuFind\Search\Base\Params($options); $params = $sm->setSearchClassId('Base')->getParams($options);
// Key test: word boundaries: // Key test: word boundaries:
$params->setBasicSearch('go good googler'); $params->setBasicSearch('go good googler');
......
...@@ -70,10 +70,11 @@ class ResultFeedTest extends \VuFind\Tests\ViewHelperTestCase ...@@ -70,10 +70,11 @@ class ResultFeedTest extends \VuFind\Tests\ViewHelperTestCase
$request->set('sort', 'title'); $request->set('sort', 'title');
$request->set('view', 'rss'); $request->set('view', 'rss');
$params = new \VuFind\Search\Solr\Params(); $sm = $this->getSearchManager()->setSearchClassId('Solr');
$params = $sm->getParams();
$params->initFromRequest($request); $params->initFromRequest($request);
$results = new \VuFind\Search\Solr\Results($params); $results = $sm->getResults($params);
$helper = new ResultFeed(); $helper = new ResultFeed();
$helper->setView($this->getPhpRenderer($this->getPlugins())); $helper->setView($this->getPhpRenderer($this->getPlugins()));
$mockTranslator = function ($str) { $mockTranslator = function ($str) {
......
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