diff --git a/application/modules/opac/controllers/PanierController.php b/application/modules/opac/controllers/PanierController.php index 4b046b336c95f0c8ed7710b81f1cb6e8e3d83ce8..3585d3ec07b1ca0675c3afd08abbf61a7730fa37 100644 --- a/application/modules/opac/controllers/PanierController.php +++ b/application/modules/opac/controllers/PanierController.php @@ -127,7 +127,7 @@ class PanierController extends ZendAfi_Controller_Action { ->setPanierCourant($model) ->save(); - return true; + return $model->index(); } diff --git a/library/Class/PanierNotice.php b/library/Class/PanierNotice.php index 1a9b9521793c8fc4d55c65f16493ab64cfcf5baf..bd0bd05d8dcd25317fb5009f4a9655de474f0f2e 100644 --- a/library/Class/PanierNotice.php +++ b/library/Class/PanierNotice.php @@ -23,13 +23,13 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// class PanierNoticeLoader extends Storm_Model_Loader { - use Trait_Translator; + use Trait_Translator, Trait_TimeSource; public function newForUser($user) { return (new Class_PanierNotice()) - ->setLibelle($this->_('nouveau')) - ->setDateMaj(date('Y-m-d')) + ->setLibelle($this->_('Nouveau panier')) + ->setDateMaj($this->getCurrentDateTime()) ->setUser($user); } @@ -87,7 +87,7 @@ class PanierNoticeLoader extends Storm_Model_Loader { class Class_PanierNotice extends Storm_Model_Abstract { - use Trait_Translator, Trait_Indexable; + use Trait_Translator, Trait_Indexable, Trait_TimeSource; const NOTICES_SEPARATOR = ';'; @@ -235,7 +235,7 @@ class Class_PanierNotice extends Storm_Model_Abstract { $this->setIdabon($user->getIdabon()); if($this->hasChange()) - $this->setDateMaj(date('Y-m-d')); + $this->setDateMaj($this->getCurrentDateTime()); } diff --git a/library/Trait/TimeSource.php b/library/Trait/TimeSource.php index b119080a8a987dd81537a0d30dbb35f6badde529..5c2570cd49d675f4aa33c490a3c17f89d12d3c0a 100644 --- a/library/Trait/TimeSource.php +++ b/library/Trait/TimeSource.php @@ -42,6 +42,7 @@ trait Trait_TimeSource { return date('Y-m-d',self::getTimeSource()->time()); } + public static function getCurrentDateTime() { return date('Y-m-d H:i:s',self::getTimeSource()->time()); } diff --git a/library/ZendAfi/Form/Panier.php b/library/ZendAfi/Form/Panier.php index f84e1a6939f8d6e675323de3a53ba4803d1fb9c2..b99b74a8f947bd20faa9fef2db2e948f87e181a4 100644 --- a/library/ZendAfi/Form/Panier.php +++ b/library/ZendAfi/Form/Panier.php @@ -49,7 +49,7 @@ class ZendAfi_Form_Panier extends ZendAfi_Form { protected function addDomainSettings() { - if(!Class_Users::getIdentity()->canAccessBackend()) + if(!Class_Users::getIdentity()->hasRightAccessDomaines()) return $this; return $this diff --git a/library/ZendAfi/View/Helper/ListeNotices/TableauPanier.php b/library/ZendAfi/View/Helper/ListeNotices/TableauPanier.php index 22156db922023615bb30a90a9af7410d463793e5..9ea3d401f73df4d4177f797ea9658d76e58e9541 100644 --- a/library/ZendAfi/View/Helper/ListeNotices/TableauPanier.php +++ b/library/ZendAfi/View/Helper/ListeNotices/TableauPanier.php @@ -53,7 +53,7 @@ class ZendAfi_View_Helper_ListeNotices_TableauPanier extends ZendAfi_View_Helper .'<td>'.$notice->getAuteurPrincipal().'</td>' .'<td class="supprimer" style="text-align:center">' .'<a href="'.$this->view->url(['controller' => 'panier', - 'action' => 'paniersupprimernotice', + 'action' => 'delete-record', 'id_panier' => $id_panier, 'id_notice' => $notice->getId(), 'redirect' => 'referer'], null, true).'" onclick="return confirm(\''.$this->view->_("Etes-vous sûr de vouloir supprimer cette notice du panier ?").'\')"> </a>' diff --git a/tests/application/modules/opac/controllers/PanierControllerTest.php b/tests/application/modules/opac/controllers/PanierControllerTest.php index 497f9d89a097c6c8dae9f2471566539e47d0ed23..73a9e8b04b545d7bc996997b649f4310ce23ea5b 100644 --- a/tests/application/modules/opac/controllers/PanierControllerTest.php +++ b/tests/application/modules/opac/controllers/PanierControllerTest.php @@ -21,31 +21,27 @@ require_once 'AbstractControllerTestCase.php'; abstract class PanierControllerSimpleLoggedUserTestCase extends AbstractControllerTestCase { - protected $user; + protected $_storm_default_to_volatile = true, + $user; + public function setUp() { parent::setUp(); - Class_Users::beVolatile(); - Class_UserGroup::beVolatile(); - Class_UserGroupMembership::beVolatile(); - Class_Notice::beVolatile(); - Class_PanierNotice::beVolatile(); - Class_PanierNoticeCatalogue::beVolatile(); - - $this->user = Class_Users::newInstanceWithId(23, ['pseudo' => 'zorn', - 'nom' => 'john', - 'login' => 'jzorn', - 'password' => '123']); + $this->user = $this->fixture('Class_Users', + ['id' => 23, + 'pseudo' => 'zorn', + 'nom' => 'john', + 'login' => 'jzorn', + 'password' => '123']); - $this->user->save(); ZendAfi_Auth::getInstance()->logUser($this->user); - } - protected function initNoticeBlackSad() { - $blacksad = Class_Notice::newInstanceWithId(12, ['titre_principal' => 'Blacksad', - 'clef_alpha' => 'BLACKSAD']); - $blacksad->save(); + protected function initNoticeBlackSad() { + $blacksad = $this->fixture('Class_Notice', + ['id' => 12, + 'titre_principal' => 'Blacksad', + 'clef_alpha' => 'BLACKSAD']); } } @@ -59,64 +55,57 @@ abstract class PanierControllerTestCase extends AbstractControllerTestCase { parent::setUp(); $this->manon = $this->fixture('Class_Users', [ - 'id' => 23, - 'pseudo' => 'ManonL', - 'nom' => 'Afond', - 'login' => 'man', - 'password' => '123']); + 'id' => 23, + 'pseudo' => 'ManonL', + 'nom' => 'Afond', + 'login' => 'man', + 'password' => '123']); ZendAfi_Auth::getInstance()->logUser($this->manon); $group = $this->fixture('Class_UserGroup', [ - 'id' => 280, - 'libelle' => 'Referent', - 'users' => [$this->manon], - 'rights' => []]); + 'id' => 280, + 'libelle' => 'Referent', + 'users' => [$this->manon], + 'rights' => []]); $this->panier_bd = $this->fixture('Class_PanierNotice', [ - 'id' => 2, - 'id_panier' => 1, - 'libelle' => 'Mes BD', - 'date_maj' => '10/02/2011', - 'notices' => 'COMBAT ORDINAIRE;BLACKSAD', - 'user' => $this->manon]); + 'id' => 2, + 'id_panier' => 1, + 'libelle' => 'Mes BD', + 'date_maj' => '10/02/2011', + 'notices' => 'COMBAT ORDINAIRE;BLACKSAD', + 'user' => $this->manon]); $this->panier_orphelin = $this->fixture('Class_PanierNotice', [ - 'id' => 9995, - 'libelle' => 'Orphelin', - 'date_maj' => '25/05/2010', - 'user' => null]); + 'id' => 9995, + 'libelle' => 'Orphelin', + 'date_maj' => '25/05/2010', + 'user' => null]); $this->panier_romans = $this->fixture('Class_PanierNotice', [ - 'id' => 15, - 'id_panier' => 2, - 'libelle' => 'Mes Romans', - 'date_maj' => '25/05/2010', - 'notices' => 'MONTESPAN', - 'user' => $this->manon]); + 'id' => 15, + 'id_panier' => 2, + 'libelle' => 'Mes Romans', + 'date_maj' => '25/05/2010', + 'notices' => 'MONTESPAN', + 'user' => $this->manon]); $montespan = $this->fixture('Class_Notice', [ - 'id' => 4, - 'titre_principal' => 'Le Montespan', - 'auteur_principal' => 'Jean Teulテδゥ', - 'clef_alpha' => 'MONTESPAN', - 'unimarc' => '00445nam0 2200181 450 0010008000000100028000081000041000361010008000771020007000851050018000922000032001102100026001422150038001687000022002068010022002289020007002509030006002570507356 a978-2-260-01723-3d22 ? a20080612d|||| uuuy0frey0103 ba| afre aFR ay|||||||000|y1 aMontespan (Le)fJean Teulテδゥ aPariscJulliardd2008 a333 p.cjaq. ill. en coul.d21 cm 1aTeulテδゥbJean4070 0aFRbBMVc20080612 arh aG']); + 'id' => 4, + 'titre_principal' => 'Le Montespan', + 'auteur_principal' => 'Jean Teulテδゥ', + 'clef_alpha' => 'MONTESPAN', + 'unimarc' => '00445nam0 2200181 450 0010008000000100028000081000041000361010008000771020007000851050018000922000032001102100026001422150038001687000022002068010022002289020007002509030006002570507356 a978-2-260-01723-3d22 ? a20080612d|||| uuuy0frey0103 ba| afre aFR ay|||||||000|y1 aMontespan (Le)fJean Teulテδゥ aPariscJulliardd2008 a333 p.cjaq. ill. en coul.d21 cm 1aTeulテδゥbJean4070 0aFRbBMVc20080612 arh aG']); $combat_ordinaire = $this->fixture('Class_Notice', [ - 'id' => 10, - 'titre_principal' => 'Le combat ordinaire', - 'clef_alpha' => 'COMBAT ORDINAIRE']); + 'id' => 10, + 'titre_principal' => 'Le combat ordinaire', + 'clef_alpha' => 'COMBAT ORDINAIRE']); $blacksad = $this->fixture('Class_Notice', [ - 'id' => 12, - 'titre_principal' => 'Blacksad', - 'clef_alpha' => 'BLACKSAD']); - - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice') - ->whenCalled('findAllBy') - ->with(['clef_alpha' => ['MONTESPAN'], - 'order' => 'FIELD(clef_alpha, "MONTESPAN")']) - ->answers([$montespan]); - + 'id' => 12, + 'titre_principal' => 'Blacksad', + 'clef_alpha' => 'BLACKSAD']); $panier_domaine_histoire = $this->fixture('Class_PanierNoticeCatalogue', ['id' => 71]); @@ -164,11 +153,11 @@ class PanierControllerIndexActionWithTextReplacmentsTest extends PanierControlle parent::setUp(); Class_AdminVar::newInstanceWithId('TEXT_REPLACEMENTS', ['valeur' => implode("\n", - ['Mes paniers de documents;Votre sélection de documents', - ' ', - ' panier ; sélection;', - 'erreur', - 'Afficher en résultat de recherche;L\'afficher en recherche'] + ['Mes paniers de documents;Votre sélection de documents', + ' ', + ' panier ; sélection;', + 'erreur', + 'Afficher en résultat de recherche;L\'afficher en recherche'] )]); Class_TextReplacements::reset(); $this->dispatch('/opac/panier', true); @@ -253,12 +242,12 @@ class PanierControllerAsSimpleUserActionTest extends PanierControllerSimpleLogge $this->user->changeRoleTo(ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL); $this->user->save(); ZendAfi_Auth::getInstance()->logUser($this->user); - $panier_bd_user = Class_PanierNotice::newInstanceWithId(200, - [ - 'libelle' => 'Mes BD', - 'date_maj' => '10/02/2011', - 'notices' => 'COMBAT ORDINAIRE;BLACKSAD', - 'user' => $this->user]); + $panier_bd_user = $this->fixture('Class_PanierNotice', + ['id' => 200, + 'libelle' => 'Mes BD', + 'date_maj' => '10/02/2011', + 'notices' => 'COMBAT ORDINAIRE;BLACKSAD', + 'user' => $this->user]); $panier_bd_user->save(); $this->dispatch('/opac/panier', true); @@ -485,7 +474,7 @@ class PanierControllerOtherUserSecurityTest extends PanierControllerTestCase { /** @test */ public function editMarkusShouldBeForbidden() { - $this->postDispatch('/panier/edit/id_panier/39/', ['new_libelle' => 'crack']); + $this->postDispatch('/panier/edit/id_panier/39/', ['libelle' => 'crack']); Class_PanierNotice::clearCache(); $this->assertEquals('panier Markus', Class_PanierNotice::find(39)->getLibelle()); } @@ -502,7 +491,7 @@ class PanierControllerAjoutNoticeBlackSadToUndefinedPanierTest extends PanierCon $this->user->setIdabon('088888'); $this->initNoticeBlackSad(); $this->postDispatch('/panier/add-record-ajax/id_notice/12', [], true); - $this->_new_panier = Class_PanierNotice::findFirstBy(['libelle' => 'nouveau']); + $this->_new_panier = Class_PanierNotice::findFirstBy(['libelle' => 'Nouveau panier']); } @@ -528,12 +517,6 @@ class PanierControllerAjoutNoticeBlackSadToUndefinedPanierTest extends PanierCon public function idPanierShouldBe088888() { $this->assertEquals('088888', $this->_new_panier->getIdabon()); } - - - /** @test */ - public function libellePanierShouldBePanierNo0() { - $this->assertEquals('nouveau', $this->_new_panier->getLibelle()); - } } @@ -573,14 +556,13 @@ class PanierControllerAjoutNoticeBlackSadToPanierMesRomansTest extends PanierCon class PanierControllerAjoutUnknownNoticeToPanierMesRomansTest extends PanierControllerTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/panier/add-record-ajax/id_panier/15/id_notice/-1', true); } /** @test */ - public function responseShouldRedirectToIndex() { - $this->assertRedirectTo('/opac/panier/index'); + public function popupWithErrorMessageShouldBeReturn() { + $this->assertContains('Veuillez choisir une notice', $this->_response->getBody()); } } @@ -610,7 +592,7 @@ class PanierControllerModifierTitrePanierMesRomansToMesLivresTest extends Panier parent::setUp(); $this->postDispatch('/panier/edit/id_panier/15', - ['new_libelle' => 'Mes livres'], + ['libelle' => 'Mes livres'], true); Class_PanierNotice::clearCache(); } @@ -619,7 +601,7 @@ class PanierControllerModifierTitrePanierMesRomansToMesLivresTest extends Panier /** @test */ public function responseShouldRedirectToIndex() { - $this->assertRedirectTo('/opac/panier/index/id_panier/15'); + $this->assertRedirect(); } @@ -686,7 +668,7 @@ class PanierControllerModifierCataloguePanierWithoutDomainesTest extends PanierC $this->panier_romans->setCatalogues([Class_Catalogue::find(97)]); $this->postDispatch('/panier/edit/id_panier/15', - ['new_libelle' => 'Mes supers romans', + ['libelle' => 'Mes supers romans', 'domaine_ids' => ''], true); } @@ -720,8 +702,8 @@ class PanierControllerExportUnimarcTest extends PanierControllerTestCase { /** @test */ public function bodyShouldReturnUnimarcISO2709() { $this->assertSame( - '00457nam0 22001811 450 0010008000000100028000081000041000361010008000771020007000851050018000922000038001102100026001482150038001747000028002128010022002409020007002629030006002690507356 a978-2-260-01723-3d22 ? a20080612d|||| uuuy0frey0103 ba| afre aFR ay|||||||000|y1 aMontespan (Le)fJean Teulテδゥ aPariscJulliardd2008 a333 p.cjaq. ill. en coul.d21 cm 1aTeulテδゥbJean4070 0aFRbBMVc20080612 arh aG', - $this->_response->getBody()); + '00457nam0 22001811 450 0010008000000100028000081000041000361010008000771020007000851050018000922000038001102100026001482150038001747000028002128010022002409020007002629030006002690507356 a978-2-260-01723-3d22 ? a20080612d|||| uuuy0frey0103 ba| afre aFR ay|||||||000|y1 aMontespan (Le)fJean Teulテδゥ aPariscJulliardd2008 a333 p.cjaq. ill. en coul.d21 cm 1aTeulテδゥbJean4070 0aFRbBMVc20080612 arh aG', + $this->_response->getBody()); } @@ -830,15 +812,9 @@ class PanierControllerAjoutAjaxLoggedManonWithoutPanierTest extends PanierContro } - /** @test **/ - public function withOutPanierActionShouldForwardToCreatePanier() { - $this->assertXPath('//form[contains(@action,"panier/creer-panier-ajax")]',$this->_response->getBody()); - } - - /** @test */ - public function hiddenInputShouldContainsRedirectUrl() { - $this->assertXPath('//input[@type="hidden"][@name="redirect"][contains(@value, "/panier/add-record-ajax/id_notice/4")]'); + public function shouldContainsNouveauPanier() { + $this->assertXPathContentContains('//div', 'Nouveau panier'); } } @@ -877,19 +853,19 @@ class PanierControllerAjoutAjaxLoggedManonWithPanierTest extends PanierControlle /** @test **/ public function htmlShouldContainsLeMontespan() { - $this->assertXPathContentContains('//strong','Montespan (Le)'); + $this->assertXPathContentContains('//b','Montespan (Le)'); } /** @test **/ public function htmlShouldContainsTerminator() { - $this->assertXPathContentContains('//strong','Terminator',$this->_response->getBody()); + $this->assertXPathContentContains('//b','Terminator',$this->_response->getBody()); } /** @test **/ public function htmlShouldContainsLinkToCreerNouveauPanier() { - $this->assertXPath('//a[contains(@href,"panier/creer-panier-ajax/id_notice/4")]'); + $this->assertXPath('//a[contains(@href,"panier/add")]'); } @@ -900,7 +876,7 @@ class PanierControllerAjoutAjaxLoggedManonWithPanierTest extends PanierControlle /** @test */ public function titleShouldBeAjouterUneNoticeAuPanier() { - $this->assertXPathContentContains('//title', 'Ajouter une notice au panier'); + $this->assertXPathContentContains('//title', 'Ajouter un document dans un panier'); } } @@ -947,10 +923,8 @@ class PanierControllerCreerPanierLoggedTest extends PanierControllerTestCase { class PanierControllerCreerPanierPostTest extends PanierControllerTestCase { public function setUp() { parent::setUp(); - $this->manon->setPaniers([]); - $this->postDispatch('/panier/add', - ['titre'=>'Par ici les bons livres']); + ['libelle'=>'Par ici les bons livres']); } @@ -1076,9 +1050,9 @@ class PanierControllerAjouterNoticeDansBoitePanierTest extends AbstractControlle Class_PanierNotice::beVolatile(); Class_PanierNoticeCatalogue::beVolatile(); $this->manon = Class_Users::newInstanceWithId(2377, ['pseudo' => 'ManonL', - 'nom' => 'Afond', - 'login' => 'man', - 'password' => '123']); + 'nom' => 'Afond', + 'login' => 'man', + 'password' => '123']); $this->manon->changeRoleTo(ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL); $this->manon->save(); @@ -1099,27 +1073,27 @@ class PanierControllerAjouterNoticeDansBoitePanierTest extends AbstractControlle /** @test */ public function contextShouldExpectation() { - $this->fixture('Class_PanierNotice', - ['id' => 1, - 'titre' => 'my cart', - 'user' => Class_Users::getIdentity()]); - - $this->postDispatch('/panier/add-record-ajax/id_notice/4/id_panier/1', ['id_notice' => 4, - 'id_panier' => 1]); + $panier = $this->fixture('Class_PanierNotice', + ['id' => 1, + 'titre' => 'my cart', + 'user' => Class_Users::getIdentity()]); + Class_Users::getIdentity()->setPanierCourant($panier); + $this->postDispatch('/panier/add-record-ajax/id_notice/4', [], true); $this->assertEquals([Class_Notice::find(4)], Class_PanierNotice::find(1)->getNoticesAsArray()); } /** @test */ - public function newPanierShouldNotHaveBeenCreated() { - $this->postDispatch('/panier/add-record-ajax/id_notice/4', ['id_panier' => '0']); - $this->assertEmpty(Class_PanierNotice::find(1)); + public function newPanierShouldHaveBeenCreated() { + $this->postDispatch('/panier/add-record-ajax/id_notice/4', []); + $this->assertNotEmpty(Class_PanierNotice::find(1)); } + /** @test */ - public function responseShouldRedirectToIndex() { + public function responseShouldContainsSuccess() { $this->postDispatch('/panier/add-record-ajax/id_notice/4', ['id_panier' => '0']); - $this->assertRedirectTo('/index'); + $this->assertContains('<p>Le document <b>Le Montespan<\/b> a \u00e9t\u00e9 ajout\u00e9 au panier <b>Nouveau panier<\/b><\/p>', $this->_response->getBody()); } } @@ -1131,9 +1105,9 @@ class PanierControllerAjoutAjaxSuccessTest extends PanierControllerSimpleLoggedU parent::setup(); $this->initNoticeBlackSad(); $panier =Class_PanierNotice::newInstanceWithId(39, - ['libelle' => 'panier Markus', - 'user' => Class_Users::newInstanceWithId(98, ['nom' => 'Markus']), - 'date_maj' => '19/01/2013']); + ['libelle' => 'panier Markus', + 'user' => Class_Users::newInstanceWithId(98, ['nom' => 'Markus']), + 'date_maj' => '19/01/2013']); $panier->save(); $this->_xpath = new Storm_Test_XPath(); @@ -1157,11 +1131,12 @@ class PanierControllerAjoutAjaxSuccessTest extends PanierControllerSimpleLoggedU 'preferences' => ['titre' => 'Mon panier']]]]; Class_Profil::getCurrentProfil()->setCfgAccueil($cfg_accueil); - $this->postDispatch('/panier/add-record-ajax', ['id_notice' => 12, - 'id_panier' => 39], + $this->postDispatch('/panier/add-record-ajax/id_notice/12', + [], true); + $this->_json = json_decode($this->_response->getbody()); - $this->_xpath->assertXPathContentContains($this->_json->content,'//script',"$('.boite.panier').reload('http://"); + $this->_xpath->assertXPathContentContains($this->_json->content,'//script','$(".boite.panier").reload("http://'); } } @@ -1178,7 +1153,7 @@ class PanierControllerSelectPanierCourantActionTest extends AbstractControllerTe $this->dispatch('/panier/select-panier-courant/id_panier/39', true); $this->assertXPath('//input[@type="hidden"][@name="id_new_panier"][@value="39"]'); - } + } /** @test **/ @@ -1200,9 +1175,9 @@ class PanierControllerEditActionAsAbonneTest extends AbstractControllerTestCase Class_PanierNotice::beVolatile(); $roger = Class_Users::newInstanceWithId(23, ['pseudo' => 'RogerL', - 'nom' => 'plou', - 'login' => 'man', - 'password' => '123']); + 'nom' => 'plou', + 'login' => 'man', + 'password' => '123']); $roger->beAbonneSIGB(); $roger->save(); @@ -1262,7 +1237,7 @@ class PanierControllerEditActionAsAdminTest extends AbstractControllerTestCase { /** @test **/ public function editLibelleShouldBeFillWithMesLivresWhenLogAsModoPortail() { - $this->assertXPath('//input[@name="new_libelle"][@value="Mes Livres"]',$this->_response->getBody()); + $this->assertXPath('//input[@name="libelle"][@value="Mes Livres"]',$this->_response->getBody()); } @@ -1288,19 +1263,22 @@ class PanierControllerEditActionAsContributeurWithOutRightForAccessDomaineTest e public function setup() { parent::setup(); - $roger = Class_Users::newInstanceWithId(23, ['pseudo' => 'RogerL', - 'nom' => 'plou', - 'login' => 'man', - 'password' => '123']); + $roger = $this->fixture('Class_Users', + ['id' => 23, + 'pseudo' => 'RogerL', + 'nom' => 'plou', + 'login' => 'man', + 'password' => '123']); $roger->changeRoleTo(ZendAfi_Acl_AdminControllerRoles::MODO_BIB); $roger->setUserGroups([]); $roger->save(); - $mes_livres = Class_PanierNotice::newInstanceWithId(465,['libelle' => 'Mes Livres', - 'date_maj' => '10/02/2011', - 'user' => $roger]); - $mes_livres->save(); + $mes_livres = $this->fixture('Class_PanierNotice', + ['id' => 465, + 'libelle' => 'Mes Livres', + 'date_maj' => '10/02/2011', + 'user' => $roger]); ZendAfi_Auth::getInstance()->logUser($roger); @@ -1309,7 +1287,7 @@ class PanierControllerEditActionAsContributeurWithOutRightForAccessDomaineTest e /** @test **/ public function editLibelleShouldBeFillWithMesLivresWhenLogAsModoBib() { - $this->assertXPath('//input[@name="new_libelle"][@value="Mes Livres"]',$this->_response->getBody()); + $this->assertXPath('//input[@name="libelle"][@value="Mes Livres"]',$this->_response->getBody()); } @@ -1323,7 +1301,6 @@ class PanierControllerEditActionAsContributeurWithOutRightForAccessDomaineTest e public function inputIdDomaineShouldBeDisplayWithOutRightForAccessDomaine() { $this->assertNotXPath('//input[@type="hidden"][@name="domaine_ids"]',$this->_response->getBody()); } - } @@ -1339,17 +1316,6 @@ class PanierControllerCreerPanierAjaxActionTest extends AbstractControllerTestCa public function creerPanierAjaxShouldContainsInputNewLibelle() { $this->assertXPath('//input[@name="libelle"]'); } - - - /** @test **/ - public function creerPanierAjaxShouldContainsInputHiddenRedirect() { - $this->assertXPath('//input[@type="hidden"][contains(@value,"/panier/add-record-ajax/id_notice/4")]',$this->_response->getBody()); - } - - /** @test */ - public function titleShouldBeNouveauPanier() { - $this->assertXPathContentContains('//title', 'Nouveau panier'); - } } @@ -1373,7 +1339,7 @@ class PanierControllerCreerPanierAjaxPostActionTest extends AbstractControllerTe Class_Catalogue::newInstanceWithId(78, ['libelle' => 'Loisirs'])]); $this->postDispatch('panier/add-ajax',['libelle' => 'Mes livres', - 'domaine_ids' => '45-56-78']); + 'domaine_ids' => '45-56-78']); $this->assertEquals('45;56;78',Class_Users::getIdentity()->getPanierCourant()->getDomaineIds()); } @@ -1514,7 +1480,7 @@ class PanierControllerIndexedByEditActionTest extends PanierControllerTestCase { public function setUp() { parent::setUp(); $this->postDispatch('/panier/edit/id_panier/15', - ['new_libelle' => 'Mes supers romans', + ['libelle' => 'Mes supers romans', 'domaine_ids' => '97-199'], true); } @@ -1565,7 +1531,7 @@ class PanierControllerDesindexedByMajTitreTest extends PanierControllerTestCase 'panier_id' => 15]); $this->postDispatch('/panier/edit/id_panier/15', - ['new_libelle' => 'Mes supers romans', + ['libelle' => 'Mes supers romans', 'domaine_ids' => '1789'], true); } @@ -1584,12 +1550,13 @@ class PanierControllerDesindexedByMajTitreTest extends PanierControllerTestCase /** @test */ - public function mesSupersRomainsShouldBeIndexedInDomain456() { + public function mesSupersRomainsShouldBeIndexedInDomain1789() { $this->assertEquals($this->panier_romans, Class_NoticeDomain::findFirstBy(['domain_id' => 1789])->getPanierNotice()); } } + abstract class PanierControllerUnindexTestCase extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true; @@ -1735,14 +1702,14 @@ class PanierControllerSavePanierTest extends AbstractControllerTestCase { parent::setUp(); $panier_one = $this->fixture('Class_PanierNotice', - ['id' => 1, - 'id_user' => 1, - 'date_maj' => '2014-10-10']); + ['id' => 1, + 'id_user' => 1, + 'date_maj' => '2014-10-10']); $panier_two = $this->fixture('Class_PanierNotice', - ['id' => 2, - 'id_user' => 1, - 'date_maj' => '2014-11-10']); + ['id' => 2, + 'id_user' => 1, + 'date_maj' => '2014-11-10']); $this->fixture('Class_Notice', ['id' => 1, @@ -1753,7 +1720,9 @@ class PanierControllerSavePanierTest extends AbstractControllerTestCase { 'login' => 'Paul', 'password' => 'Marrant']); - $user = Class_Users::find(1)->setPaniers([$panier_one, $panier_two]); + $user = Class_Users::find(1) + ->setPaniers([$panier_one, $panier_two]) + ->setPanierCourant($panier_one); $user->save(); ZendAfi_Auth::getInstance()->logUser($user); @@ -1772,9 +1741,10 @@ class PanierControllerSavePanierTest extends AbstractControllerTestCase { $this->assertEquals(date('Y-m-d'), Class_PanierNotice::find(1)->getDateMaj()); } + /** @test */ public function responseShouldContainsAjaxSucessJson() { - $this->assertContains('<div class=\"ajout-result\"><span>La notice Pomme a bien \u00e9t\u00e9 ajout\u00e9e au panier <\/span>\n <a href=\"\/panier\/index\/id_panier\/1#panier_contenu\">Voir le panier<\/a>\n <a href=\"#\" onclick=\"opacDialogClose();return false\">Fermer<\/a>\n<\/div>\n', $this->_response->getBody()); + $this->assertContains('<div class=\"ajout-result\"><p>Le document <b>Pomme<\/b> a \u00e9t\u00e9 ajout\u00e9 au panier <b><\/b><\/p><a href=\"\/panier\/index\/id_panier\/1#panier_contenu\">Acc\u00e9der au panier <b><\/b><\/a><\/div>', $this->_response->getBody()); } } @@ -1793,7 +1763,7 @@ class PanierControllerAddActionTest extends AbstractControllerTestCase { } -/** @test */ + /** @test */ public function onlyOneSelectionShouldHaveBeenCreated() { $this->assertCount(1, Class_PanierNotice::findAll()); } diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index c524a1aca74ab6e19d2cf0509832ac77d224a904..696fcb1603019fcb182a41d03787ef8679859b46 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -2285,29 +2285,29 @@ class RechercheControllerGuideeThesaurusTest extends RechercheControllerGuideeH -class RechercheControllerAjoutNoticePanierUrlWithMurConfigTest extends RechercheControllerSimpleActionListeFormatTestCase { +class RechercheControllerAjoutNoticePanierUrlMurTest extends RechercheControllerSimpleActionListeFormatTestCase { protected $_liste_format = Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR; + public function setUp() { parent::setUp(); - $this->dispatch('/recherche/simple/expressionRecherche/potter/facettes/T1/facette/B1/page/2', true); ZendAfi_Auth::getInstance()->clearIdentity(); - Class_Profil::getCurrentProfil()->setCfgModules([]); - - $this->dispatch('/recherche/simple/expressionRecherche/pomme/tri/alpha_auteur/ajoutPanier/702167',true); - + $this->dispatch('/recherche/simple/expressionRecherche/pomme/tri/alpha_auteur',true); } + /** @test */ public function pommeShouldBePresentInRedirectedPageAsResultatInSession() { $this->assertXPathContentContains('//div', 'pomme'); } + /** @test */ public function correctPunctuationSpacesShouldBeDisplayed() { $this->assertXPathContentContains('//span',"pour : "); } + /** @test */ public function pageShouldContainsLinkToSuggestionAchats() { $this->assertXPathContentContains('//a[contains(@href, "/abonne/suggestion-achat")]', @@ -2321,6 +2321,7 @@ class RechercheControllerAjoutNoticePanierUrlWithMurConfigTest extends Recherche } + /** @test */ public function withOutLoggedUserPopupLoginShouldBeInitialized() { $this->assertXPathContentContains('//script', 'initializePopups'); @@ -2329,13 +2330,7 @@ class RechercheControllerAjoutNoticePanierUrlWithMurConfigTest extends Recherche /** @test */ public function linksAjoutPanierShouldHaveDataPopupTrue() { - $this->assertXPath('//a[contains(@href, "/panier/ajout-ajax/id_notice/")][@data-popup="true"]',$this->_response->getBody()); - } - - - /** @test **/ - public function permalinkShouldBeDisplay() { - $this->assertXPath('//img[contains(@class, "permalink")][contains(@data-url, "recherche/viewnotice/expressionRecherche/potter/facettes/T1/facette/B1/page/2/")]'); + $this->assertXPath('//a[contains(@href, "/panier/add-record-ajax/id_notice/")][@data-popup="true"]',$this->_response->getBody()); } @@ -2348,6 +2343,25 @@ class RechercheControllerAjoutNoticePanierUrlWithMurConfigTest extends Recherche +class RechercheControllerPermalinkMurTest extends RechercheControllerSimpleActionListeFormatTestCase { + protected $_liste_format = Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR; + + + public function setUp() { + parent::setUp(); + ZendAfi_Auth::getInstance()->clearIdentity(); + $this->dispatch('/recherche/simple/expressionRecherche/potter/facettes/T1/facette/B1/page/2', true); + } + + + /** @test **/ + public function permalinkShouldBeDisplay() { + $this->assertXPath('//img[contains(@class, "permalink")][contains(@data-url, "recherche/viewnotice/expressionRecherche/potter/facettes/T1/facette/B1/page/2/")]'); + } +} + + + class RechercheControllerNavigationTest extends RechercheControllerNoticeTestCase { public function setUp(){ parent::setUp(); diff --git a/tests/library/Class/PanierNoticeTest.php b/tests/library/Class/PanierNoticeTest.php index d77dea6f6978d0f0b9edd119aa97529fc21594ce..bee262b2c6110c983690cf76b3f5d88f030e24f0 100644 --- a/tests/library/Class/PanierNoticeTest.php +++ b/tests/library/Class/PanierNoticeTest.php @@ -333,7 +333,7 @@ class NewPanierNoticeForUserTest extends Storm_Test_ModelTestCase { /** @test */ public function newPanierShouldBeNamedPanierNo6() { - $this->assertEquals('nouveau', Class_PanierNotice::find(6)->getLibelle()); + $this->assertEquals('Nouveau panier', Class_PanierNotice::find(6)->getLibelle()); } diff --git a/tests/library/ZendAfi/View/Helper/Accueil/PanierTest.php b/tests/library/ZendAfi/View/Helper/Accueil/PanierTest.php index 7ea687aaa274525c15191625a682195068bc730f..1fa6b0aab7fc269ccc49896028ca5f0b7e815a10 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/PanierTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/PanierTest.php @@ -163,7 +163,7 @@ class PanierTestWithConnectedUserAndCurrentPanierWithNotice extends PanierTestWi /** @test **/ public function rowShouldContainsDelAction() { - $this->assertXPath($this->_html, '//tbody/tr//a[contains(@href,"/delete-record/id_panier/987/id_notice/18/redirect/referer")]'); + $this->assertXPath($this->_html, '//tbody/tr//a[contains(@href,"/delete-record/id_panier/987/id_notice/18")]', $this->_html); } diff --git a/tests/library/ZendAfi/View/Helper/Notice/MurTest.php b/tests/library/ZendAfi/View/Helper/Notice/MurTest.php index 23f2db51d2b031e559c1fabea1c2bac4ff7fad38..35082fbcd328d8e11ef8a72f0234fdc4ed77ef0a 100644 --- a/tests/library/ZendAfi/View/Helper/Notice/MurTest.php +++ b/tests/library/ZendAfi/View/Helper/Notice/MurTest.php @@ -227,7 +227,7 @@ class ZendAfi_View_Helper_Notice_Mur_BarreDeLienTest extends ZendAfi_View_Helper /** @test */ public function barreDeLienShouldContainUrlAjoutPanier() { - $this->assertXPath($this->_html, '//a[contains(@data-action, "panier/ajout-ajax/id_notice/34")]', $this->_html); + $this->assertXPath($this->_html, '//a[contains(@href, "panier/add-record-ajax/id_notice/34")]', $this->_html); }