Commit 55acbb8f authored by Ghislain Loas's avatar Ghislain Loas Committed by Patrick Barroca

hotline #85026 add default option in link selection to domain form

parent ef295bd4
Pipeline #6195 passed with stage
in 30 minutes and 29 seconds
- ticket #85026 : Administration : ajout d'une valeur par défaut dans le formulaire de rattachement d'un panier à un domaine.
\ No newline at end of file
......@@ -200,34 +200,37 @@ class Admin_CatalogueController extends ZendAfi_Controller_Action {
if (!$catalogue = Class_Catalogue::find((int)$this->_getParam("id_catalogue")))
return $this->_redirect("admin/catalogue/index");
if ($this->_request->isPost()) {
$panier = Class_PanierNotice::find($this->_request->getPost('id_panier'));
$catalogue->addPanierNotice($panier)->save();
$panier->addCatalogue($catalogue)->save();
$panier->index();
$this->_helper->notify($this->_('Panier "%s" ajouté', $panier->getLibelle()));
$this->_redirect('admin/catalogue/paniers/id_catalogue/' . $catalogue->getId());
return;
}
if ($id_panier_to_remove = (int)$this->_getParam('remove')) {
$panier = Class_PanierNotice::find($id_panier_to_remove);
$catalogue->removePanierNotice($panier)->save();
$panier->removeCatalogue($catalogue)->save();
$this->_helper->notify($this->_('Panier "%s" retiré', $panier->getLibelle()));
$this->_redirect('admin/catalogue/paniers/id_catalogue/' . $catalogue->getId());
return $this->_redirect('admin/catalogue/paniers/id_catalogue/' . $catalogue->getId());
}
if (!$this->_request->isPost()) {
$this->view->form_paniers = $this->formAjoutPanier($catalogue);
$this->view->catalogue = $catalogue;
$this->view->titre = $this->_('Paniers du domaine: %s', $catalogue->getLibelle());
return;
}
$this->view->form_paniers = $this->formAjoutPanier($catalogue);
$this->view->catalogue = $catalogue;
$this->view->titre = $this->_('Paniers du domaine: %s', $catalogue->getLibelle());
if (!$panier = Class_PanierNotice::find((int)$this->_request->getPost('id_panier'))) {
$this->_helper->notify($this->_('Aucun panier sélectionné pour ajout'));
return $this->_redirect('admin/catalogue/paniers/id_catalogue/' . $catalogue->getId());
}
$catalogue->addPanierNotice($panier)->save();
$panier->addCatalogue($catalogue)->save();
$panier->index();
$this->_helper->notify($this->_('Panier "%s" ajouté', $panier->getLibelle()));
$this->_redirect('admin/catalogue/paniers/id_catalogue/' . $catalogue->getId());
}
protected function formAjoutPanier($catalogue) {
$options = [];
$options = ['' => $this->_('Veuiller sélectionner un panier')];
$paniers = Class_PanierNotice::findAllBelongsToAdmin();
foreach($paniers as $panier)
$options[$panier->getId()] = $panier->getLibelleForAdmins();
......
......@@ -1357,12 +1357,20 @@ class CatalogueControllerPaniersHistoireTest extends AdminCatalogueControllerTes
public function pageShouldContainsLinkToPreview() {
$this->assertXPath('//a[contains(@href, "/recherche/simple/id_catalogue/100")]');
}
/** @test */
public function defaultOptionShouldPresent() {
$this->assertXpathContentContains('//option', 'Veuiller sélectionner un panier');
}
}
class CatalogueControllerPaniersHistoirePostPanierSelectionSenorTest extends AdminCatalogueControllerTestCase {
class CatalogueControllerPaniersHistoirePostPanierSelectionSenorTest
extends AdminCatalogueControllerTestCase {
public function setUp() {
parent::setUp();
......@@ -1399,6 +1407,31 @@ class CatalogueControllerPaniersHistoirePostPanierSelectionSenorTest extends Adm
class CatalogueControllerPaniersHistoirePostPanierSelectionEmptyTest
extends AdminCatalogueControllerTestCase {
public function setUp() {
parent::setUp();
$this->postDispatch('/admin/catalogue/paniers/id_catalogue/100',
['id_panier' => '']);
}
/** @test */
public function answerShouldRedirectToCataloguePanier100() {
$this->assertRedirectTo('/admin/catalogue/paniers/id_catalogue/100');
}
/** @test */
public function messageShouldBeAucunPanierSelectionnePourAjout() {
$this->assertFlashMessengerContentContains('Aucun panier sélectionné pour ajout');
}
}
class CatalogueControllerPaniersHistoireRemovePanierJeunesseTest extends AdminCatalogueControllerTestCase {
public function setUp() {
......
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