diff --git a/VERSIONS_HOTLINE/26484 b/VERSIONS_HOTLINE/26484 new file mode 100644 index 0000000000000000000000000000000000000000..e519aa7de7efc04a0d73793317897339e4670ab1 --- /dev/null +++ b/VERSIONS_HOTLINE/26484 @@ -0,0 +1 @@ + - ticket #26484 : ajout possibilité de traduction / remplacement de textes des messages d'erreurs des connecteurs ILSDI \ No newline at end of file diff --git a/library/Class/WebService/SIGB/AbstractRESTService.php b/library/Class/WebService/SIGB/AbstractRESTService.php index 389463a12d669642845d84c2efd975d19ce15a13..65379cc2fab8830da6bb684ebd84a5fb9fad1e80 100644 --- a/library/Class/WebService/SIGB/AbstractRESTService.php +++ b/library/Class/WebService/SIGB/AbstractRESTService.php @@ -20,6 +20,8 @@ */ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebService_SIGB_AbstractService { + use Trait_Translator; + protected $_server_root; protected $_web_client; @@ -37,7 +39,7 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic * @return Class_WebService_SIGB_AbstractRESTService */ public function setServerRoot($server_root) { - $this->_server_root = 'http://'.str_replace('http://', '', $server_root); + $this->_server_root = 'http://' . str_replace('http://', '', $server_root); return $this; } @@ -178,7 +180,8 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic * @return array */ public function ilsdiHoldTitle($params, $error_tag = 'error') { - return $this->ilsdiAction('HoldTitle', $params, $error_tag, 'Réservation impossible'); + return $this->ilsdiAction('HoldTitle', $params, $error_tag, + $this->_('Réservation impossible')); } @@ -187,7 +190,8 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic * @return array */ public function ilsdiHoldItem($params, $error_tag = 'error') { - return $this->ilsdiAction('HoldItem', $params, $error_tag, 'Réservation impossible'); + return $this->ilsdiAction('HoldItem', $params, $error_tag, + $this->_('Réservation impossible')); } @@ -195,7 +199,8 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic * @param array $params */ public function ilsdiCancelHold($params, $error_tag='error') { - return $this->ilsdiAction('CancelHold', $params, $error_tag, 'Annulation impossible'); + return $this->ilsdiAction('CancelHold', $params, $error_tag, + $this->_('Annulation impossible')); } @@ -203,7 +208,8 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic * @param array $params */ public function ilsdiRenewLoan($params, $error_tag='error') { - return $this->ilsdiAction('RenewLoan', $params, $error_tag, 'Prolongation impossible'); + return $this->ilsdiAction('RenewLoan', $params, $error_tag, + $this->_('Prolongation impossible')); } @@ -211,12 +217,13 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic * @param string $xml */ public function ilsdiUpdatePatronInfo($xml, $error_tag='error'){ - return $this->ilsdiCheckXml($xml, $error_tag, 'Mise à jour impossible'); + return $this->ilsdiCheckXml($xml, $error_tag, + $this->_('Mise à jour impossible')); } public function ilsdiAction($name, $params, $error_tag, $error_message) { - $params = array_merge(array('service' => $name), $params); + $params = array_merge(['service' => $name], $params); return $this->ilsdiCheckXml($this->httpGet($params), $error_tag, $error_message); } @@ -239,8 +246,6 @@ abstract class Class_WebService_SIGB_AbstractRESTService extends Class_WebServic * @return array */ protected function _getNetworkError() { - return $this->_error('Service indisponible'); + return $this->_error($this->_('Service indisponible')); } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php index 0f429f978b671b14211fd54cc3242b78cc55cd59..69fe7f6addfa4dc1d0cd462b06fee0c403366ec1 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php @@ -517,9 +517,10 @@ class AbonneControllerPretsRenewErrorThreePretsTest extends AbonneControllerPret return $this->mock() ->whenCalled('prolongerPret') ->answers(['statut' => 0, - 'erreur' => 'Patron not found']); + 'erreur' => '<strong>Patron not found</strong>']); } + /** @test */ public function popupTitleShouldBeErreur() { $this->assertEquals('Erreur', $this->json->title); @@ -528,7 +529,7 @@ class AbonneControllerPretsRenewErrorThreePretsTest extends AbonneControllerPret /** @test */ public function popupContentShouldContainsPatronNotFound() { - $this->assertEquals('Patron not found', $this->json->content); + $this->assertEquals('<strong>Patron not found</strong>', $this->json->content); } } diff --git a/tests/library/Class/WebService/SIGB/KohaTest.php b/tests/library/Class/WebService/SIGB/KohaTest.php index d75b7d621b93fa7b88e034dc463714b1dad870ce..2747923538a83b4e6d61ee7e03836082e573e9d3 100644 --- a/tests/library/Class/WebService/SIGB/KohaTest.php +++ b/tests/library/Class/WebService/SIGB/KohaTest.php @@ -52,8 +52,8 @@ class KohaGetServiceTest extends PHPUnit_Framework_TestCase { } -abstract class KohaTestCase extends PHPUnit_Framework_TestCase { - use Storm_Test_THelpers; +abstract class KohaTestCase extends ModelTestCase { + protected $_storm_default_to_volatile = true; protected $mock_web_client; protected $service; @@ -62,8 +62,10 @@ abstract class KohaTestCase extends PHPUnit_Framework_TestCase { ['id' => 1, 'libelle' => 'Actu'])); - Class_AdminVar::newInstanceWithId('KOHA_MULTI_SITES', ['valeur' => '' ]); - $this->mock_web_client = $this->getMock('Class_WebService_SimpleWebClient'); + $this->fixture('Class_AdminVar', ['id' => 'KOHA_MULTI_SITES', + 'valeur' => '']); + + $this->mock_web_client = $this->mock(); $this->service = Class_WebService_SIGB_Koha::getService(['url_serveur' => 'http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl']); $this->service->setWebClient($this->mock_web_client); @@ -76,10 +78,9 @@ class KohaServiceGetNoticeJardinEnfantTest extends KohaTestCase { parent::setUp(); $this->mock_web_client - ->expects($this->once()) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=GetRecords&id=1') - ->will($this->returnValue(KohaFixtures::xmlGetRecordOneJardinEnfance())); + ->answers(KohaFixtures::xmlGetRecordOneJardinEnfance()); $this->jardins_enfant = $this->service->getNotice('1'); } @@ -120,10 +121,9 @@ abstract class KohaServiceGetNoticeHarryPotterTestCase extends KohaTestCase { public function setUp() { parent::setUp(); $this->mock_web_client - ->expects($this->once()) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=GetRecords&id=33233') - ->will($this->returnValue(KohaFixtures::xmlGetRecordHarryPotter())); + ->answers(KohaFixtures::xmlGetRecordHarryPotter()); } } @@ -303,9 +303,8 @@ class KohaGetEmprunteurErrorTest extends KohaTestCase { parent::setUp(); $this->mock_web_client - ->expects($this->any()) - ->method('open_url') - ->will($this->throwException(new Exception('network error'))); + ->whenCalled('open_url') + ->willDo(function() { throw new Exception('network error'); }); $this->emprunteur = $this->service->getEmprunteur(Class_Users::newInstance() ->setLogin('zork') @@ -335,23 +334,21 @@ class KohaGetEmprunteurLaureAfondTest extends KohaTestCase { 'code' => 'MON']); $this->mock_web_client - ->expects($this->at(0)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=LookupPatron&id=012345&id_type=cardnumber') - ->will($this->returnValue(KohaFixtures::xmlLookupPatronLaure())); + ->answers(KohaFixtures::xmlLookupPatronLaure()); $this->mock_web_client - ->expects($this->at(1)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=572&show_contact=0&show_loans=1&show_holds=1') - ->will($this->returnValue(KohaFixtures::xmlGetPatronInfoLaure())); + ->answers(KohaFixtures::xmlGetPatronInfoLaure()); - $this->laurent = $this->service->getEmprunteur( - Class_Users::getLoader()->newInstance() - ->setLogin('lafond') - ->setPassword('afi') - ->setIdabon('012345') + $this->laurent = $this->service + ->getEmprunteur(Class_Users::newInstance() + ->setLogin('lafond') + ->setPassword('afi') + ->setIdabon('012345') ); } @@ -483,30 +480,25 @@ class KohaGetEmprunteurJeanAndreWithIdSIGBTest extends KohaTestCase { parent::setUp(); $this->mock_web_client - ->expects($this->at(0)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=LookupPatron&id=01234&id_type=cardnumber') - ->will($this->returnValue(KohaFixtures::xmlLookupPatronJeanAndre())); + ->answers(KohaFixtures::xmlLookupPatronJeanAndre()); $this->mock_web_client - ->expects($this->at(1)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=GetPatronInfo&patron_id=419&show_contact=0&show_loans=1&show_holds=1') - ->will($this->returnValue(KohaFixtures::xmlGetPatronInfoJeanAndre())); - - $this->jean = $this->service->getEmprunteur( - $this->fixture('Class_Users', ['id' => 43, - 'login' => 'JEAN', - 'password' => 'zork', - 'id_sigb' => '01234'])); + ->answers(KohaFixtures::xmlGetPatronInfoJeanAndre()); $this->fixture('Class_CodifAnnexe', ['id' => 33, 'libelle' => 'Testing branch', 'code' => 'BIB']); - - Class_Exemplaire::beVolatile(); - Class_Notice::beVolatile(); + $this->jean = $this->service + ->getEmprunteur($this->fixture('Class_Users', + ['id' => 43, + 'login' => 'JEAN', + 'password' => 'zork', + 'id_sigb' => '01234'])); } @@ -596,21 +588,21 @@ class KohaOperationsTest extends KohaTestCase { public function setUp() { parent::setUp(); - $this->_lafond = Class_Users::getLoader()->newInstance() - ->setLogin('lafond') - ->setPassword('afi') - ->setIdabon('012345'); + $this->_lafond = $this->fixture('Class_Users', + ['id' => 67, + 'login' => 'lafond', + 'password' => 'afi', + 'idabon' => '012345']); $this->mock_web_client - ->expects($this->at(0)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=LookupPatron&id=012345&id_type=cardnumber') - ->will($this->returnValue(KohaFixtures::xmlLookupPatronLaure())); + ->answers(KohaFixtures::xmlLookupPatronLaure()); - $this->_exemplaire_mireille_abeille = Class_Exemplaire::getLoader() - ->newInstanceWithId(123) - ->setIdOrigine('89863'); + $this->_exemplaire_mireille_abeille = $this->fixture('Class_Exemplaire', + ['id' => 123, + 'id_origine' => '89863']); } @@ -618,13 +610,12 @@ class KohaOperationsTest extends KohaTestCase { /** @test */ function supprimerReservationShouldCallCancelHoldServiceAndReturnResultOK() { $this->mock_web_client - ->expects($this->at(1)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=CancelHold&patron_id=572&item_id=24426') - ->will($this->returnValue('<CancelHold><code>Canceled</code></CancelHold>')); + ->answers('<CancelHold><code>Canceled</code></CancelHold>'); - $this->assertEquals(array('statut' => true,'erreur' => ''), + $this->assertEquals(['statut' => true,'erreur' => ''], $this->service->supprimerReservation($this->_lafond, '24426')); } @@ -632,33 +623,56 @@ class KohaOperationsTest extends KohaTestCase { /** @test */ function supprimerReservationShouldReturnErrorIfNotCanceled() { $this->mock_web_client - ->expects($this->at(1)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=CancelHold&patron_id=572&item_id=24426') - ->will($this->returnValue('<CancelHold><code>NotCanceled</code></CancelHold>')); + ->answers('<CancelHold><code>NotCanceled</code></CancelHold>'); - $this->assertEquals(array('statut' => false,'erreur' => 'NotCanceled'), + $this->assertEquals(['statut' => false,'erreur' => 'NotCanceled'], $this->service->supprimerReservation($this->_lafond, '24426')); } /** @test */ + function prolongerPretWithErrorAndTextReplacementShouldReplaceText() { + Class_TextReplacements::reset(); + $this->fixture('Class_AdminVar', + ['id' => 'TEXT_REPLACEMENTS', + 'valeur' => 'Prolongation impossible;Prolongation impossible. Vous êtes dans l\'un des cas suivants : <br>- Le nombre de prolongations autorisé est dépassé<br>- Le document est en retard<br>- Le document est réservé par une autre personne']); + + $this->mock_web_client + ->whenCalled('open_url') + ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=RenewLoan&patron_id=572&item_id=24426') + ->answers('<RenewLoan> + <success>0</success> + <error> + <message>too_many</message> + </error> + <date_due>2009-06-22</date_due> + </RenewLoan>'); + + + $this->assertEquals(['statut' => false, + 'erreur' => 'Prolongation impossible. Vous êtes dans l\'un des cas suivants : <br>- Le nombre de prolongations autorisé est dépassé<br>- Le document est en retard<br>- Le document est réservé par une autre personne'], + $this->service->prolongerPret($this->_lafond, '24426')); + } + + + /** @test */ function prolongerPretWithKohaCG55VersionShouldReturnErrorIfTooMany() { $this->mock_web_client - ->expects($this->at(1)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=RenewLoan&patron_id=572&item_id=24426') - ->will($this->returnValue('<RenewLoan> - <success>0</success> + ->answers('<RenewLoan> + <success>0</success> <error> <message>too_many</message> </error> <date_due>2009-06-22</date_due> - </RenewLoan>')); + </RenewLoan>'); - $this->assertEquals(array('statut' => false, 'erreur' => 'Prolongation impossible'), + $this->assertEquals(['statut' => false, 'erreur' => 'Prolongation impossible'], $this->service->prolongerPret($this->_lafond, '24426')); } @@ -666,15 +680,14 @@ class KohaOperationsTest extends KohaTestCase { /** @test */ function prolongerPretShouldReturnErrorIfTooMany() { $this->mock_web_client - ->expects($this->at(1)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=RenewLoan&patron_id=572&item_id=24426') - ->will($this->returnValue('<RenewLoan> + ->answers('<RenewLoan> <success>0</success> <renewals>1</renewals> <error>too_many</error> <date_due>2009-06-22</date_due> - </RenewLoan>')); + </RenewLoan>'); $this->assertEquals(array('statut' => false, 'erreur' => 'Prolongation impossible'), @@ -686,15 +699,14 @@ class KohaOperationsTest extends KohaTestCase { /** @test */ function prolongerPretShouldReturnSuccessIfNoErrors() { $this->mock_web_client - ->expects($this->at(1)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=RenewLoan&patron_id=572&item_id=24426') - ->will($this->returnValue('<?xml version="1.0" encoding="ISO-8859-1" ?> + ->answers('<?xml version="1.0" encoding="ISO-8859-1" ?> <RenewLoan> <success>0</success> <renewals>5</renewals> <date_due>2011-05-11</date_due> - </RenewLoan>')); + </RenewLoan>'); $this->assertEquals(array('statut' => true, 'erreur' => ''), @@ -706,10 +718,9 @@ class KohaOperationsTest extends KohaTestCase { /** @test */ function prolongerPretWithKohaCG55VersionShouldReturnSuccessIfNoErrors() { $this->mock_web_client - ->expects($this->at(1)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=RenewLoan&patron_id=572&item_id=24426') - ->will($this->returnValue('<?xml version="1.0" encoding="ISO-8859-1" ?> + ->answers('<?xml version="1.0" encoding="ISO-8859-1" ?> <RenewLoan> <success>1</success> <renewals>2</renewals> @@ -717,7 +728,7 @@ class KohaOperationsTest extends KohaTestCase { <renewalsallowed>2</renewalsallowed> </error> <date_due>2015-07-19</date_due> - </RenewLoan>')); + </RenewLoan>'); $this->assertEquals(array('statut' => true, 'erreur' => ''), @@ -729,13 +740,12 @@ class KohaOperationsTest extends KohaTestCase { /** @test */ function reserverExemplaireShouldReturnSuccessIfNoErrors() { $this->mock_web_client - ->expects($this->at(1)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=HoldTitle&patron_id=572&bib_id=89863&request_location=127.0.0.1') - ->will($this->returnValue('<HoldTitle> + ->answers('<HoldTitle> <title>Mireille l\'abeille</title> <pickup_location>Bibliothèque Départementale de la Meuse</pickup_location> - </HoldTitle>')); + </HoldTitle>'); $this->assertEquals(array('statut' => true, 'erreur' => ''), @@ -749,13 +759,12 @@ class KohaOperationsTest extends KohaTestCase { /** @test */ function reserverExemplaireShouldSendPickupLocationIfGiven() { $this->mock_web_client - ->expects($this->at(1)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=HoldTitle&patron_id=572&bib_id=89863&request_location=127.0.0.1&pickup_location=BLV') - ->will($this->returnValue('<HoldTitle> + ->answers('<HoldTitle> <title>Mireille l\'abeille</title> <pickup_location>Bibliothèque Départementale de la Meuse</pickup_location> - </HoldTitle>')); + </HoldTitle>'); $this->assertEquals(array('statut' => true, 'erreur' => ''), $this->service->reserverExemplaire($this->_lafond, $this->_exemplaire_mireille_abeille, 'BLV')); @@ -766,12 +775,11 @@ class KohaOperationsTest extends KohaTestCase { /** @test */ function reserverExemplaireShouldReturnErrorIfFail() { $this->mock_web_client - ->expects($this->at(1)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=HoldTitle&patron_id=572&bib_id=89863&request_location=127.0.0.1') - ->will($this->returnValue('<HoldTitle> + ->answers('<HoldTitle> <code>NotHoldable</code> - </HoldTitle>')); + </HoldTitle>'); $this->assertEquals(array('statut' => false, 'erreur' => 'Réservation impossible'), $this->service->reserverExemplaire($this->_lafond, $this->_exemplaire_mireille_abeille, '')); @@ -779,40 +787,44 @@ class KohaOperationsTest extends KohaTestCase { } + class KohaTestMultiSites extends KohaTestCase{ public function setUp() { parent::setUp(); - Class_AdminVar::newInstanceWithId('KOHA_MULTI_SITES', ['valeur' => '1']); - $this->_lafond = Class_Users::getLoader()->newInstance() - ->setLogin('lafond') - ->setPassword('afi') - ->setIdabon('012345'); + $this->fixture('Class_AdminVar', + ['id' => 'KOHA_MULTI_SITES', + 'valeur' => '1']); + + $this->_lafond = $this->fixture('Class_Users', + ['id' => 67, + 'login' => 'lafond', + 'password' => 'afi', + 'idabon' => '012345']); $this->mock_web_client - ->expects($this->at(0)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=LookupPatron&id=012345&id_type=cardnumber') - ->will($this->returnValue(KohaFixtures::xmlLookupPatronLaure())); + ->answers(KohaFixtures::xmlLookupPatronLaure()); - $this->_exemplaire_mireille_abeille = Class_Exemplaire::getLoader() - ->newInstanceWithId(123) - ->setIdOrigine('89863') - ->setZone995(serialize([['clef' => 'a', 'valeur' => '28'], - ['clef' => '9', 'valeur' => '999']])); + $this->_exemplaire_mireille_abeille = $this + ->fixture('Class_Exemplaire', + ['id' => 123, + 'id_origine' => '89863', + 'zone995' => serialize([['clef' => 'a', 'valeur' => '28'], + ['clef' => '9', 'valeur' => '999']])]); } /** @test */ public function reserverExemplaireWithMultiSitesOptionShouldReturnSuccessIfNoErrors() { $this->mock_web_client - ->expects($this->at(1)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=HoldItem&patron_id=572&bib_id=89863&item_id=999') - ->will($this->returnValue('<HoldTitle> + ->answers('<HoldTitle> <title>Mireille l\'abeille</title> <pickup_location>Bibliothèque Départementale de la Meuse</pickup_location> - </HoldTitle>')); + </HoldTitle>'); $this->assertEquals(array('statut' => true, 'erreur' => ''), $this->service->reserverExemplaire($this->_lafond, $this->_exemplaire_mireille_abeille, '')); @@ -822,12 +834,11 @@ class KohaTestMultiSites extends KohaTestCase{ /** @test */ public function reserverExemplaireShouldReturnErrorIfFail() { $this->mock_web_client - ->expects($this->at(1)) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=HoldItem&patron_id=572&bib_id=89863&item_id=999') - ->will($this->returnValue('<HoldTitle> + ->answers('<HoldTitle> <code>NotHoldable</code> - </HoldTitle>')); + </HoldTitle>'); $this->assertEquals(array('statut' => false, 'erreur' => 'Réservation impossible'), $this->service->reserverExemplaire($this->_lafond, $this->_exemplaire_mireille_abeille, '')); @@ -836,30 +847,28 @@ class KohaTestMultiSites extends KohaTestCase{ -class KohaServiceGetNoticeHarryPotterWithRestrictionTest extends Storm_Test_ModelTestCase { - public function tearDown() { - Storm_Model_Loader::defaultToDb(); - parent::tearDown(); - } +class KohaServiceGetNoticeHarryPotterWithRestrictionTest + extends ModelTestCase { + protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); - Storm_Model_Loader::defaultToVolatile(); + Class_Profil::setCurrentProfil($this->fixture('Class_Profil', ['id' => 1, 'libelle' => 'Actu'])); Class_AdminVar::newInstanceWithId('KOHA_MULTI_SITES', ['valeur' => '' ]); - $this->mock_web_client = $this->getMock('Class_WebService_SimpleWebClient'); + $this->mock_web_client = $this->mock(); + $this->service = Class_WebService_SIGB_Koha::getService(['url_serveur' => 'http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl', 'Interdire_reservation_doc_dispo' => '1']); $this->mock_web_client - ->expects($this->once()) - ->method('open_url') + ->whenCalled('open_url') ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=GetRecords&id=33233') - ->will($this->returnValue(KohaFixtures::xmlGetRecordHarryPotter())); + ->answers(KohaFixtures::xmlGetRecordHarryPotter()); $this->service->setWebClient($this->mock_web_client); $this->potter = $this->service->getNotice('33233');