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

hotline #83776 : fix error when author page is active but record has no author

parent f3d22d3c
Branches
Tags
4 merge requests!3297WIP: Master,!2936Master,!2935Hotline,!2932hotline #83776 : fix error when author page is active but record has no author
Pipeline #5643 passed with stage
in 1 hour, 2 minutes, and 13 seconds
- 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
......@@ -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>
......
......@@ -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
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