Skip to content
Snippets Groups Projects
Commit 18f16b7e authored by Robert Lange's avatar Robert Lange
Browse files

refs #22542 [finc] resore finc EZB and Redi test

This reverts commit d48825aa
parent 694564c4
No related merge requests found
<?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 finc\Resolver\Driver\Ezb;
use Zend\Http\Client\Adapter\Test as TestAdapter;
/**
* 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 finc\Resolver\Driver\Redi;
use Zend\Http\Client\Adapter\Test as TestAdapter;
/**
* 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