Skip to content
Snippets Groups Projects
Commit 0fcf94a2 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch 'hotline_#21086_koha_loans' into 'stable'

Hotline #21086 koha loans

See merge request !694
parents eb3cfbc9 5cdda45b
4 merge requests!780Master,!722Master,!721Hotline master,!720Stable
- ticket #21086: Correction sur la réservation des exemplaires Koha qui étaient déjà réservés. On peut réserver un exemplaire déjà réservé.
\ No newline at end of file
......@@ -16,12 +16,12 @@
*
* 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 TypeDocLoader extends Storm_Model_Loader {
protected $_all_instances;
public function __construct() {
$this->findAll();
}
......@@ -37,7 +37,7 @@ class TypeDocLoader extends Storm_Model_Loader {
if (!empty($attributes))
$instance->updateAttributes($attributes);
return $instance;
}
......@@ -72,10 +72,13 @@ class TypeDocLoader extends Storm_Model_Loader {
public function findAll($select = NULL) {
if (isset($this->_all_instances))
return $this->_all_instances;
$types_docs = Class_CosmoVar::getLoader()->find('types_docs');
$lines = explode("\r\n", $types_docs->getListe());
$instances = array();
$lines = [];
if($types_docs = Class_CosmoVar::find('types_docs'))
$lines = explode("\r\n", $types_docs->getListe());
$instances = [];
foreach ($lines as $line) {
$instance = $this->unserialize($line);
......@@ -87,7 +90,7 @@ class TypeDocLoader extends Storm_Model_Loader {
if (!isset($instances[$id]))
$instances[$id] = Class_TypeDoc::newWithLabel($label)->setId($id);
}
return $this->_all_instances = $instances;
}
......@@ -128,7 +131,7 @@ class TypeDocLoader extends Storm_Model_Loader {
return $this->_saveSerialized($serialized);
}
public function delete($model) {
$serialized = array();
......@@ -176,7 +179,7 @@ class Class_TypeDoc extends Storm_Model_Abstract {
const CODE_FACETTE = 'T';
protected $_loader_class = 'TypeDocLoader';
protected $_belongs_to = ['codif_type_doc' =>
protected $_belongs_to = ['codif_type_doc' =>
[ 'model' => 'Class_CodifTypeDoc',
'referenced_in' => 'id' ]];
const LIVRE = 1;
......@@ -200,7 +203,7 @@ class Class_TypeDoc extends Storm_Model_Abstract {
const NUMERIQUEPREMIUM = 110;
const CYBERLIBRIS = 111;
public static function getDefaultTypeDocs() {
return [self::LIVRE => 'Livres',
self::PERIODIQUE => 'Périodiques',
......@@ -228,7 +231,7 @@ class Class_TypeDoc extends Storm_Model_Abstract {
/**
* @param String label
* @return Class_Type_Doc
*/
*/
public static function newWithLabel($label) {
$instance = new self();
return $instance->setLabel($label);
......@@ -279,7 +282,7 @@ class Class_TypeDoc extends Storm_Model_Abstract {
}
public function isRessourceNumerique() {
return ($this->getId() >= Class_TypeDoc::LIVRE_NUM)
return ($this->getId() >= Class_TypeDoc::LIVRE_NUM)
&& (!in_array($this->getId(),[static::ARTICLE, static::RSS, static::SITE]));
}
......@@ -295,7 +298,7 @@ class Class_TypeDoc extends Storm_Model_Abstract {
return $codif;
}
public function getLibelleFamille() {
return $this->getCodifTypeDoc()->getLibelle();
}
......
......@@ -16,7 +16,7 @@
*
* 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_Koha_GetRecordsResponseReader {
use Class_WebService_SIGB_Koha_TraitFormat;
......@@ -44,6 +44,7 @@ class Class_WebService_SIGB_Koha_GetRecordsResponseReader {
return new self();
}
public function setInterdireResaDocDispo($dispo) {
$this->interdire_resa_doc_dispo = $dispo;
return $this;
......@@ -56,6 +57,7 @@ class Class_WebService_SIGB_Koha_GetRecordsResponseReader {
return $this;
}
public function getNoticeFromXML($xml) {
$this->_xml_parser = Class_WebService_XMLParser::newInstance();
$this->_xml_parser
......@@ -100,9 +102,8 @@ class Class_WebService_SIGB_Koha_GetRecordsResponseReader {
$date = $this->formatDate($data);
$this->_current_exemplaire->setDateRetour($date);
if (('' != $date) || ($this->allowAvailableDocumentReservation())) {
if (('' != $date) || ($this->allowAvailableDocumentReservation()))
$this->_current_exemplaire->setReservable(true);
}
}
......@@ -142,10 +143,9 @@ class Class_WebService_SIGB_Koha_GetRecordsResponseReader {
if (!$this->_xml_parser->inParents('item'))
return;
if (array_key_exists($data, $this->_not_for_loan_status) and !$this->_current_exemplaire->isPiege()) {
$this->_current_exemplaire->setDisponibilite($this->_not_for_loan_status[$data]);
if (!in_array($data, array('0', '4')))
if (!in_array($data, array('0', '4')))
$this->_current_exemplaire->notForLoan();
}
}
......@@ -157,11 +157,12 @@ class Class_WebService_SIGB_Koha_GetRecordsResponseReader {
return;
}
if ($this->_xml_parser->inParents('item')) {
$this->_current_exemplaire->setId($data);
if (in_array($data, $this->_reservations))
if (in_array($data, $this->_reservations)) {
$this->_current_exemplaire->setDisponibiliteDejaReserve();
$this->_current_exemplaire->setReservable(true);
}
}
}
}
......
......@@ -129,6 +129,7 @@ abstract class KohaServiceGetNoticeHarryPotterTestCase extends KohaTestCase {
class KohaServiceGetNoticeHarryPotterTest extends KohaServiceGetNoticeHarryPotterTestCase {
public function setUp() {
parent::setUp();
......@@ -139,6 +140,7 @@ class KohaServiceGetNoticeHarryPotterTest extends KohaServiceGetNoticeHarryPotte
/** @test */
public function shouldAnswerOneNotice() {
$this->assertInstanceOf('Class_WebService_SIGB_Notice', $this->potter);
$this->assertTrue($this->potter->exemplaireAt(8)->isReservable());
}
......@@ -346,11 +348,11 @@ class KohaGetEmprunteurLaureAfondTest extends KohaTestCase {
->will($this->returnValue(KohaFixtures::xmlGetPatronInfoLaure()));
$this->laurent = $this->service->getEmprunteur(
Class_Users::getLoader()->newInstance()
->setLogin('lafond')
->setPassword('afi')
->setIdabon('012345')
);
Class_Users::getLoader()->newInstance()
->setLogin('lafond')
->setPassword('afi')
->setIdabon('012345')
);
}
......@@ -494,10 +496,10 @@ class KohaGetEmprunteurJeanAndreWithIdSIGBTest extends KohaTestCase {
->will($this->returnValue(KohaFixtures::xmlGetPatronInfoJeanAndre()));
$this->jean = $this->service->getEmprunteur(
$this->fixture('Class_Users', ['id' => 43,
'login' => 'JEAN',
'password' => 'zork',
'id_sigb' => '01234']));
$this->fixture('Class_Users', ['id' => 43,
'login' => 'JEAN',
'password' => 'zork',
'id_sigb' => '01234']));
$this->fixture('Class_CodifAnnexe', ['id' => 33,
'libelle' => 'Testing branch',
......@@ -595,9 +597,9 @@ class KohaOperationsTest extends KohaTestCase {
parent::setUp();
$this->_lafond = Class_Users::getLoader()->newInstance()
->setLogin('lafond')
->setPassword('afi')
->setIdabon('012345');
->setLogin('lafond')
->setPassword('afi')
->setIdabon('012345');
$this->mock_web_client
->expects($this->at(0))
......@@ -782,9 +784,9 @@ class KohaTestMultiSites extends KohaTestCase{
parent::setUp();
Class_AdminVar::newInstanceWithId('KOHA_MULTI_SITES', ['valeur' => '1']);
$this->_lafond = Class_Users::getLoader()->newInstance()
->setLogin('lafond')
->setPassword('afi')
->setIdabon('012345');
->setLogin('lafond')
->setPassword('afi')
->setIdabon('012345');
$this->mock_web_client
->expects($this->at(0))
......@@ -831,4 +833,53 @@ class KohaTestMultiSites extends KohaTestCase{
$this->service->reserverExemplaire($this->_lafond, $this->_exemplaire_mireille_abeille, ''));
}
}
?>
\ No newline at end of file
class KohaServiceGetNoticeHarryPotterWithRestrictionTest extends Storm_Test_ModelTestCase {
public function tearDown() {
Storm_Model_Loader::defaultToDb();
parent::tearDown();
}
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->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')
->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/ilsdi.pl?service=GetRecords&id=33233')
->will($this->returnValue(KohaFixtures::xmlGetRecordHarryPotter()));
$this->service->setWebClient($this->mock_web_client);
$this->potter = $this->service->getNotice('33233');
}
/** @test */
public function secondItemShouldBeReservable() {
$this->assertTrue($this->potter->exemplaireAt(1)->isReservable());
}
/** @test */
public function lastItemShouldBeReservable() {
$this->assertTrue($this->potter->exemplaireAt(8)->isReservable());
}
/** @test */
public function lastItemDisponibiliteShouldBeReserve() {
$this->assertEquals('Réservé', $this->potter->exemplaireAt(8)->getDisponibilite());
}
}
......@@ -16,7 +16,7 @@
*
* 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 ToutApprendreTest extends Storm_Test_ModelTestCase{
......@@ -32,7 +32,7 @@ class ToutApprendreTest extends Storm_Test_ModelTestCase{
->with('http://biblio.toutapprendre.com/cours/catalogue.aspx?pk=2100')
->answers($catalogue_xml)
->beStrict();
Class_WebService_BibNumerique_ToutApprendre::setDefaultHttpClient($http_client);
Class_WebService_BibNumerique_Vignette::setInstance(Storm_Test_ObjectWrapper::mock()
->whenCalled('updateAlbum')
......@@ -44,7 +44,7 @@ class ToutApprendreTest extends Storm_Test_ModelTestCase{
'annexes' => '10;12',
'sections' => '18;19']);
self::fixture('Class_TypeDoc', ['id'=>Class_TypeDoc::TOUTAPPRENDRE,
self::fixture('Class_TypeDoc', ['id'=>Class_TypeDoc::TOUTAPPRENDRE,
'codif_type_doc' => $codif_type_doc,
'label'=> 'Tout apprendre'
]);
......@@ -71,15 +71,22 @@ class ToutApprendreTest extends Storm_Test_ModelTestCase{
public function setUp() {
parent::setUp();
Storm_Model_Loader::defaultToVolatile();
$this->_toutApprendre = self::$toutApprendre;
$this->_first_album = $this->_toutApprendre->getAlbums()[0];
}
public function tearDown() {
Storm_Model_Loader::defaultToDb();
parent::tearDown();
}
/**
/**
* [[file:~/www/afi-opac/tests/fixtures/toutApprendre_catalogue.xml::<titre>Safari%202</titre][formation Safari2]]
* @test
* @test
*/
public function firstAlbumTitreShouldBeLibreOffice() {
$this->assertEquals('LibreOffice Database - Module 1', $this->_first_album->getTitre());
......@@ -123,7 +130,7 @@ class ToutApprendreTest extends Storm_Test_ModelTestCase{
public function firstAlbumLibreOfficeDesciptionShouldBeSet() {
$this->assertEquals("Accéder aux données de LibreOffice Database et les imprimer",$this->_first_album->getDescription());
}
/** @test */
public function posterToutApprendreShouldBeURIJacketURL(){
......
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