Commit 549d6ef4 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline #70867 replace tag anchor with dedicated buttons

parent a676d984
......@@ -286,8 +286,8 @@ class BibNumeriqueController extends ZendAfi_Controller_Action {
if($this->_userShouldBeRedirect())
return;
return $this->renderPopupResult($this->_('Emprunter le livre au format EPUB'),
$this->view->render('bib-numerique/loan-book.phtml'));
$this->view->titre = $this->_('Emprunter le livre au format EPUB');
$this->renderScript('bib-numerique/loan-book.phtml');
}
......@@ -295,8 +295,8 @@ class BibNumeriqueController extends ZendAfi_Controller_Action {
if($this->_userShouldBeRedirect())
return;
return $this->renderPopupResult($this->_('Consulter le livre en ligne'),
$this->view->render('bib-numerique/consult-book.phtml'));
$this->view->titre = $this->_('Consulter le livre en ligne');
$this->renderScript('bib-numerique/consult-book.phtml');
}
......
<?php
echo '<div class="popup-content">';
echo $this->tag('p', $this->_('Êtes vous sûr de vouloir consulter ce document ?'));
echo $this->tagAnchor($this->url(['action' => 'consult-book-open-ajax']), $this->_('oui'), ['data-popup' => 'true',
'class' => 'button blue']);
echo $this->tagAnchor('', $this->_('non'), ['onclick' => 'opacDialogClose();return false',
'class' => 'button red']);
echo '</div>';
?>
$html = [$this->tag('p', $this->_('Êtes vous sûr de vouloir consulter ce document ?')),
$this->button((new Class_Entity())
->setUrl($this->url(['action' => 'consult-book-open-ajax']))
->setText($this->_('Oui'))
->setAttribs(['data-popup' => 'true',
'class' => 'bouton validate'])),
$this->Button_Back((new Class_Entity())
->setUrl($this->url(['controller' => 'recherche',
'action' => 'viewnotice']))
->setAttribs(['title' => $this->_('Non je ne veux pas')])
->setText($this->_('Non')))];
echo $this->tag('div', implode($html), ['class' => 'popup-content']);
<?php
echo '<div class="popup-content">';
echo $this->tag('p', $this->_('Êtes vous sûr de vouloir emprunter ce document ?'));
echo $this->tagAnchor($this->url(['action' => 'download-loan-book-ajax']), $this->_('oui'), ['data-popup' => 'true',
'class' => 'button blue']);
echo $this->tagAnchor('', $this->_('non'), ['onclick' => 'opacDialogClose();return false',
'class' => 'button red']);
echo $this->tag('p', Class_AdminVar::getValueOrDefault('DILICOM_PNB_LOAN_WARNING_MESSAGE'));
echo '</div>';
?>
$html = [$this->tag('p', $this->_('Êtes vous sûr de vouloir emprunter ce document ?')),
$this->button((new Class_Entity())
->setUrl($this->url(['action' => 'download-loan-book-ajax']))
->setText($this->_('Oui'))
->setAttribs(['data-popup' => 'true',
'class' => 'bouton validate'])),
$this->Button_Back((new Class_Entity())
->setUrl($this->url(['controller' => 'recherche',
'action' => 'viewnotice']))
->setAttribs(['title' => $this->_('Non je ne veux pas')])
->setText($this->_('Non'))),
$this->tag('p', Class_AdminVar::getValueOrDefault('DILICOM_PNB_LOAN_WARNING_MESSAGE'))];
echo $this->tag('div', implode($html), ['class' => 'popup-content']);
......@@ -125,7 +125,7 @@ class BibNumeriqueContollerDilicomAjaxPopupBookActionTest extends BibNumeriqueCo
protected $_storm_default_to_volatile = true;
/** @test */
public function popupConsultBookShouldContainsLinkToOpenAjax() {
public function consultBookShouldContainsLinkToOpenAjax() {
$this->_http
->whenCalled('open_url')
->with('https://pnb-test.centprod.com/v2/pnb-numerique/json/consultBook?glnContractor=123456789&orderLineId=x321&accessMedium=STREAMING&localization=IN_SITU&consultEndDate=2014-05-02T15%3A14%3A14%2B0200&ean13=435465&ipAddress=127.0.0.1&glnColl=afi-bib&loanerColl=2345889&loanId=n4y4nq63')
......@@ -133,8 +133,9 @@ class BibNumeriqueContollerDilicomAjaxPopupBookActionTest extends BibNumeriqueCo
->beStrict();
$this->dispatch('/bib-numerique/consult-book-ajax/id/3', true);
$this->assertContains('<div class="popup-content"><p>Êtes vous sûr de vouloir consulter ce document ?</p><a href="/bib-numerique/consult-book-open-ajax/id/3" data-popup="true" class="button blue">oui</a><a href="" onclick="opacDialogClose();return false" class="button red">non</a></div>',
json_decode($this->_response->getBody())->content);
$this->assertXpathContentContains('//div[@class="popup-content"]//button[contains(@onclick, "/bib-numerique/consult-book-open-ajax/id/3")][@data-popup="true"][@class="bouton validate"]', 'Oui');
$this->assertXpathContentContains('//button[contains(@onclick, "window.location.href")]', 'Non');
}
......@@ -167,7 +168,7 @@ class BibNumeriqueContollerDilicomAjaxPopupBookActionTest extends BibNumeriqueCo
/** @test */
public function loanBookPopupShouldContainsQuestion() {
$this->dispatch('/bib-numerique/loan-book-ajax/id/3', true);
$this->dispatch('/bib-numerique/loan-book-ajax/id/3/render/popup', true);
$this->assertContains('<p>Êtes vous sûr de vouloir emprunter ce document ?</p>',
json_decode($this->_response->getBody())->content);
}
......@@ -176,20 +177,13 @@ class BibNumeriqueContollerDilicomAjaxPopupBookActionTest extends BibNumeriqueCo
/** @test */
public function loanBookPopupShouldContainsLinkToDownload() {
$this->dispatch('/bib-numerique/loan-book-ajax/id/3', true);
$this->assertContains('<a href=\"\/bib-numerique\/download-loan-book-ajax\/id\/3\" data-popup=\"true\" class=\"button blue\">oui<\/a>', $this->_response->getBody());
}
/** @test */
public function loanBookPopupShouldContainsAnswerYes() {
$this->dispatch('/bib-numerique/loan-book-ajax/id/3', true);
$this->assertContains('<a href=\"\/bib-numerique\/download-loan-book-ajax\/id\/3\" data-popup=\"true\" class=\"button blue\">oui<\/a>', $this->_response->getBody());
$this->assertXpathContentContains('//button[contains(@onclick, "/bib-numerique/download-loan-book-ajax/id/3")][@data-popup="true"][@class="bouton validate"]', 'Oui');
}
/** @test */
public function loanBookPopupShouldContainDefaultMessage() {
$this->dispatch('/bib-numerique/loan-book-ajax/id/3', true);
$this->dispatch('/bib-numerique/loan-book-ajax/id/3/render/popup', true);
$this->assertContains('Votre compte sera mis à jour dans un délai de 15 minutes après le retour anticipé du document.', json_decode($this->_response->getBody())->content);
}
......@@ -200,7 +194,7 @@ class BibNumeriqueContollerDilicomAjaxPopupBookActionTest extends BibNumeriqueCo
['id' => 'DILICOM_PNB_LOAN_WARNING_MESSAGE',
'valeur' => 'Don\'t use this !'
]);
$this->dispatch('/bib-numerique/loan-book-ajax/id/3', true);
$this->dispatch('/bib-numerique/loan-book-ajax/id/3/render/popup', true);
$this->assertContains('Don\'t use this !', json_decode($this->_response->getBody())->content);
}
......
Markdown is supported
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