diff --git a/VERSIONS_HOTLINE/83776 b/VERSIONS_HOTLINE/83776 new file mode 100644 index 0000000000000000000000000000000000000000..deb66f4ca3d1e2a047e2e746958ffc0cf0eaf72a --- /dev/null +++ b/VERSIONS_HOTLINE/83776 @@ -0,0 +1 @@ + - ticket #83776 : Vue notice : Correction d'une erreur lorsque la fiche auteur est activée et que la notice n'a pas d'auteur principal \ No newline at end of file diff --git a/application/modules/opac/views/scripts/recherche/viewnotice.phtml b/application/modules/opac/views/scripts/recherche/viewnotice.phtml index ec7dad9994666c29c1a1130b22e05010f4089aa4..e7da9a0845b7174450ecbacc64dc6ac948f8f94f 100644 --- a/application/modules/opac/views/scripts/recherche/viewnotice.phtml +++ b/application/modules/opac/views/scripts/recherche/viewnotice.phtml @@ -92,8 +92,9 @@ $script_loader = Class_ScriptLoader::getInstance() ?> <br> <?php - echo (Class_AdminVar::isModuleEnabled('AUTHOR_PAGE')) - ? $this->notice->getChampNotice(Class_CodifAuteur::CODE_FACETTE)[0]->renderOn($this) + echo (Class_AdminVar::isModuleEnabled('AUTHOR_PAGE') + && ($author_fields = $this->notice->getChampNotice(Class_CodifAuteur::CODE_FACETTE))) + ? $author_fields[0]->renderOn($this) : $this->tag('span', $this->notice->getAuteurPrincipal()); ?> </h1> diff --git a/tests/scenarios/AuthorPage/AuthorPageTest.php b/tests/scenarios/AuthorPage/AuthorPageTest.php index cbc0def1d592f9d2b42be4de0e0d81f5796d9bd7..1071e5c61a3f40a3690eca6745af7ebe04dba00d 100644 --- a/tests/scenarios/AuthorPage/AuthorPageTest.php +++ b/tests/scenarios/AuthorPage/AuthorPageTest.php @@ -379,7 +379,7 @@ class AuthorPageViewRecordDetailTest extends AuthorPageTestCase { -class AuthorPageViewRecordTest extends AuthorPageTestCase { +class AuthorPageViewRecordWithAuthorTest extends AuthorPageTestCase { public function setUp() { parent::setUp(); $this->mock_sql->whenCalled('fetchOne') @@ -399,4 +399,31 @@ class AuthorPageViewRecordTest extends AuthorPageTestCase { $this->assertXPathContentContains('//h1/a[@href="/author/view/id/2408"]', 'Victor Hugo'); } +} + + + + +class AuthorPageViewRecordWithoutAuthorTest extends AuthorPageTestCase { + public function setUp() { + parent::setUp(); + + $this->mock_sql->whenCalled('fetchOne')->answers(true) + ->whenCalled('fetchAll')->answers([]) + ->whenCalled('execute')->answers(true); + + $this->fixture('Class_Notice', ['id' => 999, 'titre_principal' => 'Les contacteurs']); + + $this->_http_client->whenCalled('open_url') + ->with('http://cache.org?titre=Les+contacteurs&auteur=&type_doc=0&numero=&src=d65fb6da9bbd9e4ddc65b9dcf1c1869f&api=2.0&action=10') + ->answers(false); + + $this->dispatch('/recherche/viewnotice/id/999'); + } + + + /** @test */ + public function shouldNotBeError() { + $this->assertXPathContentContains('//h1', 'Les contacteurs'); + } } \ No newline at end of file