Commit c003ccc1 authored by Laurent's avatar Laurent
Browse files

dev #48981 fix test failure

parent 73bd777d
......@@ -391,10 +391,14 @@ class AbonneController extends ZendAfi_Controller_Action {
foreach($ids as $id) {
$status = $cards->renewLoan($id);
$status['id'] = $id;
$results[]=$status;
$results[] = $status;
}
$title = (count($ids)>1) ? $this->_('Prolongation des prêts') :$this->_('Prolongation du prêt');
$this->_renderExtendPopup($title, $this->view->abonne_LoansExtension($this->_user,$results,$ids));
$title = (count($ids)>1)
? $this->_('Prolongation des prêts')
: $this->_('Prolongation du prêt');
$this->_renderExtendPopup($title, $this->view->abonne_LoansExtension($cards, $results, $ids));
}
......
......@@ -2,8 +2,8 @@
<div class="abonneTitre"><?php echo $this->user->getNomAff();?></div>
<?php
$loans = (new Class_User_Cards($this->user))->getLoansWithOutPNB();
$cards = new Class_User_Cards($this->user);
$loans = $cards->getLoansWithOutPNB();
$renewable_loan = [];
foreach ($loans as $loan) {
......
......@@ -1238,7 +1238,8 @@ class Class_Users extends Storm_Model_Abstract {
public function getPNBLoans() {
return $this->getEmprunts()->selectPNB();
$loans = $this->getEmprunts()->selectPNB();
return Class_User_CardsOperationDecorator::decorateAll($loans, $this);
}
......
......@@ -21,52 +21,60 @@
class ZendAfi_View_Helper_Abonne_LoansExtension extends ZendAfi_View_Helper_BaseHelper {
public function abonne_LoansExtension($user,$results, $ids) {
if (count($ids) == 1)
return $this->_renderOneLoanExtension($results);
return $this->_renderMultipleLoansExtension($results,$user);
protected
$_cards,
$_results;
public function abonne_LoansExtension($cards, $results, $ids) {
$this->_cards = $cards;
$this->_results = $results;
return count($ids) == 1
? $this->_renderOneLoanExtension()
: $this->_renderMultipleLoansExtension();
}
protected function _renderMultipleLoansExtension($results,$user) {
protected function _renderMultipleLoansExtension() {
$nb_success = 0;
$nb_errors = 0;
foreach ($results as $result)
foreach ($this->_results as $result)
$result['statut'] == 1 ? $nb_success++ : $nb_errors++;
$message = $nb_success . $this->_(' prêt(s) prolongé(s).').'<br>';
$message .= $nb_errors . $this->_(' prolongation(s) impossible(s).').'<br>';
$message .= $this->_getExtensionsErrors($results,$user);
$message .= $this->_getExtensionsErrors();
return $message;
}
protected function _renderOneLoanExtension($results) {
return ($results[0]['statut'] == 1)
protected function _renderOneLoanExtension() {
return ($this->_results[0]['statut'] == 1)
? $this->_('Votre prêt a bien été prolongé.')
: ($results[0]['erreur']);
: ($this->_results[0]['erreur']);
}
protected function _getExtensionsErrors($results,$user) {
protected function _getExtensionsErrors() {
$message = '';
foreach($results as $result) {
$message .= $this->_getExtensionError($result,$user);
}
foreach($this->_results as $result)
$message .= $this->_getExtensionError($result);
return $message;
}
protected function _getExtensionError($result,$user) {
protected function _getExtensionError($result) {
if ($result['statut'] != 0)
return '';
$loans = $user->getEmprunts();
foreach ($loans as $loan) {
foreach ($this->_cards->getLoansWithOutPNB() as $loan) {
if ($loan->getId() == $result['id'])
return '<br><strong>' . $loan->getTitre() . ':</strong> ' . $result['erreur'];
return '<br>'. $this->_tag('strong', $loan->getTitre() . ':') . ' ' . $result['erreur'];
}
return '';
}
}
?>
\ No newline at end of file
}
\ No newline at end of file
......@@ -43,7 +43,9 @@ abstract class AbstractAbonneControllerPretsTestCase extends AbstractControllerT
['id' => '123456',
'login' => 'flo',
'idabon' => 'x234',
'password' => 'flo']);
'password' => 'flo',
'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
'id_site' => 1]);
Storm_Cache::beVolatile();
Storm_Cache::setSeed('local');
......@@ -238,7 +240,9 @@ class AbonneControllerPretsListThreePretsTest extends AbonneControllerPretsListT
/** @test */
public function extendAllLoansButtonShouldBeDisplayed() {
$this->assertXPathContentContains('//a[contains(@href, "/abonne/prolongerPret/id_pret/13%3B12")]', 'Tout prolonger', $this->_response->getBody());
$this->assertXPathContentContains('//a[contains(@href, "/abonne/prolongerPret/id_pret/123456_13%3B123456_12")]',
'Tout prolonger',
$this->_response->getBody());
}
......@@ -317,7 +321,7 @@ class AbonneControllerPretsListThreePretsTest extends AbonneControllerPretsListT
/** @test */
public function aliceLoanShouldHaveExtendLink() {
$this->assertXPathContentContains("//tbody/tr[1]//td//a[@href='/abonne/prolongerPret/id_pret/13'][@data-popup='true']",
$this->assertXPathContentContains("//tbody/tr[1]//td//a[@href='/abonne/prolongerPret/id_pret/123456_13'][@data-popup='true']",
'Prolonger');
}
......@@ -348,7 +352,7 @@ class AbonneControllerPretsListThreePretsTest extends AbonneControllerPretsListT
/** @test */
public function potterLoanShouldHaveExtendLink() {
$this->assertXPathContentContains("//tbody/tr[2]//td//a[@href='/abonne/prolongerPret/id_pret/12'][@data-popup='true']",
$this->assertXPathContentContains("//tbody/tr[2]//td//a[@href='/abonne/prolongerPret/id_pret/123456_12'][@data-popup='true']",
'Prolonger');
}
......@@ -622,7 +626,7 @@ class AbonneControllerPretsRenewErrorThreePretsTest extends AbonneControllerPret
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/prolongerPret/id_pret/12', true);
$this->dispatch('/opac/abonne/prolongerPret/id_pret/123456_12', true);
$this->json = json_decode($this->_response->getBody());
}
......@@ -652,7 +656,7 @@ class AbonneControllerPretsRenewSuccessThreePretsTest extends AbonneControllerPr
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/prolongerPret/id_pret/12', true);
$this->dispatch('/opac/abonne/prolongerPret/id_pret/123456_12', true);
$this->json = json_decode($this->_response->getBody());
}
......@@ -705,7 +709,7 @@ class AbonneControllerPretsExtendAllLoansSuccessThreePretsTest extends AbonneCon
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/prolongerPret/id_pret/12;13', true);
$this->dispatch('/opac/abonne/prolongerPret/id_pret/123456_12;123456_13', true);
$this->json = json_decode($this->_response->getBody());
}
......@@ -735,7 +739,7 @@ class AbonneControllerPretsExtendAllLoansErrorThreePretsTest extends AbonneContr
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/prolongerPret/id_pret/12;13', true);
$this->dispatch('/opac/abonne/prolongerPret/id_pret/123456_12;123456_13', true);
$this->json = json_decode($this->_response->getBody());
}
......@@ -749,7 +753,6 @@ class AbonneControllerPretsExtendAllLoansErrorThreePretsTest extends AbonneContr
/** @test */
public function popupContentShouldContains2ImpossibleExtensions() {
$this->assertEquals(utf8_encode('0 prt(s) prolong(s).<br>2 prolongation(s) impossible(s).<br><br><strong>Harry Potter n 7<br /> Harry Potter and the deathly hallows:</strong> Prolongation impossible, votre abonnement est chu.<br><strong>Alice au royaume de Trfle : Cheshire cat Waltz n 5<br /> Alice au royaume de Trfle:</strong> Prolongation impossible, votre abonnement est chu.'), $this->json->content);
}
}
......@@ -761,7 +764,7 @@ class AbonneControllerPretsExtendAllLoansSuccessAndErrorThreePretsTest extends A
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/prolongerPret/id_pret/12;13', true);
$this->dispatch('/opac/abonne/prolongerPret/id_pret/123456_12;123456_13', true);
$this->json = json_decode($this->_response->getBody());
}
......@@ -790,7 +793,7 @@ class AbonneControllerPretsBadFormatExtendLoanThreePretsTest extends AbonneContr
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/prolongerPret/id_pret/;12;', true);
$this->dispatch('/opac/abonne/prolongerPret/id_pret/;123456_12;', true);
$this->json = json_decode($this->_response->getBody());
}
......
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