diff --git a/FEATURES/156028 b/FEATURES/156028 new file mode 100644 index 0000000000000000000000000000000000000000..fcdbeeb3d1025e18b874b0a45e27547ee4479887 --- /dev/null +++ b/FEATURES/156028 @@ -0,0 +1,10 @@ + '156028' => + ['Label' => $this->_('Permettre d\'avoir un permalien avec des identifiants propres au SIGB'), + 'Desc' => $this->_('Dans le cas d\'un SIGB qui n\'a pas de règles de dédoublonage, afficher un permalien avec des identifiants provenant du SIGB qui sont plus pérenne dans le temps'), + 'Image' => '', + 'Video' => '', + 'Category' => $this->_('Exemplaire'), + 'Right' => function($feature_description, $user) {return true;}, + 'Wiki' => 'https://wiki.bokeh-library-portal.org/index.php?title=Permalien', + 'Test' => '', + 'Date' => '2022-04-26'], \ No newline at end of file diff --git a/VERSIONS_WIP/156028 b/VERSIONS_WIP/156028 new file mode 100644 index 0000000000000000000000000000000000000000..7cccf15e339685d2732965833a45349bb893cb78 --- /dev/null +++ b/VERSIONS_WIP/156028 @@ -0,0 +1 @@ + - fonctionnalité #156028 : Exemplaire : Permettre d'avoir un permalien avec des identifiants propres au SIGB \ No newline at end of file diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index 2e046fee94b45fba54ad13278289f4c8c3c25bdd..a20c92f2b50eb2c95ee42fab1ea58ea148d79f25 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -125,7 +125,8 @@ class RechercheController extends ZendAfi_Controller_Action { $record_request = Class_MoteurRecherche_RecordRequest::newFor($this->_getParam('id_sigb'), $this->_getParam('id_site'), - $this->_getParam('record_type')); + $this->_getParam('record_type'), + $this->_getParam('id_int_bib')); if ($record_id = $record_request->recordId()) return $this->_redirect('/recherche/viewnotice/id/' . $record_id); diff --git a/library/Class/MoteurRecherche/RecordRequest.php b/library/Class/MoteurRecherche/RecordRequest.php index b85110ad87403f4854fcbd8293871fe73a555aaa..fda2c356e2ea82e9d473065cd021f0555e4fe9e0 100644 --- a/library/Class/MoteurRecherche/RecordRequest.php +++ b/library/Class/MoteurRecherche/RecordRequest.php @@ -31,38 +31,47 @@ abstract class Class_MoteurRecherche_RecordRequest { $_success_callback, $_id_site; - public static function newFor($id_sigb, $id_site, $record_type) { - if (!$id_sigb && !$id_site) + public static function newFor(?int $id_sigb, ?string $id_site, ?int $record_type, + ?int $id_int_bib) : self { + if (!$id_sigb && !$id_site && !$id_int_bib) return new Class_MoteurRecherche_NullRecordRequest(); $t = new Class_Translator; if (!$id_sigb) return new Class_MoteurRecherche_MissingParamRecordRequest($t->_('Paramètre id_sigb obligatoire')); - if (!$id_site) + if (!$id_site && !$id_int_bib) return new Class_MoteurRecherche_MissingParamRecordRequest($t->_('Paramètre id_site obligatoire')); + if ($id_site && $id_int_bib) + return new Class_MoteurRecherche_MissingParamRecordRequest($t->_('Paramètre id_site et id_int_bib ne peuvent pas être renseignés en même temps')); + if (!$record_type) $record_type = Class_Notice::TYPE_BIBLIOGRAPHIC; - if (!$item = static::_findItem($id_sigb, $id_site, $record_type)) + if (!$item = static::_findItem($id_sigb, $id_site, $record_type, $id_int_bib)) return new Class_MoteurRecherche_UnknownRecordRequest(); return new Class_MoteurRecherche_FoundRecordRequest($item->getIdNotice()); } - protected static function _findItem($id_sigb, $id_site, $record_type) { - if (static::ALL_SITES === $id_site) - return Class_Exemplaire::findFirstBy(['id_origine' => $id_sigb, - 'id_int_bib not' => 0, - 'type' => $record_type]); + protected static function _findItem(int $id_sigb, ?string $id_site, + int $record_type, + ?int $id_int_bib) : ?Class_Exemplaire { + $clauses = array_merge(($id_int_bib + ? ['id_int_bib' => $id_int_bib] + : ['id_int_bib not' => 0]), + ['id_origine' => $id_sigb, + 'type' => $record_type]); + + if (!$id_site + || static::ALL_SITES === $id_site) + return Class_Exemplaire::findFirstBy($clauses); return ($annex = Class_CodifAnnexe::findFirstBy(['id_origine' => $id_site])) - ? Class_Exemplaire::findFirstBy(['id_origine' => $id_sigb, - 'id_bib' => $annex->getIdBib(), - 'id_int_bib not' => 0, - 'type' => $record_type]) + ? Class_Exemplaire::findFirstBy(array_merge(['id_bib' => $annex->getIdBib()], + $clauses)) : null; } @@ -89,13 +98,16 @@ abstract class Class_MoteurRecherche_RecordRequest { -class Class_MoteurRecherche_NullRecordRequest extends Class_MoteurRecherche_RecordRequest { +class Class_MoteurRecherche_NullRecordRequest + extends Class_MoteurRecherche_RecordRequest { } -class Class_MoteurRecherche_MissingParamRecordRequest extends Class_MoteurRecherche_RecordRequest { +class Class_MoteurRecherche_MissingParamRecordRequest + extends Class_MoteurRecherche_RecordRequest { + protected $_message; public function __construct($message) { @@ -111,7 +123,9 @@ class Class_MoteurRecherche_MissingParamRecordRequest extends Class_MoteurRecher -class Class_MoteurRecherche_UnknownRecordRequest extends Class_MoteurRecherche_RecordRequest { +class Class_MoteurRecherche_UnknownRecordRequest + extends Class_MoteurRecherche_RecordRequest { + public function doNotFound() { $this->_recordDoesNotExistsError(); } @@ -120,7 +134,9 @@ class Class_MoteurRecherche_UnknownRecordRequest extends Class_MoteurRecherche_R -class Class_MoteurRecherche_FoundRecordRequest extends Class_MoteurRecherche_RecordRequest { +class Class_MoteurRecherche_FoundRecordRequest + extends Class_MoteurRecherche_RecordRequest { + public function __construct($id) { $this->_id = $id; } diff --git a/library/Class/Notice/Permalink.php b/library/Class/Notice/Permalink.php index 64df2eddb88b85b3d687b594d389ef090cd16b01..02378b5e66fb8f716f1fefd26417a8125e0b30c1 100644 --- a/library/Class/Notice/Permalink.php +++ b/library/Class/Notice/Permalink.php @@ -80,7 +80,33 @@ class Class_Notice_Permalink { 'controller' => 'recherche', 'action' => 'viewnotice', 'clef' => $record->getClefAlpha(), - 'id' => $record->getId()]; + 'id' => $record->getId()]; + } + + + public function getPermalink(Class_Notice $record) : string { + if (Class_CosmoVar::DOUBLE_SEARCH_NONE != Class_CosmoVar::get('mode_doublon')) + return ''; + + $first_exemplaire = ($exemplaires = $record->getExemplaires()) + ? $exemplaires[0] + : null; + if (!$first_exemplaire) + return ''; + + if (!($id_sigb = $first_exemplaire->getIdOrigine()) + || !($id_int_bib = $first_exemplaire->getIdIntBib())) + return ''; + + $type = (Class_Notice::TYPE_BIBLIOGRAPHIC === $record->getType()) + ? [] + : ['type' => $record->getType()]; + return Class_Url::relative(array_merge(['module' => 'opac', + 'controller' => 'recherche', + 'action' => 'viewnotice', + 'id_sigb' => $id_sigb, + 'id_int_bib' => $id_int_bib], + $type), null, true); } diff --git a/library/ZendAfi/View/Helper/ReseauxSociaux.php b/library/ZendAfi/View/Helper/ReseauxSociaux.php index e884fe84401872e3bbe7b7ad3fb74411d87c5f98..0358566aaebf0ec846566f0831e3b946515f6bc4 100644 --- a/library/ZendAfi/View/Helper/ReseauxSociaux.php +++ b/library/ZendAfi/View/Helper/ReseauxSociaux.php @@ -42,15 +42,19 @@ class ZendAfi_View_Helper_ReseauxSociaux extends ZendAfi_View_Helper_BaseHelper public function renderNotice($notice) { - return $this->links(['url_to_share' => $this->_urlWithProfil($this->view->urlNotice($notice)), - 'titre' => $notice->getTitreEtSousTitre().' - '.$notice->getAuteurPrincipal(), + $permalink = (new Class_Notice_Permalink)->getPermalink($notice); + return $this->links(['url_to_share' => $permalink + ? $permalink + : $this->_urlWithProfil($this->view->urlNotice($notice)), + 'titre' => $notice->getTitreEtSousTitre() + . ' - ' . $notice->getAuteurPrincipal(), 'message' => $notice->getResume(), 'img_url' => $notice->getUrlVignette()]); } protected function _urlWithProfil($url) { - return $url .'?id_profil=' . Class_Profil::getCurrentProfil()->getId(); + return $url . '?id_profil=' . Class_Profil::getCurrentProfil()->getId(); } @@ -171,4 +175,4 @@ class ZendAfi_View_Helper_ReseauxSociaux extends ZendAfi_View_Helper_BaseHelper protected function imageForAction($action) { return 'reseaux/'. $action . '.png'; } -} \ No newline at end of file +} diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index 43b1a13b266c6e032514d5a0ad98ee4d1f326dcc..2283e888b82822dd3e7c8d27eef416411383cabc 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -25,52 +25,48 @@ abstract class RechercheControllerNoticeTestCase extends AbstractControllerTestC public function setUp() { parent::setUp(); - $this->fixture('Class_CodifAuteur', + $this->fixture(Class_CodifAuteur::class, ['id' => 123, 'libelle' => 'Bernard Génin']); - $this->fixture('Class_CodifAuteurFonction', + $this->fixture(Class_CodifAuteurFonction::class, ['id' => '070', 'libelle' => 'Auteur']); - $this->fixture('Class_CodifCentreInteret', + $this->fixture(Class_CodifCentreInteret::class, ['id' => 2, 'libelle' => 'marionettes']); - $this->fixture('Class_CodifGenre', + $this->fixture(Class_CodifGenre::class, ['id' => 1, 'libelle' => 'spectacle']); - $this->fixture('Class_CodifTags', + $this->fixture(Class_CodifTags::class, ['id' => 3, 'libelle' => 'enfants']); - $this->fixture('Class_CodifPcdm4', + $this->fixture(Class_CodifPcdm4::class, ['id' => 4, 'libelle' => 'rock']); - $this->fixture('Class_CodifDewey', + $this->fixture(Class_CodifDewey::class, ['id' => 1, 'id_dewey' => 1, 'libelle' => 'Philosophie et disciplines connexes']); - $this->fixture('Class_CodifDewey', + $this->fixture(Class_CodifDewey::class, ['id' => 2, 'id_dewey' => 2, 'libelle' => 'enfants']); - - $this->mock_sql = $this->mock() ->whenCalled('execute')->answers('') ->whenCalled('fetchOne')->answers(null) ->whenCalled('fetchAll')->answers([ [1, ''] ]); Zend_Registry::set('sql', $this->mock_sql); - - $this->fixture('Class_Bib', ['id' => 1, 'libelle' => 'Romains']); - $this->fixture('Class_Bib', ['id' => 2, 'nom_court' => 'Pringy']); - + $this->fixture(Class_Bib::class, ['id' => 1, 'libelle' => 'Romains']); + $this->fixture(Class_Bib::class, ['id' => 2, 'nom_court' => 'Pringy']); $this->notice = Class_Notice::newInstanceWithId(345, ['annee' => 2002, @@ -82,7 +78,7 @@ abstract class RechercheControllerNoticeTestCase extends AbstractControllerTestC 'facettes' => 'A123 F2 G1 P4 Y2 B1 Lfre M1 Z3 D1', 'date_creation' => '2013-12-31', 'unimarc' => file_get_contents(ROOT_PATH . 'tests/fixtures/bernard_genin.uni')]) - ->setExemplaires([$this->fixture('Class_Exemplaire', + ->setExemplaires([$this->fixture(Class_Exemplaire::class, ['id' => 34, 'id_bib' => 456, 'id_int_bib' => 1, @@ -100,40 +96,41 @@ abstract class RechercheControllerNoticeTestCase extends AbstractControllerTestC class RechercheControllerPrintTest extends RechercheControllerNoticeTestCase { - public function setUp() { + public function setUp() { parent::setUp(); - $this->fixture('Class_ModeleFusion', ['id' => 1, - 'nom' => 'article', - 'contenu' => '<p><h1> {notice.titre_principal}</h1> <div>{notice.article.contenu} </div> + + $this->fixture(Class_ModeleFusion::class, + ['id' => 1, + 'nom' => 'article', + 'contenu' => '<p><h1> {notice.titre_principal}</h1> <div>{notice.article.contenu} </div> {notice.avis[<p>{avis}</p>]} </p>', - 'profil_ids' => '3;4', - 'type' => Class_ModeleFusion::RECORD_TEMPLATE]); + 'profil_ids' => '3;4', + 'type' => Class_ModeleFusion::RECORD_TEMPLATE]); Class_AdminVar::newInstanceWithId('BABELTHEQUE_JS')->setValeur(''); - } /** @test */ public function pageOnProfilOneShouldNotContainsPrintLink() { - $this->home_profil = $this->fixture('Class_Profil', + $this->home_profil = $this->fixture(Class_Profil::class, ['id'=> 1, 'libelle'=> 'HomePage']); Class_Profil::setCurrentProfil($this->home_profil); - $this->dispatch('/recherche/viewnotice/id/'.$this->notice->getId(), true); + $this->dispatch('/recherche/viewnotice/id/' . $this->notice->getId()); $this->assertNotXPathContentContains('//div', 'Imprimer'); } /** @test */ public function pageOnProfilThreeShouldContainsPrintLink() { - $this->home_profil = $this->fixture('Class_Profil', + $this->home_profil = $this->fixture(Class_Profil::class, ['id'=> 3, 'libelle'=> 'HomePage']); Class_Profil::setCurrentProfil($this->home_profil); - $this->dispatch('/recherche/viewnotice/id/'.$this->notice->getId(), true); + $this->dispatch('/recherche/viewnotice/id/' . $this->notice->getId()); $this->assertXPathContentContains('//div', 'Imprimer'); } @@ -717,7 +714,9 @@ class RechercheControllerViewNoticeTest extends RechercheControllerNoticeTestCas -class RechercheControllerViewNoticeByIdSigbTest extends RechercheControllerNoticeTestCase { +class RechercheControllerViewNoticeByIdSigbTest + extends RechercheControllerNoticeTestCase { + public function setUp() { parent::setUp(); $this->fixture(Class_CodifAnnexe::class, @@ -725,7 +724,6 @@ class RechercheControllerViewNoticeByIdSigbTest extends RechercheControllerNotic 'id_bib' => 456, 'id_origine' => 2]); - $this->fixture(Class_Notice::class, ['id' => 678, 'type' => Class_Notice::TYPE_AUTHORITY]) @@ -746,6 +744,13 @@ class RechercheControllerViewNoticeByIdSigbTest extends RechercheControllerNotic } + /** @test */ + public function withIdIntBib1ShouldRedirectToViewNoticeId345() { + $this->dispatch('/recherche/viewnotice/id_sigb/12/id_int_bib/1'); + $this->assertRedirectTo('/recherche/viewnotice/id/345'); + } + + /** @test */ public function withIdSIB12AndRecordTypeAuthorityShouldRedirectToViewNoticeId678() { $this->dispatch('/recherche/viewnotice/id_sigb/12/id_site/2/record_type/2'); @@ -767,22 +772,25 @@ class RechercheControllerViewNoticeByIdSigbTest extends RechercheControllerNotic } + /** @test */ + public function withIdIntBib456AndRecordTypeAuthorityIdSiteWildcardShouldRedirectToViewNoticeId678() { + $this->dispatch('/recherche/viewnotice/id_sigb/12/id_int_bib/456/record_type/2'); + $this->assertRedirectTo('/recherche/viewnotice/id/678'); + } + + /** * @test * @expectedException Zend_Controller_Action_Exception */ public function withUnknownIdSiteShouldThrow404() { $this->dispatch('/recherche/viewnotice/id_sigb/12/id_site/3'); - $this->assertResponseCode(404); } - /** - * @test - * @expectedException Zend_Controller_Action_Exception - */ + /** @test */ public function withUnknownIdSigbShouldThrow404() { - $this->dispatch('/recherche/viewnotice/id_sigb/66/id_site/2'); + $this->dispatch('/recherche/viewnotice/id_sigb/66/id_site/2', false); $this->assertResponseCode(404); } @@ -793,22 +801,27 @@ class RechercheControllerViewNoticeByIdSigbTest extends RechercheControllerNotic */ public function withNoIdSigbShouldThrow400() { $this->dispatch('/recherche/viewnotice/id_site/2'); - $this->assertResponseCode(400); } - /** - * @test - * @expectedException Zend_Controller_Action_Exception - */ + /** @test */ public function withNoIdSiteShouldThrow400() { - $this->dispatch('/recherche/viewnotice/id_sigb/12'); + $this->dispatch('/recherche/viewnotice/id_sigb/12', false); + $this->assertResponseCode(400); + } + + + /** @test */ + public function withIdIntBib1AndIdSite2ShouldThrow400() { + $this->dispatch('/recherche/viewnotice/id_sigb/12/id_site/2/id_int_bib/1', + false); $this->assertResponseCode(400); } } + class RechercheControllerViewNoticeByIdSigbFilteredTest extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true; @@ -1852,12 +1865,15 @@ class RechercheControllerSimpleActionWithNoResultsTest extends RechercheControll -abstract class RechercheControllerSimpleActionListeFormatTestCase extends AbstractControllerTestCase { +abstract class RechercheControllerSimpleActionListeFormatTestCase + extends AbstractControllerTestCase { + + protected $_liste_format, $_search_term_editable = 0, - $_nb_par_page = 10, - $_storm_default_to_volatile = true; + $_nb_par_page = 10; + public function setUp() { parent::setUp(); @@ -1872,19 +1888,21 @@ abstract class RechercheControllerSimpleActionListeFormatTestCase extends Abstra 'search_term_editable' => $this->_search_term_editable]]]) ->setSelTypeDoc('1;2;3;4;5'); - - $this->fixture('Class_Bib', ['id' => 1, - 'sigb_exemplaire' => false, - 'libelle' => 'Tombouctou']); - $this->fixture('Class_IntBib', ['id' => 1, - 'nom_court' => 'Annecy', - 'comm_sigb' => null - ]); - $this->fixture('Class_TypeDoc' , [ 'id' => 1, - 'label' => 'Livres']); - $this->fixture('Class_TypeDoc' , [ 'id' => 2, - 'label' => 'Périodique']); - + $this->fixture(Class_Bib::class, + ['id' => 1, + 'sigb_exemplaire' => false, + 'libelle' => 'Tombouctou']); + $this->fixture(Class_IntBib::class, + ['id' => 1, + 'nom_court' => 'Annecy', + 'comm_sigb' => null + ]); + $this->fixture(Class_TypeDoc::class, + [ 'id' => 1, + 'label' => 'Livres']); + $this->fixture(Class_TypeDoc::class, + [ 'id' => 2, + 'label' => 'Périodique']); $potter_marc = file_get_contents(ROOT_PATH.'/tests/fixtures/dvd_potter.uni'); $fetch_all_result = []; @@ -1908,7 +1926,6 @@ abstract class RechercheControllerSimpleActionListeFormatTestCase extends Abstra ['id' => 1234, 'libelle' => 'Chris Columbus']); - $mock_sql = $this->mock() ->whenCalled('fetchAll') ->answers($fetch_all_result); @@ -2997,14 +3014,15 @@ class RechercheControllerAjoutNoticePanierUrlMurTest extends RechercheController -class RechercheControllerPermalinkMurTest extends RechercheControllerSimpleActionListeFormatTestCase { - protected $_liste_format = Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR; +class RechercheControllerPermalinkMurTest + extends RechercheControllerSimpleActionListeFormatTestCase { + protected $_liste_format = Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR; public function setUp() { parent::setUp(); ZendAfi_Auth::getInstance()->clearIdentity(); - $this->dispatch('/recherche/simple/expressionRecherche/potter/facettes/T1/facette/B1/page/2', true); + $this->dispatch('/recherche/simple/expressionRecherche/potter/facettes/T1/facette/B1/page/2'); } @@ -3017,6 +3035,174 @@ class RechercheControllerPermalinkMurTest extends RechercheControllerSimpleActio +abstract class RechercheControllerPermalinkWithIdIntBibTestCase + extends RechercheControllerSimpleActionListeFormatTestCase { + + protected $_liste_format = Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR; + + public function setUp() { + parent::setUp(); + + Class_CosmoVar::setValueOf('mode_doublon', + '' . Class_CosmoVar::DOUBLE_SEARCH_NONE); + + Class_Notice::find(15) + ->setType($this->_getNoticeType()) + ->setExemplaires([$this->fixture(Class_Exemplaire::class, + ['id' => 999, + 'type' => $this->_getNoticeType(), + 'id_bib' => 1, + 'id_int_bib' => 1, + 'id_origine' => 1111])]) + ->assertSave(); + + $this->_dispatch(); + } + + + protected function _dispatch() : void { + $this->dispatch('/recherche/simple/expressionRecherche/potter/facettes/T1/facette/B1/page/2/id_profil/2'); + } + + + protected function _getNoticeType() : int { + return 0; + } +} + + + + +class RechercheControllerPermalinkWithIdIntBibAndTypeBibliographicTest + extends RechercheControllerPermalinkWithIdIntBibTestCase { + + protected function _getNoticeType() : int { + return Class_Notice::TYPE_BIBLIOGRAPHIC; + } + + + /** @test */ + public function permalinkShouldBeDisplay() { + $this->assertXPath('//img[contains(@class, "permalink")][contains(@data-url, "/recherche/viewnotice/id_sigb/1111/id_int_bib/1")]'); + } + + + /** @test */ + public function contextfacebookLinkShouldContainsIdIntBib() { + $this->assertXPath('//div[contains(@class, "reseaux-sociaux")]/img[contains(@onclick, "id_int_bib")]'); + } + + + /** @test */ + public function permalinkShouldNotBeDisplayedWithContextExpressionRecherche() { + $this->assertNotXPath('//img[contains(@class, "permalink")][contains(@data-url, "id_sigb/1111/id_int_bib/1/expressionRecherche")]'); + } + + + /** @test */ + public function permalinkShouldNotBeDisplayedWithIdProfil() { + $this->assertNotXPath('//img[contains(@class, "permalink")][contains(@data-url, "id_sigb/1111/id_int_bib/1?id_profil")]'); + } + + + /** @test */ + public function othersLinkShouldNotBeDisplayedWithIdIntBib() { + $this->assertNotXPath('//a[contains(@href, "id_sigb/1111/id_int_bib/1")]'); + } + + + /** @test */ + public function permalinkWithIdIntBibShouldBeDisplayOnlyOnce() { + $this->assertXPathCount('//img[contains(@class, "permalink")][contains(@data-url, "/recherche/viewnotice/id_sigb/1111/id_int_bib/1")]', 1); + } +} + + + + +class RechercheControllerPermalinkWithIdIntBibAndTypeAuthorityTest + extends RechercheControllerPermalinkWithIdIntBibTestCase { + + protected function _getNoticeType() : int { + return Class_Notice::TYPE_AUTHORITY; + } + + + /** @test */ + public function permalinkShouldBeDisplay() { + $this->assertXPath('//img[contains(@class, "permalink")][contains(@data-url, "/recherche/viewnotice/id_sigb/1111/id_int_bib/1/type/2")]'); + } +} + + + + +class RechercheControllerPermalinkWithIdIntBibAndTypeBibliographicInTemplateTest + extends RechercheControllerPermalinkWithIdIntBibTestCase { + + protected function _getNoticeType() : int { + return Class_Notice::TYPE_BIBLIOGRAPHIC; + } + + + protected function _dispatch() : void { + $this->_buildTemplateProfil(['id' => '2']); + parent::_dispatch(); + } + + + /** @test */ + public function permalinkViewNoticeWithIdSigb1111AndIdIntBib1ShouldBeDisplay() { + $this->assertXPath('//body[@data-template="INTONATION"]//a[contains(@class, "view_permalink permalink")][contains(@href, "/recherche/viewnotice/id_sigb/1111/id_int_bib/1")]'); + } + + + /** @test */ + public function onlyOneLinkShouldContainIdIntBibOne() { + $this->assertXPathCount('//a[contains(@href, "id_int_bib/1")]', 1); + } +} + + + + +class RechercheControllerViewNoticePermalinkWithIdIntBibInTemplateTest + extends RechercheControllerPermalinkWithIdIntBibTestCase { + + protected function _getNoticeType() : int { + return Class_Notice::TYPE_BIBLIOGRAPHIC; + } + + + protected function _dispatch() : void { + $sql = Zend_Registry::get('sql'); + $sql + ->whenCalled('fetchOne') + ->answers([0]) + + ->whenCalled('execute') + ->answers(null); + + $this->_buildTemplateProfil(['id' => '2']); + $this->dispatch('/recherche/viewnotice/id/15'); + } + + + /** @test */ + public function permalinkViewNoticeWithIdSigb1111AndIdIntBib1ShouldBeDisplay() { + $this->assertXPath('//body[@data-template="INTONATION"]//a[contains(@class, "view_permalink permalink")][contains(@href, "/recherche/viewnotice/id_sigb/1111/id_int_bib/1")]'); + } + + + /** @test */ + public function onlyOneLinkShouldContainIdIntBibOne() { + $this->assertXPathCount('//a[contains(@href, "id_int_bib/1")]', 1); + } +} + + + + class RechercheControllerNavigationTest extends RechercheControllerNoticeTestCase { public function setUp(){ parent::setUp(); @@ -3927,4 +4113,4 @@ class RechercheControllerWithEmptyPanierTest extends AbstractControllerTestCase public function shouldRenderNoResult() { $this->assertXPathContentContains('//p', 'Aucun résultat'); } -} \ No newline at end of file +}