diff --git a/VERSIONS b/VERSIONS index bfbb4cc263c1d001582c2f91c4a250a2436fc896..fa9375f21c88618bee3acd83af812182148e8576 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,3 +1,9 @@ +17/12/2015 - v7.3.38 + + - ticket #32959 : Prise en compte du champ activité dans l'affichage d'exemplaires sans webservices + + + 14/12/2015 - v7.3.37 - ticket #33149 : Correction SSO CAS LeKiosk diff --git a/library/Class/CommSigb.php b/library/Class/CommSigb.php index 06a47c48017806c582a153d2cb0a12de2d303e45..9df4c3ac1c6ce31476f817861313d983878f4210 100644 --- a/library/Class/CommSigb.php +++ b/library/Class/CommSigb.php @@ -42,17 +42,23 @@ class Class_CommSigb { if ($dispo = $this->getDispoExemplaire($exemplaire)) $exemplaires []= array_merge($exemplaire->toRaw(), $dispo); } + return $exemplaires; } - public function getDispoExemplaire($bibitem) { - $exemplaire = ["dispo" => ($bibitem->getIsAvailable() + public function getDispoExemplaire($item) { + $exemplaire = ['dispo' => ($item->getIsAvailable() ? $this->_('Disponible') : $this->_('Non disponible')), - "reservable" => false]; + 'reservable' => false]; + + if ($item->isDisconnected() && $item->hasActivite()) { + $exemplaire['dispo'] = $item->getActivite(); + return $exemplaire; + } - if (!$sigb_exemplaire = $bibitem->getSigbExemplaire()) + if (!$sigb_exemplaire = $item->getSigbExemplaire()) return $exemplaire; if ($sigb_exemplaire->isPilonne() || !$sigb_exemplaire->isVisibleOPAC()) @@ -61,25 +67,25 @@ class Class_CommSigb { if (!$sigb_exemplaire->isValid()) return $exemplaire; - $exemplaire["dispo"]=$sigb_exemplaire->getDisponibilite(); - $exemplaire["date_retour"]=$sigb_exemplaire->getDateRetour(); - $exemplaire["reservable"]=$sigb_exemplaire->isReservable(); - $exemplaire["id_exemplaire"]=$sigb_exemplaire->getId(); - $exemplaire["nb_resas"]=$sigb_exemplaire->getNbReservations(); - $exemplaire["edition"]=$sigb_exemplaire->getEdition(); - $exemplaire["is_available"]=$sigb_exemplaire->isDisponible(); + $exemplaire['dispo'] = $sigb_exemplaire->getDisponibilite(); + $exemplaire['date_retour'] = $sigb_exemplaire->getDateRetour(); + $exemplaire['reservable'] = $sigb_exemplaire->isReservable(); + $exemplaire['id_exemplaire'] = $sigb_exemplaire->getId(); + $exemplaire['nb_resas'] = $sigb_exemplaire->getNbReservations(); + $exemplaire['edition'] = $sigb_exemplaire->getEdition(); + $exemplaire['is_available'] = $sigb_exemplaire->isDisponible(); if ($cote = $sigb_exemplaire->getCote()) - $exemplaire["cote"] = $cote; + $exemplaire['cote'] = $cote; if ($emplacement = $sigb_exemplaire->getEmplacement()) - $exemplaire["emplacement"] = $emplacement; + $exemplaire['emplacement'] = $emplacement; if (!$code_annexe = $sigb_exemplaire->getCodeAnnexe()) return $exemplaire; if ($annexe = Class_CodifAnnexe::findFirstBy(['code' => $code_annexe])) - $exemplaire["id_bib"] = $annexe->getIdBib(); + $exemplaire['id_bib'] = $annexe->getIdBib(); return $exemplaire; } diff --git a/library/Class/Exemplaire.php b/library/Class/Exemplaire.php index 4e861710b87f2ca8bcccbab6fa83ad5d26746fa6..c1810159a5dd03ea58505d118e167a29c9b2f2bd 100644 --- a/library/Class/Exemplaire.php +++ b/library/Class/Exemplaire.php @@ -46,6 +46,7 @@ class Class_Exemplaire extends Storm_Model_Abstract { 'genre' => null, 'url' => null, 'emplacement' => '', + 'activite' => null, 'date_nouveaute' => '']; protected $_sigb_exemplaire; @@ -133,6 +134,12 @@ class Class_Exemplaire extends Storm_Model_Abstract { } + public function isDisconnected() { + return (!$this->hasIntBib()) + || $this->getIntBib()->isDisconnected(); + } + + public function updateAvailabilityFromSIGB() { if (!$sigb_exemplaire = $this->getSigbExemplaire()) return $this; diff --git a/library/Class/IntBib.php b/library/Class/IntBib.php index 5ab61c81eebd4ac7754f731f283319c79c62a3c5..f5b8138b07d5cc1779e4424ba37b262afe7aaf04 100644 --- a/library/Class/IntBib.php +++ b/library/Class/IntBib.php @@ -28,6 +28,8 @@ class Class_IntBib extends Storm_Model_Abstract { const PLANIF_NOT_RECURRENT = 'i'; const CODE_FACETTE = 'B'; + + const COM_NONE = 0; const COM_PERGAME = 1; const COM_OPSYS = 2; const COM_VSMART = 4; @@ -40,6 +42,8 @@ class Class_IntBib extends Storm_Model_Abstract { const COM_DYNIX = 11; const COM_CDSCRIPT = 12; + const SIGB_NONE = 0; + protected static $COM_CLASSES = [self::COM_PERGAME => 'Class_WebService_SIGB_Pergame', self::COM_OPSYS => 'Class_WebService_SIGB_Opsys', self::COM_VSMART => 'Class_WebService_SIGB_VSmart', @@ -165,6 +169,12 @@ class Class_IntBib extends Storm_Model_Abstract { public function isPergame() { return in_array($this->getSigb(), [1, 13]); } + + + public function isDisconnected() { + return static::COM_NONE == $this->getCommSigb() + && static::SIGB_NONE == $this->getSigb(); + } } ?> \ No newline at end of file diff --git a/library/Class/WebService/SIGB/Pergame.php b/library/Class/WebService/SIGB/Pergame.php index 94987d66be0c6ab7daa0efd129a5eb29d71ee6ab..9e55d14eeaeee87692d0908bb7276dc86ef8bc99 100644 --- a/library/Class/WebService/SIGB/Pergame.php +++ b/library/Class/WebService/SIGB/Pergame.php @@ -16,33 +16,35 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_WebService_SIGB_Pergame { - protected static $services; + protected static $_services, $_default_service; public static function getService($params){ - if (!isset(self::$service)) - self::$services = array(); + if (static::$_default_service) + return static::$_default_service; + + if (!isset(static::$_services)) + static::$_services = []; $id_bib = $params['id_bib']; - if (!array_key_exists($id_bib, self::$services)) - self::$services[$id_bib] = Class_WebService_SIGB_Pergame_Service::getService($id_bib); + if (!array_key_exists($id_bib, static::$_services)) + static::$_services[$id_bib] = Class_WebService_SIGB_Pergame_Service::getService($id_bib); - return self::$services[$id_bib]; + return static::$_services[$id_bib]; } public static function setService($service) { - self::$service = $service; + static::$_default_service = $service; } public static function reset() { - self::$service = null; + static::$_default_service = static::$_services = null; } - } ?> \ No newline at end of file diff --git a/library/startup.php b/library/startup.php index 8537207af9ea2b1284acdc6edf020b17d72d43d5..27f545e741c71d866a4505bca178827279a09971 100644 --- a/library/startup.php +++ b/library/startup.php @@ -64,7 +64,7 @@ function defineConstant($name, $value) { function setupConstants() { defineConstant('BOKEH_MAJOR_VERSION','7.3'); - defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.37'); + defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.38'); defineConstant('BOKEH_REMOTE_FILES', 'http://git.afi-sa.fr/afi/opacce/'); diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerPergameTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerPergameTest.php index 376182dcffe8bbb6bde884b482461098ada47a4e..43da127f6cce6dcb2f4497ea21de9ac7e19bbaf7 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerPergameTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerPergameTest.php @@ -18,11 +18,13 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -require_once 'AbstractControllerTestCase.php'; - /** @see http://forge.afi-sa.fr/issues/21462 */ -abstract class NoticeAjaxControllerPergameItemTestCase extends AbstractControllerTestCase { +abstract class NoticeAjaxControllerPergameItemTestCase + extends AbstractControllerTestCase { + + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); @@ -33,33 +35,40 @@ abstract class NoticeAjaxControllerPergameItemTestCase extends AbstractControlle 'comm_sigb' => Class_IntBib::COM_PERGAME, 'comm_params' => 'a:3:{s:26:"Autoriser_docs_disponibles";s:0:"";s:13:"Max_par_carte";s:1:"4";s:16:"Max_par_document";s:3:"100";}']); - $this->fixture('Class_Notice', ['id' => 23, - 'cle_oeuvre' => 'DDD']); - - $this->fixture('Class_Exemplaire', ['id' => 732494, - 'id_notice' => 23, - 'id_bib' => 1, - 'code_barres' => '0213689147', - 'cote' => 'EA WAD', - 'genre' => 8, - 'documentaire' => 0, - 'section' => 3, - 'activite' => 'En rayon', - 'emplacement' => 0, - 'annexe' => 1, - 'date_nouveaute' => '0000-00-00', - 'id_origine' => '00013313', - 'id_int_bib' => 1, - 'is_available' => 1]); - - $this->fixture('Class_Pret', ['id' => 98216, - 'id_site' => 1, - 'pergame' => 291392, - 'id_notice_origine' => '13313', - 'en_cours' => 1, - 'date_pret' => '2015-02-17', - 'date_retour' => '2015-03-31', - 'code_barres' => '0213689147']); + $this->fixture('Class_Notice', ['id' => 23, 'cle_oeuvre' => 'DDD']); + + $this->fixture('Class_Exemplaire', + ['id' => 732494, + 'id_notice' => 23, + 'id_bib' => 1, + 'code_barres' => '0213689147', + 'cote' => 'EA WAD', + 'genre' => 8, + 'documentaire' => 0, + 'section' => 3, + 'activite' => 'En rayon', + 'emplacement' => 0, + 'annexe' => 1, + 'date_nouveaute' => '0000-00-00', + 'id_origine' => '00013313', + 'id_int_bib' => 1, + 'is_available' => 1]); + + $this->fixture('Class_Pret', + ['id' => 98216, + 'id_site' => 1, + 'pergame' => 291392, + 'id_notice_origine' => '13313', + 'en_cours' => 1, + 'date_pret' => '2015-02-17', + 'date_retour' => '2015-03-31', + 'code_barres' => '0213689147']); + } + + + public function tearDown() { + Class_WebService_SIGB_Pergame::reset(); + parent::tearDown(); } } @@ -67,9 +76,11 @@ abstract class NoticeAjaxControllerPergameItemTestCase extends AbstractControlle class NoticeAjaxControllerPergameItemNoDefaultLabelTest extends NoticeAjaxControllerPergameItemTestCase { + public function setUp() { parent::setUp(); - $cfg = Class_Profil::getCurrentProfil()->getCfgNoticeAsArray(); + + $cfg = Class_Profil::getCurrentProfil()->getCfgNoticeAsArray(); $cfg['exemplaires']['grouper'] = 1; unset($cfg['exemplaires']['en_pret']); Class_Profil::getCurrentProfil()->setCfgNotice($cfg); @@ -93,6 +104,7 @@ class NoticeAjaxControllerPergameItemLabelConfiguredTest extends NoticeAjaxControllerPergameItemTestCase { public function setUp() { parent::setUp(); + $cfg = Class_Profil::getCurrentProfil()->getCfgNoticeAsArray(); $cfg['exemplaires']['grouper'] = 1; $cfg['exemplaires']['en_pret'] = 'En pret'; diff --git a/tests/library/Class/CommSigbTest.php b/tests/library/Class/CommSigbTest.php index b6c2eb74746e33f694d300af5e78c597acbe0a21..0555eb75c3423ff934594a5e4bf42c56960148af 100644 --- a/tests/library/Class/CommSigbTest.php +++ b/tests/library/Class/CommSigbTest.php @@ -19,7 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -abstract class CommSigbTestCase extends Storm_Test_ModelTestCase { +abstract class CommSigbTestCase extends ModelTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); @@ -38,22 +40,23 @@ abstract class CommSigbTestCase extends Storm_Test_ModelTestCase { ZendAfi_Auth::getInstance()->getStorage()->write($florence); $this->florence = $florence; - $this->userModel = $this->fixture('Class_Users', ['id' => 1, - 'login' => 'florence', - 'password' => 'secret', - 'id_site' => 5, - 'idabon' => '0123456789']); + $this->userModel = $this->fixture('Class_Users', + ['id' => 1, + 'login' => 'florence', + 'password' => 'secret', + 'id_site' => 5, + 'idabon' => '0123456789']); - $this->zend_cache = Storm_Test_ObjectWrapper::mock(); + $this->zend_cache = $this->mock(); $this->zend_cache ->whenCalled('test')->answers(false) ->whenCalled('remove')->answers(true) ->whenCalled('save')->answers(true); + Storm_Cache::setDefaultZendCache($this->zend_cache); } - /** @test */ public function getDispoExemplairesShouldReturnAnArrayWithPotterInfos() { $potter = new Class_WebService_SIGB_Exemplaire('123'); @@ -94,143 +97,143 @@ abstract class CommSigbTestCase extends Storm_Test_ModelTestCase { $this->assertFalse($potter_invisible->isVisibleOpac()); - $map = array(array('123', 'ABC', $potter), - array('456', 'LOR', $lord_of_rings), - array('789', 'ALM', $alice_merveilles), - array('666', 'PTI', $potter_invalide), - array('999', 'PTP', $potter_pilonne), - array('0001', 'PTIO', $potter_invisible)); + $map = [['123', 'ABC', $potter], + ['456', 'LOR', $lord_of_rings], + ['789', 'ALM', $alice_merveilles], + ['666', 'PTI', $potter_invalide], + ['999', 'PTP', $potter_pilonne], + ['0001', 'PTIO', $potter_invisible]]; $this->mock_service ->expects($this->any()) ->method('getExemplaire') ->will($this->returnValueMap($map)); - - $this->assertEquals([['id_origine' => '123', - 'code_barres' => 'ABC', - 'id_int_bib' => 5, - 'dispo' => 'En pret', - 'reservable' => true, - 'date_retour' => '17/02/1978', - 'id_exemplaire' => '123', - 'cote' => 'POT', - 'emplacement' => '1', - 'nb_resas' => 0, - 'edition' => '', - 'annexe' => null, - 'code_annexe' => null, - 'is_available' => false, - 'section' => '', - 'genre' => null, - 'date_nouveaute' => '', - 'id' => 10, - 'url' => null - ], - - ['id_origine' => '789', - 'code_barres' => 'ALM', - 'id_int_bib' => 5, - 'annexe' => 5, - 'code_annexe' => 5, - 'dispo' => 'Sur demande calligraphiee', - 'reservable' => false, - 'date_retour' => '', - 'id_exemplaire' => '789', - 'cote' => 'ALI MER', - 'emplacement' => '2', - 'nb_resas' => 0, - 'edition' => '', - 'is_available' => true, - 'section' => '', - 'genre' => null, - 'date_nouveaute' => '', - 'id' => 12, - 'url' => null - ], - - ['id_origine' => '666', - 'code_barres' => 'PTI', - 'id_int_bib' => 5, - 'dispo' => 'Disponible', - 'reservable' => false, - 'annexe' => null, - 'code_annexe' => null, - 'is_available' => true, - 'section' => '', - 'genre' => null, - 'emplacement' => '', - 'date_nouveaute' => '', - 'id' => 13, - 'url' => null], - - ['id'=> 16, - 'id_origine' => '999', - 'code_barres' => 'UNKNOWN', - 'id_int_bib' => 5, - 'annexe' => null, - 'code_annexe' => null, - 'is_available' => false, - 'section' => '', - 'genre' => null, - 'emplacement' => '', - 'date_nouveaute' => '', - 'dispo' => 'Non disponible', - 'reservable' => false, - 'url' => null] - ], - - $this->comm_sigb->getDispoExemplaires( - [ - $this->fixture('Class_Exemplaire', - ['id'=> 10, - 'id_origine' => '123', - 'code_barres' => 'ABC', - 'id_int_bib' => 5, - 'cote' => 'POT', - 'emplacement' => '1']), - - $this->fixture('Class_Exemplaire', - ['id'=> 11, - 'id_origine' => '456', - 'code_barres' => 'LOR', - 'id_int_bib' => 5]), - - $this->fixture('Class_Exemplaire', - ['id'=> 12, - 'id_origine' => '789', - 'code_barres' => 'ALM', - 'id_int_bib' => 5, - 'annexe' => 5, - 'cote' => 'A', - 'emplacement' => '9', - 'is_available' => false]), - - $this->fixture('Class_Exemplaire', - ['id'=> 13, - 'id_origine' => '666', - 'code_barres' => 'PTI', - 'id_int_bib' => 5, - 'is_available'=> true]), - - $this->fixture('Class_Exemplaire', - ['id'=> 14, - 'id_origine' => '999', - 'code_barres' => 'PTP', - 'id_int_bib' => 5]), - - $this->fixture('Class_Exemplaire', - ['id'=> 15, - 'id_origine' => '0001', - 'code_barres' => 'PTIO', - 'id_int_bib' => 5]), - - $this->fixture('Class_Exemplaire', - ['id'=> 16, - 'id_origine' => '999', - 'code_barres' => 'UNKNOWN', - 'id_int_bib' => 5]) - ])); + $expected = [['id_origine' => '123', + 'code_barres' => 'ABC', + 'id_int_bib' => 5, + 'dispo' => 'En pret', + 'reservable' => true, + 'date_retour' => '17/02/1978', + 'id_exemplaire' => '123', + 'cote' => 'POT', + 'emplacement' => '1', + 'nb_resas' => 0, + 'edition' => '', + 'annexe' => null, + 'code_annexe' => null, + 'is_available' => false, + 'section' => '', + 'genre' => null, + 'date_nouveaute' => '', + 'id' => 10, + 'url' => null, + 'activite' => null], + + ['id_origine' => '789', + 'code_barres' => 'ALM', + 'id_int_bib' => 5, + 'annexe' => 5, + 'code_annexe' => 5, + 'dispo' => 'Sur demande calligraphiee', + 'reservable' => false, + 'date_retour' => '', + 'id_exemplaire' => '789', + 'cote' => 'ALI MER', + 'emplacement' => '2', + 'nb_resas' => 0, + 'edition' => '', + 'is_available' => true, + 'section' => '', + 'genre' => null, + 'date_nouveaute' => '', + 'id' => 12, + 'url' => null, + 'activite' => null], + + ['id_origine' => '666', + 'code_barres' => 'PTI', + 'id_int_bib' => 5, + 'dispo' => 'Disponible', + 'reservable' => false, + 'annexe' => null, + 'code_annexe' => null, + 'is_available' => true, + 'section' => '', + 'genre' => null, + 'emplacement' => '', + 'date_nouveaute' => '', + 'id' => 13, + 'url' => null, + 'activite' => null], + + ['id'=> 16, + 'id_origine' => '999', + 'code_barres' => 'UNKNOWN', + 'id_int_bib' => 5, + 'annexe' => null, + 'code_annexe' => null, + 'is_available' => false, + 'section' => '', + 'genre' => null, + 'emplacement' => '', + 'date_nouveaute' => '', + 'dispo' => 'Non disponible', + 'reservable' => false, + 'url' => null, + 'activite' => null]]; + + $actual = $this->comm_sigb + ->getDispoExemplaires([$this->fixture('Class_Exemplaire', + ['id'=> 10, + 'id_origine' => '123', + 'code_barres' => 'ABC', + 'id_int_bib' => 5, + 'cote' => 'POT', + 'emplacement' => '1']), + + $this->fixture('Class_Exemplaire', + ['id'=> 11, + 'id_origine' => '456', + 'code_barres' => 'LOR', + 'id_int_bib' => 5]), + + $this->fixture('Class_Exemplaire', + ['id'=> 12, + 'id_origine' => '789', + 'code_barres' => 'ALM', + 'id_int_bib' => 5, + 'annexe' => 5, + 'cote' => 'A', + 'emplacement' => '9', + 'is_available' => false]), + + $this->fixture('Class_Exemplaire', + ['id'=> 13, + 'id_origine' => '666', + 'code_barres' => 'PTI', + 'id_int_bib' => 5, + 'is_available'=> true]), + + $this->fixture('Class_Exemplaire', + ['id'=> 14, + 'id_origine' => '999', + 'code_barres' => 'PTP', + 'id_int_bib' => 5]), + + $this->fixture('Class_Exemplaire', + ['id'=> 15, + 'id_origine' => '0001', + 'code_barres' => 'PTIO', + 'id_int_bib' => 5]), + + $this->fixture('Class_Exemplaire', + ['id'=> 16, + 'id_origine' => '999', + 'code_barres' => 'UNKNOWN', + 'id_int_bib' => 5])]); + + $this->assertEquals($expected, $actual); } @@ -253,13 +256,13 @@ abstract class CommSigbTestCase extends Storm_Test_ModelTestCase { ->expects($this->once()) ->method('reserverExemplaire') ->with($this->userModel, - Class_Exemplaire::getLoader()->newInstanceWithId(123), + $this->fixture('Class_Exemplaire', ['id' => '123', 'id_notice' => 7888]), 'ABC') - ->will($this->returnValue(array('statut' => 1, - 'erreur' => ''))); + ->will($this->returnValue(['statut' => 1, + 'erreur' => ''])); - $this->assertEquals(array('statut' => 1, - 'erreur' => ''), + $this->assertEquals(['statut' => 1, + 'erreur' => ''], $this->comm_sigb->reserverExemplaire(5, '123', 'ABC')); return $this->zend_cache; @@ -591,7 +594,9 @@ class CommSigbDynixTest extends CommSigbTestCase { -class CommSigbWithNotAbonneTest extends Storm_Test_ModelTestCase { +class CommSigbWithNotAbonneTest extends ModelTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); @@ -600,13 +605,17 @@ class CommSigbWithNotAbonneTest extends Storm_Test_ModelTestCase { $this->user->ID_USER = 66; $this->user->IDABON = 6; ZendAfi_Auth::getInstance()->getStorage()->write($this->user); + $this->comm_sigb = new Class_CommSigb(); - Class_Users::getLoader() - ->newInstanceWithId(66) - ->setIdSite(0) - ->setIdabon(3); + $this->fixture('Class_Users', + ['id' => 66, + 'login' => 'test', + 'password' => 'test', + 'id_site' => 0, + 'idabon' => 3]); } + /** @test */ public function prolongerPretShouldReturnError() { $this->assertEquals(['erreur' => 'Communication SIGB indisponible'], @@ -636,33 +645,67 @@ class CommSigbWithNotAbonneTest extends Storm_Test_ModelTestCase { /** @test */ public function getDispoExemplairesShouldReturnNonReservable() { - $this->assertEquals([ - [ - 'id' => 2, - 'id_int_bib' => 0, - 'id_origine' => 0, - 'code_barres' => 0, - 'dispo' => 'Non disponible', - 'reservable' => false, - 'annexe' => null, - 'code_annexe' => null, - 'is_available' => false, - 'section' => '', - 'genre' => null, - 'emplacement' => '', - 'date_nouveaute' => '', - 'url' => null - ] - ], - $this->comm_sigb->getDispoExemplaires([ - $this->fixture('Class_Exemplaire', - ['id'=> 19, - 'id' => 2, - 'id_origine' => 0, - 'code_barres' => 0, - 'id_int_bib' => 0])])); + $expected = [ ['id' => 2, + 'id_int_bib' => 0, + 'id_origine' => 0, + 'code_barres' => 0, + 'dispo' => 'Non disponible', + 'reservable' => false, + 'annexe' => null, + 'code_annexe' => null, + 'is_available' => false, + 'section' => '', + 'genre' => null, + 'emplacement' => '', + 'date_nouveaute' => '', + 'url' => null, + 'activite' => null] ]; + + $actual = $this->comm_sigb + ->getDispoExemplaires([$this->fixture('Class_Exemplaire', + ['id'=> 19, + 'id' => 2, + 'id_origine' => 0, + 'code_barres' => 0, + 'id_int_bib' => 0])]); + + $this->assertEquals($expected, $actual); } } -?> + +/** @see http://forge.afi-sa.fr/issues/32959 */ +class CommSigbItemAvailabilityWithoutSigbTest extends ModelTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_IntBib', + ['id' => 5, + 'comm_params' => [], + 'comm_sigb' => Class_IntBib::COM_NONE, + 'sigb' => Class_IntBib::SIGB_NONE]); + + $this->fixture('Class_Notice', + ['id' => 78907, + 'exemplaires' => [$this->fixture('Class_Exemplaire', + ['id' => 42, + 'id_notice' => 78907, + 'id_origine' => 4343, + 'id_int_bib' => 5, + 'activite' => 'Never mind', + 'code_barres' => '889389'])]]); + + $this->comm_sigb = new Class_CommSigb(); + } + + + /** @test */ + public function itemAvailabilityShouldBeReadFromDatabase() { + $actual = $this->comm_sigb->getDispoExemplaires([Class_Exemplaire::find(42)]); + + $this->assertEquals('Never mind', $actual[0]['dispo']); + } +} \ No newline at end of file