Skip to content
Snippets Groups Projects
Commit 84039bc4 authored by llaffont's avatar llaffont
Browse files

Prise en charge de l'authentification si le web service Koha est indisponible

parent e1b16a41
Branches
Tags
No related merge requests found
......@@ -81,7 +81,11 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic
*/
public function httpGet($options) {
$url = $this->buildQueryURL($options);
return $this->getWebClient()->open_url($url);
try {
return $this->getWebClient()->open_url($url);
} catch (Exception $e) {
return '';
}
}
......@@ -190,11 +194,8 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic
public function ilsdiAction($name, $params, $error_tag, $error_message) {
$params = array_merge(array('service' => $name), $params);
try {
$xml = $this->httpGet($params);
} catch (Exception $e) {
if (!$xml = $this->httpGet($params))
return $this->_getNetworkError();
}
if (0 === strpos($xml, '<html>'))
return $this->_getNetworkError();
......
......@@ -254,6 +254,31 @@ class KohaServiceGetNoticeHarryPotterTest extends KohaTestCase {
class KohaGetEmprunteurErrorTest extends KohaTestCase {
public function setUp() {
parent::setUp();
$this->mock_web_client
->expects($this->any())
->method('open_url')
->will($this->throwException(new Exception('network error')));
$this->emprunteur = $this->service->getEmprunteur(Class_Users::newInstance()
->setLogin('zork')
->setPassword('afi'));
}
/** @test */
public function emprunteurShouldNotBeValid() {
$this->assertFalse($this->emprunteur->isValid());
}
}
class KohaGetEmprunteurLaurentLaffontTest extends KohaTestCase {
public function setUp() {
parent::setUp();
......
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