Skip to content
Snippets Groups Projects
Commit d48825aa authored by André Lahmann's avatar André Lahmann Committed by Robert Lange
Browse files

efs #22542 [finc] remove obsolete finc Redi and tests

parent 753bcf04
No related merge requests found
......@@ -205,12 +205,10 @@ $config = [
],
'resolver_driver' => [
'factories' => [
'finc\Resolver\Driver\Ezb' => 'finc\Resolver\Driver\FincResolverDriverFactory',
'finc\Resolver\Driver\Redi' => 'finc\Resolver\Driver\FincResolverDriverFactory'
'finc\Resolver\Driver\Ezb' => 'finc\Resolver\Driver\FincResolverDriverFactory'
],
'aliases' => [
'ezb' => 'finc\Resolver\Driver\Ezb',
'redi' => 'finc\Resolver\Driver\Redi'
'ezb' => 'finc\Resolver\Driver\Ezb'
]
],
'hierarchy_treedataformatter' => [
......
<?php
/**
* ReDi Link Resolver Driver
*
* PHP version 5
*
* Copyright (C) Leipzig University Library 2015
*
* @category VuFind
* @package Resolver_Drivers
* @author Robert Lange <lange@ub.uni-leipzig.de>
* @author Gregor Gawol <gawol@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:link_resolver_drivers Wiki
*/
namespace finc\Resolver\Driver;
use VuFind\Resolver\Driver\Redi as RediBase;
use Zend\Dom\DOMXPath;
/**
* Redi Link Resolver Driver
*
* @category VuFind
* @package Resolver_Drivers
* @author Robert Lange <lange@ub.uni-leipzig.de>
* @author Gregor Gawol <gawol@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:link_resolver_drivers Wiki
*/
class Redi extends RediBase
{
/**
* Constructor
*
* @param string $config redi configuration
* @param \Zend\Http\Client $httpClient HTTP client
*/
public function __construct($config, \Zend\Http\Client $httpClient)
{
$this->baseUrl = $config->url;
$this->httpClient = $httpClient;
}
/**
* Fetch Links
*
* Fetches a set of links corresponding to an OpenURL
*
* @param string $openURL openURL (url-encoded)
*
* @return string raw XML returned by resolver
*/
public function fetchLinks($openURL)
{
$url = $this->getResolverUrl($openURL);
$feed = $this->httpClient->setUri($url)->send()->getBody();
return $feed;
}
/**
* Parse the Redi XML response and return array with DOI information.
*
* @param DOMDocument $xml Loaded xml document
*
* @deprecated with VuFind 9 - cf. https://github.com/vufind-org/vufind/pull/2419
* @return array Get back a array with title, URL and service_type
*/
protected function parseDOI($xml)
{
$retval = [];
$xpath = new DOMXPath($xml);
$doiTerm = $xpath
->query("//dt[@class='doi_t']");
$doiDefinition = $xpath
->query("//dd[@class='doi_d']");
if ($doiTerm->length == $doiDefinition->length) {
for ($i = 0; $i < $doiTerm->length; $i++) {
$href = $xpath
->query(".//@href", $doiDefinition->item($i))
->item(0)->textContent;
$retval[] = [
'title' => $doiTerm->item($i)->textContent
. $doiDefinition->item($i)->textContent,
'href' => $href,
'access' => 'unknown',
'coverage' => null,
'service_type' => 'getDOI',
];
}
}
return $retval;
}
}
<?php
/**
* Finc Resolver Ezb Test Class
*
* PHP version 5
*
* Copyright (C) Leipzig University Library 2017.
*
* 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.
*
* @category Finc
* @package Tests
* @author Robert Lange <lange@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:testing:unit_tests Wiki
*/
namespace FincTest\Resolver\Driver\Root;
use Zend\Http\Client\Adapter\Test as TestAdapter;
use finc\Resolver\Driver\Ezb;
/**
* Finc Resolver Redi Test Class
*
* @category Finc
* @package Tests
* @author Robert Lange <lange@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:testing:unit_tests Wiki
*/
class EzbTest extends \VuFindTest\Resolver\Driver\EzbTest
{
protected $adapter;
protected $client;
protected function initEmpty()
{
$this->adapter = new TestAdapter();
$this->client = new \Zend\Http\Client();
$this->client->setAdapter($this->adapter);
}
protected function getInstance($baseUrl = false)
{
$this->initEmpty();
return $ezb = new Ezb(
$baseUrl !== false ? (object) ['url' => $baseUrl] : (object) $this->openUrlConfig['OpenURL'],
$this->client
);
}
public function testGetResolverUrl()
{
$openUrl = "x=1&y=2";
$this->assertEquals(
"{$this->openUrlConfig['OpenURL']['url']}?$openUrl",
$this->getInstance()->getResolverUrl($openUrl)
);
}
public function testGetResolverUrlWithQuestionMarkInBaseUrl()
{
$baseUrl = "{$this->openUrlConfig['OpenURL']['url']}?site=xyz";
$openUrl = "x=1&y=2";
$this->assertEquals("$baseUrl&$openUrl", $this->getInstance($baseUrl)->getResolverUrl($openUrl));
}
public function testGetResolverUrlNoParams()
{
$this->assertEquals($this->openUrlConfig['OpenURL']['url'], $this->getInstance()->getResolverUrl(""));
}
public function testEmptyBaseUrlException()
{
$this->expectException(\Zend\Config\Exception\InvalidArgumentException::class);
$this->getInstance("")->getResolverUrl("xyz");
}
public function testRemoveLeadingConnectorFromOpenUrl()
{
$baseUrl = "http://services.dnb.de/fize-service/gvr/full.xml";
$openUrl = "&x=1&y=2";
$this->assertEquals(
"http://services.dnb.de/fize-service/gvr/full.xml?x=1&y=2",
$this->getInstance($baseUrl)->getResolverUrl($openUrl)
);
$openUrl = "?x=1&y=2";
$this->assertEquals(
"http://services.dnb.de/fize-service/gvr/full.xml?x=1&y=2",
$this->getInstance($baseUrl)->getResolverUrl($openUrl)
);
}
}
<?php
/**
* Finc Resolver Redi Test Class
*
* PHP version 5
*
* Copyright (C) Leipzig University Library 2017.
*
* 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.
*
* @category Finc
* @package Tests
* @author Robert Lange <lange@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:testing:unit_tests Wiki
*/
namespace FincTest\Resolver\Driver\Root;
use Zend\Http\Client\Adapter\Test as TestAdapter;
use finc\Resolver\Driver\Redi;
/**
* Finc Resolver Redi Test Class
*
* @category Finc
* @package Tests
* @author Robert Lange <lange@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:testing:unit_tests Wiki
*/
class RediTest extends \VuFindTest\Resolver\Driver\RediTest
{
protected $adapter;
protected $client;
protected function initEmpty()
{
$this->adapter = new TestAdapter();
$this->client = new \Zend\Http\Client();
$this->client->setAdapter($this->adapter);
}
protected function getInstance($baseUrl = false)
{
$this->initEmpty();
return $redi = new Redi(
$baseUrl !== false ? $baseUrl : $this->openUrlConfig['OpenURL']['url'],
$this->client
);
}
public function testGetResolverUrl()
{
$openUrl = "x=1&y=2";
$this->assertEquals(
"{$this->openUrlConfig['OpenURL']['url']}?$openUrl",
$this->getInstance()->getResolverUrl($openUrl)
);
}
public function testGetResolverUrlWithQuestionMarkInBaseUrl()
{
$baseUrl = "{$this->openUrlConfig['OpenURL']['url']}?site=xyz";
$openUrl = "x=1&y=2";
$this->assertEquals("$baseUrl&$openUrl", $this->getInstance($baseUrl)->getResolverUrl($openUrl));
}
public function testGetResolverUrlNoParams()
{
$this->assertEquals($this->openUrlConfig['OpenURL']['url'], $this->getInstance()->getResolverUrl(""));
}
public function testGetResolverUrlWHZ()
{
$openUrl = "rl_site=whz&issn=1941-9511";
$this->assertEquals(
"http://www.redi-bw.de/links/whz?rl_site=whz&rl_site=whz&issn=1941-9511",
$this->getInstance("http://www.redi-bw.de/links/whz?rl_site=whz")->getResolverUrl($openUrl)
);
}
public function testEmptyBaseUrlException()
{
$this->expectException(\Zend\Config\Exception\InvalidArgumentException::class);
$this->getInstance("")->getResolverUrl("");
}
}
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