diff --git a/library/ZendAfi/View/Helper/RecordAlbums.php b/library/ZendAfi/View/Helper/RecordAlbums.php index 0e51666721370e875429b0a592cfcea340d0b545..ecb2f80308fe08b9e93e3c7ed2399e293d4b5d90 100644 --- a/library/ZendAfi/View/Helper/RecordAlbums.php +++ b/library/ZendAfi/View/Helper/RecordAlbums.php @@ -43,6 +43,9 @@ class ZendAfi_View_Helper_RecordAlbums extends Zend_View_Helper_Abstract { if (!$album = $link->getEntityOfType(Class_FRBR_Link::TYPE_ALBUM)) return ''; + if (!$album->isValidated() && !Class_Users::isCurrentUserAdmin()) + return ''; + return $this->view->tag('h3', $album->getTitre()) . $this->view->renderAlbum($album); } diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index 7522db7584b31b4e45d53b04204d5cb98907b6c3..cb6cad7bf4105712ff2eb2ce7babf4832658dde8 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -310,7 +310,8 @@ class NoticeAjaxControllerResNumeriquesTest extends AbstractControllerTestCase { -class NoticeAjaxControllerResNumeriquesFromFrbrLinkTest extends AbstractControllerTestCase { + +abstract class NoticeAjaxControllerResNumeriquesFromFrbrLinkTestCase extends AbstractControllerTestCase { public function setup() { parent::setup(); $this->fixture('Class_Notice', ['id' => 123, 'clef_alpha' => 'ACESHIGH--IRONM---1984-1']); @@ -319,6 +320,12 @@ class NoticeAjaxControllerResNumeriquesFromFrbrLinkTest extends AbstractControll 'titre' => 'Aces High', 'type_doc_id' => Class_TypeDoc::AUDIO_RECORD]); + $album = $this->fixture('Class_Album', + ['id' => 43, + 'titre' => 'Digitak', + 'type_doc_id' => Class_TypeDoc::AUDIO_RECORD, + 'status' => Class_Album::STATUS_DRAFT]); + $this->fixture('Class_FRBR_LinkType', ['id' => 1, 'libelle' => 'CD MP3', @@ -343,6 +350,21 @@ class NoticeAjaxControllerResNumeriquesFromFrbrLinkTest extends AbstractControll 'target' => ROOT_URL . BASE_URL . '/recherche/viewnotice/clef/ACESHIGH--IRONM---1984-1', 'source' => ROOT_URL . BASE_URL . '/bib-numerique/notice/id/42']); + $this->fixture('Class_FRBR_Link', + ['id' => 3, + 'type_id' => 2, + 'target' => ROOT_URL . BASE_URL . '/recherche/viewnotice/clef/ACESHIGH--IRONM---1984-1', + 'source' => ROOT_URL . BASE_URL . '/bib-numerique/notice/id/43']); + + } +} + + + +class NoticeAjaxControllerResNumeriquesFromFrbrLinkTest extends NoticeAjaxControllerResNumeriquesFromFrbrLinkTestCase { + public function setup() { + parent::setup(); + $this->dispatch('noticeajax/resnumeriques?id_notice=123', true); } @@ -371,6 +393,12 @@ class NoticeAjaxControllerResNumeriquesFromFrbrLinkTest extends AbstractControll } + /** @test */ + public function digitakTitleShouldBeDisplayed() { + $this->assertXPathContentContains('//h3', 'Digitak'); + } + + /** @test */ public function linkedAlbumShouldBeEditable() { $this->assertXPath('//a[@class="edit_album"][contains(@href, "/admin/album/edit_album/id/42")]/img[contains(@src, "ico/edit.gif")]', $this->_response->getBody()); @@ -381,7 +409,26 @@ class NoticeAjaxControllerResNumeriquesFromFrbrLinkTest extends AbstractControll public function addAlbumLinkShouldBeDisplayed() { $this->assertXPathContentRegex('//a[@class="link_album"][@data-popup="true"][contains(@href, "/admin/album/link_album_to/id_notice/123")]', '/Cr(.*)er un album/'); } +} + + + +class NoticeAjaxControllerResNumeriquesFromFrbrLinkNonAdminTest extends NoticeAjaxControllerResNumeriquesFromFrbrLinkTestCase { + public function _login() { + } + + public function setup() { + parent::setup(); + + $this->dispatch('noticeajax/resnumeriques?id_notice=123', true); + } + + + /** @test */ + public function digitakTitleShouldNotBeDisplayed() { + $this->assertNotXPathContentContains('//h3', 'Digitak'); + } }