diff --git a/VERSIONS_HOTLINE/103837 b/VERSIONS_HOTLINE/103837 new file mode 100644 index 0000000000000000000000000000000000000000..019260849dc9f8da88809f8ef6fb354cb40be082 --- /dev/null +++ b/VERSIONS_HOTLINE/103837 @@ -0,0 +1 @@ + - ticket #103837 : Affichage notices : correction de la détection de l'appartenance des exemplaires à un lot \ No newline at end of file diff --git a/library/Class/Exemplaire.php b/library/Class/Exemplaire.php index 76130a924210ba5aa18a301588c188503e5d3192..72c2f23fd9dfaa954284a4c042c5a68880465aca 100644 --- a/library/Class/Exemplaire.php +++ b/library/Class/Exemplaire.php @@ -451,6 +451,7 @@ class Class_Exemplaire extends Storm_Model_Abstract { return null; } + public function toRaw() { $raw = $this->getRawAttributes() ; // LL: pour Opsys nous avons besoin de l'identifiant de l'annexe, d'où sauvegarde pour réutilisation dans ReservationLink @@ -470,6 +471,7 @@ class Class_Exemplaire extends Storm_Model_Abstract { return $this->annexe; } + public function getNbResas() { return $this->getSigbExemplaire()->getNbReservations(); } @@ -490,15 +492,15 @@ class Class_Exemplaire extends Storm_Model_Abstract { public function getBundle() { - if (!$data_profile = $this->getDataProfile()) + if ((!$id_int_bib = $this->getIdIntBib()) + || (!$data_profile = $this->getDataProfile()) + || (!$bundle_id_field = $data_profile->getBundleIdField()) + || (!$id_origine = $this->getSubfield($bundle_id_field))) return null; - $bundle_id_field = $data_profile->getBundleIdField(); - $bundle_id = $this->getSubfield($bundle_id_field); - $bundle_item = Class_Exemplaire::getLoader() - ->findFirstBy(['id_int_bib' => $this->getIdIntBib(), - 'id_origine' => $bundle_id]); + ->findFirstBy(['id_int_bib' => $id_int_bib, + 'id_origine' => $id_origine]); return $bundle_item ? $bundle_item->getNotice() diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerItemsTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerItemsTest.php index 9983079f6bab327073dc297fc5652db561c07dda..fc887f331331a09cfa2803d35751aa42b6149a16 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerItemsTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerItemsTest.php @@ -295,8 +295,7 @@ class NoticeAjaxControllerItemsCustomIconsTest - -class NoticeAjaxControllerItemBelongsToBundleTest +abstract class NoticeAjaxControllerItemBundleTestCase extends NoticeAjaxControllerItemsTestCase { protected function _prepareFixtures() { @@ -304,11 +303,10 @@ class NoticeAjaxControllerItemBelongsToBundleTest $config['exemplaires']['grouper'] = '1'; Class_Profil::getCurrentProfil()->setCfgNotice($config); - $data_profile = Class_IntProfilDonnees::forKoha()->setId(23); $data_profile ->setItemField(Class_IntProfilDonnees::FIELD_ITEM_BUNDLE_ID, - 7) + $this->_bundleIdField()) ->save(); $bundled_item = $this->fixture('Class_Exemplaire', @@ -337,7 +335,6 @@ class NoticeAjaxControllerItemBelongsToBundleTest 'valeur' => '']]) ]); - $bundle_not_exists = $this->fixture('Class_Exemplaire', ['id' => 103, 'id_bib' => 3, @@ -352,7 +349,7 @@ class NoticeAjaxControllerItemBelongsToBundleTest ]); $no_bundle_field = $this->fixture('Class_Exemplaire', - ['id' => 103, + ['id' => 104, 'id_bib' => 3, 'id_int_bib' => 3, 'section' => 14, @@ -363,7 +360,6 @@ class NoticeAjaxControllerItemBelongsToBundleTest 'zone995' => serialize([[]]) ]); - $this->fixture('Class_Notice', ['id' => 34, 'titre_principal' => 'La fausse malle du piège du int_bib', @@ -374,7 +370,6 @@ class NoticeAjaxControllerItemBelongsToBundleTest 'id_origine' => 87346]) ]]); - $this->fixture('Class_Notice', ['id' => 25, 'titre_principal' => 'Se faire la malle', @@ -395,10 +390,56 @@ class NoticeAjaxControllerItemBelongsToBundleTest } + protected function _bundleIdField() { + return null; + } +} + + + +class NoticeAjaxControllerItemBelongsToBundleTest + extends NoticeAjaxControllerItemBundleTestCase { + + protected function _bundleIdField() { + return 7; + } + + /** @test */ public function tdShouldContainsLinkToRecordSeFaireLaMalleId25() { $this->assertXPathContentContains('//td//a[contains(@href, "/recherche/viewnotice/id/25")]', 'Fait partie du lot "Se faire la malle"'); } +} + + + + +/** @see http://forge.afi-sa.fr/issues/103837 */ +class NoticeAjaxControllerItemWithEmptyBundleIdTest + extends NoticeAjaxControllerItemBundleTestCase { + + protected function _bundleIdField() { + return 7; + } + + /** @test */ + public function tdShouldNotContainsLinkToEmptyBundle() { + $this->assertNotXPathContentContains('//td//a', 'Fait partie du lot ""'); + } +} + + + + +/** @see http://forge.afi-sa.fr/issues/103837 */ +class NoticeAjaxControllerItemBelongsToBundleButWithoutBundleFieldIdTest + extends NoticeAjaxControllerItemBundleTestCase { + + /** @test */ + public function tdShouldNotContainsLinkToRecordSeFaireLaMalleId25() { + $this->assertNotXPathContentContains('//td//a[contains(@href, "/recherche/viewnotice/id/25")]', + 'Fait partie du lot "Se faire la malle"'); + } } \ No newline at end of file