Пример #1
0
 /**
  * Test feed generation
  *
  * @return void
  */
 public function testRSS()
 {
     // Set up a request -- we'll sort by title to ensure a predictable order
     // for the result list (relevance or last_indexed may lead to unstable test
     // cases).
     $request = new \Zend\Stdlib\Parameters();
     $request->set('lookfor', 'id:testbug2 OR id:testsample1');
     $request->set('skip_rss_sort', 1);
     $request->set('sort', 'title');
     $request->set('view', 'rss');
     $results = $this->getServiceManager()->get('VuFind\\SearchResultsPluginManager')->get('Solr');
     $results->getParams()->initFromRequest($request);
     $helper = new ResultFeed();
     $helper->setView($this->getPhpRenderer($this->getPlugins()));
     $feed = $helper->__invoke($results, '/test/path');
     $this->assertTrue(is_object($feed));
     $rss = $feed->export('rss');
     // Make sure it's really an RSS feed:
     $this->assertTrue(strstr($rss, '<rss') !== false);
     // Make sure custom Dublin Core elements are present:
     $this->assertTrue(strstr($rss, 'dc:format') !== false);
     // Now re-parse it and check for some expected values:
     $parsedFeed = \Zend\Feed\Reader\Reader::importString($rss);
     $this->assertEquals('Showing 1-2 of 2', $parsedFeed->getDescription());
     $items = [];
     $i = 0;
     foreach ($parsedFeed as $item) {
         $items[$i++] = $item;
     }
     $this->assertEquals('Journal of rational emotive therapy : ' . 'the journal of the Institute for Rational-Emotive Therapy.', $items[1]->getTitle());
 }
Пример #2
0
 /**
  * Either assign the requested search object to the view or display a flash
  * message indicating why the operation failed.
  *
  * @param string $searchId ID value of a saved advanced search.
  *
  * @return bool|object     Restored search object if found, false otherwise.
  */
 protected function restoreAdvancedSearch($searchId)
 {
     $savedSearch = parent::restoreAdvancedSearch($searchId);
     if ($savedSearch) {
         if ($filter = $savedSearch->getParams()->getSpatialDateRangeFilter(true)) {
             $req = new \Zend\Stdlib\Parameters();
             $req->set('filter', [$filter['field'] . ':"' . $filter['value'] . '"']);
             if (isset($filter['type'])) {
                 $req->set('search_sdaterange_mvtype', $filter['type']);
             }
             $savedSearch->getParams()->initSpatialDateRangeFilter($req);
         }
     }
     return $savedSearch;
 }