From 14afa6202abb7f367e6a9e0dbfacf168e3904e20 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Sat, 20 Oct 2012 11:42:40 +0000 Subject: [PATCH] =?UTF-8?q?Il=20est=20possible=20d'avoir=20un=20mail=20dif?= =?UTF-8?q?f=C3=A9rent=20pour=20les=20suggestions=20d'achat=20/=20formulai?= =?UTF-8?q?re=20de=20contact,=20par=20profil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/scripts/profil/_formProfil.phtml | 9 ++++--- library/Class/Profil.php | 15 +++++++++++ library/Class/SuggestionAchat.php | 2 +- .../controllers/ProfilControllerTest.php | 8 ++++++ .../BibNumeriqueControllerTest.php | 2 +- .../controllers/RechercheControllerTest.php | 1 - tests/library/Class/ProfilTest.php | 25 ++++++++++++++++++- tests/library/Class/SuggestionAchatTest.php | 4 +-- 8 files changed, 57 insertions(+), 9 deletions(-) diff --git a/application/modules/admin/views/scripts/profil/_formProfil.phtml b/application/modules/admin/views/scripts/profil/_formProfil.phtml index c50065a107c..ada805e05c9 100644 --- a/application/modules/admin/views/scripts/profil/_formProfil.phtml +++ b/application/modules/admin/views/scripts/profil/_formProfil.phtml @@ -3,9 +3,7 @@ Class_ScriptLoader::getInstance() ->addStylesheet(URL_ADMIN_JS.'color_picker/jquery.vreboton.ColorPicker') ->addAdminScript('color_picker/jquery.vreboton.ColorPicker') ->addInlineStyle('div.ColorPickerDivSample {margin-top:4px; margin-right:0px}') -->addJQueryReady('$(".colorpicker").attachColorPicker()'); - -Class_ScriptLoader::getInstance() +->addJQueryReady('$(".colorpicker").attachColorPicker()') ->addAdminScript('tag_selection') ->addInlineScript(" function changeBrowser(sBrowser){ if (sBrowser=='telephone') { @@ -65,6 +63,11 @@ Class_ScriptLoader::getInstance() <td class="droite"><?php echo $this->traduire('E-mail du Webmestre'); ?></td> <td class="gauche"><input type="text" style="width:100%" name="mail_site" value="<?php echo $this->escape(trim($this->profil->getMailSite()));?>" maxlength="50"/></td> </tr> + + <tr> + <td class="droite"><?php echo $this->traduire('E-mail de réception des suggestions d\'achat'); ?></td> + <td class="gauche"><input type="text" style="width:100%" name="mail_suggestion_achat" value="<?php echo $this->escape(trim($this->profil->getMailSuggestionAchat()));?>" maxlength="50"/></td> + </tr> </table> </fieldset> diff --git a/library/Class/Profil.php b/library/Class/Profil.php index 0b2603d5488..c78bf8d0564 100644 --- a/library/Class/Profil.php +++ b/library/Class/Profil.php @@ -178,6 +178,7 @@ class Class_Profil extends Storm_Model_Abstract { 'en_pret' => 'En prêt']), 'hauteur_banniere' => 100, 'mail_site' => '', + 'mail_suggestion_achat' => '', 'skin' => 'original', 'largeur_site' => 1000, 'nb_divisions' => 3, @@ -1238,6 +1239,20 @@ class Class_Profil extends Storm_Model_Abstract { } + public function getMailSuggestionAchatOrPortail() { + if ($this->isPortail()) + return $this->getMailSuggestionAchat(); + + if ($this->hasMailSuggestionAchat()) + return $this->getMailSuggestionAchat(); + + if ($mail = $this->getLoader()->getPortail()->getMailSuggestionAchat()) + return $mail; + + return $this->getMailSiteOrPortail(); + } + + protected function _getIdModuleAtDivPosInCfg($div, $pos, $cfg_accueil) { $id_module = 0; $i = 0; diff --git a/library/Class/SuggestionAchat.php b/library/Class/SuggestionAchat.php index 7abee1466c4..0e3cfd20d32 100644 --- a/library/Class/SuggestionAchat.php +++ b/library/Class/SuggestionAchat.php @@ -90,7 +90,7 @@ class Class_SuggestionAchat extends Storm_Model_Abstract { if ($mail_user = $this->getUser()->getMail()) $mail->addTo($mail_user); - if ($mail_profil = Class_Profil::getCurrentProfil()->getMailSiteOrPortail()) + if ($mail_profil = Class_Profil::getCurrentProfil()->getMailSuggestionAchatOrPortail()) $mail->addTo($mail_profil); $mail->send(); diff --git a/tests/application/modules/admin/controllers/ProfilControllerTest.php b/tests/application/modules/admin/controllers/ProfilControllerTest.php index 9a3fb1dda0f..a133ca3265b 100644 --- a/tests/application/modules/admin/controllers/ProfilControllerTest.php +++ b/tests/application/modules/admin/controllers/ProfilControllerTest.php @@ -62,6 +62,7 @@ abstract class Admin_ProfilControllerProfilJeunesseTestCase extends Admin_Abstra ->setCfgSite(ZendAfi_Filters_Serialize::serialize($cfg_site)) ->setCfgNotice($cfg_notice) ->setMailSite('tintin@herge.be') + ->setMailSuggestionAchat('suggestion@herge.be') ->setHauteurBanniere(150) ->setBoiteLoginInBanniere(true); @@ -199,6 +200,13 @@ class Admin_ProfilControllerEditProfilJeunesseTest extends Admin_ProfilControlle $this->assertXPath("//select[@name='skin']/option[@value='modele'][@selected='selected']"); } + + /** @test */ + public function mailSuggestionAchatsShouldContainsSuggestionAtHergeDotBe() { + $this->assertXPath("//input[@type='text'][@name='mail_suggestion_achat'][@value='suggestion@herge.be']"); + } + + /** @test */ public function mailSiteShouldContainsTintinAtHergeDotBe() { $this->assertXPath("//input[@type='text'][@name='mail_site'][@value='tintin@herge.be']"); diff --git a/tests/application/modules/opac/controllers/BibNumeriqueControllerTest.php b/tests/application/modules/opac/controllers/BibNumeriqueControllerTest.php index b0f8a58d0f7..5cff3d34cba 100644 --- a/tests/application/modules/opac/controllers/BibNumeriqueControllerTest.php +++ b/tests/application/modules/opac/controllers/BibNumeriqueControllerTest.php @@ -163,7 +163,7 @@ class BibNumeriqueControllerAlbumPremierVolumeTestToJSON extends AbstractBibNume /** @test */ function firstRessourceNavigatorDownloadShouldBeUrlToDownloadRessource() { - $this->assertContains('/bib-numerique/download-resource/1', + $this->assertContains('/bib-numerique/download-resource/id/1', $this->json->album->ressources[0]->download); } diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index b8a9e8433b5..735dd0fd194 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -357,7 +357,6 @@ abstract class RechercheControllerSimpleActionTestCase extends AbstractControlle $recherche = $_SESSION['recherche']; $this->bootstrap(); $_SESSION['recherche'] = $recherche; - var_dump($_SESSION['recherche']); $this->dispatch('/recherche/simple', true); } } diff --git a/tests/library/Class/ProfilTest.php b/tests/library/Class/ProfilTest.php index 64a8deb5456..8f45f4cccb0 100644 --- a/tests/library/Class/ProfilTest.php +++ b/tests/library/Class/ProfilTest.php @@ -316,7 +316,8 @@ abstract class ProfilAdulteChatenayTestCase extends ModelTestCase { ->setLargeurDivision2(600) ->setLargeurDivision3(0) ->setCfgAccueil($cfg_accueil) - ->setAccessLevel('-1'); + ->setAccessLevel('-1') + ->setMailSuggestionAchat('chatenay@chatenay.fr'); } } @@ -540,6 +541,28 @@ class ProfilAdulteChatenayTest extends ProfilAdulteChatenayTestCase { ->methodHasBeenCalledWithParams('delete', array($this->page_histoire))); } + + + /** @test */ + public function pagePolitiqueMailSuggestionAchatShouldBeChatenayAtChatenayDotFr() { + $this->assertEquals('chatenay@chatenay.fr', $this->page_politique->getMailSuggestionAchatOrPortail()); + } + + + /** @test */ + public function withoutMailSuggestionAchatPagePolitiqueShouldGetOneFromPortail() { + Class_Profil::getPortail()->setMailSuggestionAchat('suggest@chatenay.fr'); + $this->profil->setMailSuggestionAchat(''); + $this->assertEquals('suggest@chatenay.fr', $this->page_politique->getMailSuggestionAchatOrPortail()); + } + + + /** @test */ + public function withoutMailSuggestionAchatqShouldGetMailSite() { + Class_Profil::getPortail()->setMailSuggestionAchat(''); + $this->profil->setMailSuggestionAchat('')->setMailSite('contact@chatenay.fr'); + $this->assertEquals('contact@chatenay.fr', $this->page_politique->getMailSuggestionAchatOrPortail()); + } } diff --git a/tests/library/Class/SuggestionAchatTest.php b/tests/library/Class/SuggestionAchatTest.php index b1c1cf2a926..f6cff39466f 100644 --- a/tests/library/Class/SuggestionAchatTest.php +++ b/tests/library/Class/SuggestionAchatTest.php @@ -35,7 +35,7 @@ abstract class SuggestionAchatTestCase extends Storm_Test_ModelTestCase { ->setId(1) ->setLibelle('PHP Unit') ->setTitreSite('PHP Unit') - ->setMailSite('laurent@afi-sa.fr'); + ->setMailSuggestionAchat('laurent@afi-sa.fr'); Class_Profil::setCurrentProfil($profil); $this->_suggestion = Class_SuggestionAchat::newInstanceWithId(2) @@ -138,7 +138,7 @@ class SuggestionAchatMailTest extends SuggestionAchatTestCase { class SuggestionAchatMailErrorsTest extends SuggestionAchatTestCase { /** @test */ public function withoutMailSiteShouldSendMailOnlyToUser() { - Class_Profil::getCurrentProfil()->setMailSite(''); + Class_Profil::getCurrentProfil()->setMailSuggestionAchat(''); $this->_suggestion->sendMail('noreply@astromelun.fr'); $this->assertEquals(['sbelle@gmail.com'], $this->_mock_transport->sent_mail->getRecipients()); -- GitLab