diff --git a/.gitattributes b/.gitattributes index d0445c24bc2ddd1a10add95671a45e1bdde5d632..300f7f8ff8ec345babab52dd8f11973bc6fbefdd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6136,6 +6136,7 @@ tests/library/ZendAfi/View/Helper/TagBanniereTest.php -text tests/library/ZendAfi/View/Helper/TagCVSCriteresRechercheTest.php -text tests/library/ZendAfi/View/Helper/TagCoursToutApprendreTest.php -text tests/library/ZendAfi/View/Helper/TagImgTest.php -text +tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php -text tests/library/ZendAfi/View/Helper/TagSlideshowTest.php -text tests/library/ZendAfi/View/Helper/TagUploadMultipleTest.php -text tests/library/ZendAfi/View/Helper/TagUploadTest.php -text diff --git a/application/modules/admin/controllers/AccueilController.php b/application/modules/admin/controllers/AccueilController.php index d34ca12c4478616366ff0b1c0dbfc93f4c0bf25d..0eae7f4d20854ca6554910e45871f8bc69350fe0 100644 --- a/application/modules/admin/controllers/AccueilController.php +++ b/application/modules/admin/controllers/AccueilController.php @@ -92,6 +92,11 @@ class Admin_AccueilController extends Zend_Controller_Action { public function rechsimpleAction() { + $this->view->liste_profils_redirect = ['' => '']; + $top_profils = Class_Profil::findTopProfils(); + foreach($top_profils as $profil) + $this->view->liste_profils_redirect[$profil->getId()] = $profil->getLibelle(); + $this->_simpleAction(); } diff --git a/application/modules/admin/views/scripts/accueil/rechsimple.phtml b/application/modules/admin/views/scripts/accueil/rechsimple.phtml index 5e916c0634e8be8377454d14354235887cd21680..e1c44777db24c72a78c4b1a0f1407306047ba3fb 100644 --- a/application/modules/admin/views/scripts/accueil/rechsimple.phtml +++ b/application/modules/admin/views/scripts/accueil/rechsimple.phtml @@ -86,6 +86,17 @@ </td> </tr> + + <tr> + <td class="droite">Basculer automatiquement sur le profil: </td> + <td class="gauche"> + <?php echo $this->formSelect('profil_redirect', + $this->preferences['profil_redirect'], + '', + $this->liste_profils_redirect); ?> + </td> + </tr> + </table> </fieldset> diff --git a/library/Class/Codification.php b/library/Class/Codification.php index ae561fb8a1c78bba79d181b0e755dea634b500c0..08852366684c04bad38753f652d9832ff33888d5 100644 --- a/library/Class/Codification.php +++ b/library/Class/Codification.php @@ -85,10 +85,10 @@ class Class_Codification { //------------------------------------------------------------------------------------------------------ // Retourne libelle correspondant à un code facette //------------------------------------------------------------------------------------------------------ - function getLibelleFacette($rubrique) - { + function getLibelleFacette($rubrique) { $type=$rubrique[0]; - $id=substr($rubrique,1); + if (!$id=substr($rubrique,1)) + return ''; switch($type) { diff --git a/library/Class/Systeme/ModulesAccueil/RechercheSimple.php b/library/Class/Systeme/ModulesAccueil/RechercheSimple.php index d7a5ff282a49d8f112bc98935f230f7309078d23..e273cf40c558271a375bd2328415c1b6ec259e91 100644 --- a/library/Class/Systeme/ModulesAccueil/RechercheSimple.php +++ b/library/Class/Systeme/ModulesAccueil/RechercheSimple.php @@ -48,7 +48,8 @@ class Class_Systeme_ModulesAccueil_RechercheSimple extends Class_Systeme_Modules 'largeur' => 140, // du champ de saisie 'recherche_avancee' => 1, //afficher le lien recherche avancée, 'type_doc' => 0, // filtre du type de doc - 'tri' => '*' + 'tri' => '*', + 'profil_redirect' => 0 //type de profil vers lequel basculer lors d'une recherche ]; } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/TagAnchor.php b/library/ZendAfi/View/Helper/TagAnchor.php index c74e4d912d09aae276a640c04849c1d484da5e71..de155d34f4fd219884bca0fdd2a3e6a72dee80ec 100644 --- a/library/ZendAfi/View/Helper/TagAnchor.php +++ b/library/ZendAfi/View/Helper/TagAnchor.php @@ -26,7 +26,6 @@ class ZendAfi_View_Helper_TagAnchor extends Zend_View_Helper_HtmlElement { * @return string */ public function tagAnchor($url, $text, array $attribs = array()) { - if(array_key_exists('libelle',$attribs)){ $attribs['title'] = $attribs['libelle']; unset($attribs['libelle']); diff --git a/library/ZendAfi/View/Helper/TagRechercheSimple.php b/library/ZendAfi/View/Helper/TagRechercheSimple.php index 66b843513493043837d3d6acf7e298e2c33b147e..f0c0c27ac1ef0a84adaad7c1cf498dc56d30bf0c 100644 --- a/library/ZendAfi/View/Helper/TagRechercheSimple.php +++ b/library/ZendAfi/View/Helper/TagRechercheSimple.php @@ -30,53 +30,91 @@ class ZendAfi_View_Helper_TagRechercheSimple extends Zend_View_Helper_HtmlElemen $this->division = $division; $this->id_module = $id_module; - // Si division 2 on met champ de recherche et types de docs côte a côte + return $this->renderForm($this->renderInputTypeDoc(). + $this->renderInputTri(). + $this->renderChampSaisie(). + $this->renderSelectionBib()). + $this->renderRechercheAvancee(). + '<div class="clear"></div>'; + } + + + public function renderRechercheAvancee() { + if (!in_array($this->preferences["recherche_avancee"], ['on', 1])) + return ''; + + return '<div class="recherche_avancee">'. + $this->view->tagAnchor($this->view->url(['controller' => 'recherche', + 'action' => 'avancee', + 'statut' => 'reset'], + null, + true), + $this->view->_('Recherche avancée'), + ['title' => $this->view->_('Recherche avancée')]). + '</div>'; + } + + + public function renderSelectionBib() { + if ($this->preferences["select_bib"] !== 1) + return ''; + + return isset($_SESSION['selection_bib']['id_bibs']) + ? '<input type="hidden" name="bib_select" value="'.$_SESSION['selection_bib']['id_bibs'].'" />' + : '<div>'. $_SESSION["selection_bib"]["html"] .'</div>'; + } + + + public function renderChampSaisie() { + // Si division 2 (colonne centrale) on met champ de recherche et types de docs côte a côte $float = ''; if ($this->division=="2" and $this->preferences["select_doc"]) $float=' style="float:left;width:50%"'; - // filtres - $arg_filtre = ''; - if(array_isset("type_doc", $this->preferences)) $arg_filtre="?facette=T".$this->preferences["type_doc"]; - - $this->contenu = '<form name="form" action="'.BASE_URL.'/opac/recherche/simple'.$arg_filtre.'" method="get" class="rechSimpleForm">'; - $this->contenu.= '<div>'; - if (isset($this->preferences["type_doc"])) - $this->contenu.= '<input type="hidden" name="type_doc" value="'.$this->preferences["type_doc"].'" />'; + $contenu='<div'.$float.'><label for="expressionRecherche_'.$this->id_module.'">'.$this->preferences["message"].' </label></div>'; - $this->contenu.= '<input type="hidden" name="tri" value="'.$this->preferences["tri"].'" />'; - $this->contenu.='<div'.$float.'><label for="expressionRecherche_'.$this->id_module.'">'.$this->preferences["message"].' </label></div>'; + if($float) $contenu.=sprintf('<div><label for="select_type_doc">%s </label></div>', $this->view->_('Type de document')); - if($float) $this->contenu.=sprintf('<div><label for="select_type_doc">%s </label></div>', $this->view->_('Type de document')); - - $this->contenu.='<div'.$float.'>'.$this->getChampSaisie().'</div>'; - if($float) $this->contenu.='<div>'.$this->getComboTypesDocs().'</div>'; + $contenu.='<div'.$float.'>'.$this->getChampSaisie().'</div>'; + if($float) $contenu.='<div>'.$this->getComboTypesDocs().'</div>'; if($this->preferences["select_doc"] and $this->division!="2") - $this->contenu.= sprintf('<div style="margin-top:5px"><label for="select_type_doc">%s</label>%s</div>', + $contenu.= sprintf('<div style="margin-top:5px"><label for="select_type_doc">%s</label>%s</div>', $this->view->_('Type de document'), $this->getComboTypesDocs()); if($this->preferences["select_annexe"] and $this->division!="2") { - $this->contenu.='<div style="margin-top:5px">'.$this->view->_('Site').'</div>'; - $this->contenu.=$this->getComboAnnexes(); + $contenu.='<div style="margin-top:5px">'.$this->view->_('Site').'</div>'; + $contenu.=$this->getComboAnnexes(); } + return $contenu; + } - if($this->preferences["select_bib"] == 1) { - if (isset($_SESSION['selection_bib']['id_bibs'])) - $this->contenu.= '<input type="hidden" name="bib_select" value="'.$_SESSION['selection_bib']['id_bibs'].'" />'; - $this->contenu.='<div>'. $_SESSION["selection_bib"]["html"] .'</div>'; - } - $this->contenu.='</div></form>'; + public function renderInputTypeDoc() { + return isset($this->preferences["type_doc"]) + ? '<input type="hidden" name="type_doc" value="'.$this->preferences["type_doc"].'" />' + : ''; + } + - if ($this->preferences["recherche_avancee"] == "on") - $this->contenu.='<div class="recherche_avancee">'. - '<a href="'.BASE_URL.'/recherche/avancee?statut=reset'.'">Recherche avancée</a>'. - '</div>'; + public function renderInputTri() { + return '<input type="hidden" name="tri" value="'.$this->preferences["tri"].'" />'; + } - $this->contenu .= '<div class="clear"></div>'; - return $this->contenu; + + public function renderForm($content) { + $action_url = ['controller' => 'recherche', + 'action' => 'simple']; + if (array_isset("type_doc", $this->preferences)) + $action_url['facette'] = 'T'.$this->preferences["type_doc"]; + if (array_isset("profil_redirect", $this->preferences)) + $action_url['id_profil'] = $this->preferences["profil_redirect"]; + + return + '<form name="form" action="'.$this->view->url($action_url, null, true).'" method="get" class="rechSimpleForm">' + .'<div>'.$content.'</div>' + .'</form>'; } //--------------------------------------------------------------------- diff --git a/tests/application/modules/admin/controllers/AccueilControllerTest.php b/tests/application/modules/admin/controllers/AccueilControllerTest.php index 81ea92896a15df1f43e52a0d9df533bece075af2..ed8b681b8ed307061421904d3cbf95219b83fc72 100644 --- a/tests/application/modules/admin/controllers/AccueilControllerTest.php +++ b/tests/application/modules/admin/controllers/AccueilControllerTest.php @@ -582,7 +582,15 @@ class AccueilControllerRechSimpleConfigurationTest extends Admin_AbstractControl 'preferences' => ['titre' => 'Recherchez', 'boite' => 'boite_vide']]; - Class_Profil::getCurrentProfil()->updateModuleConfigAccueil(2, $boite_recherche); + $profil_adulte = Class_Profil::getCurrentProfil() + ->setLibelle('Adulte') + ->updateModuleConfigAccueil(2, $boite_recherche); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Profil') + ->whenCalled('findTopProfils') + ->answers([$profil_adulte, + Class_Profil::newInstanceWithId(98, ['libelle' => 'Jeunesse'])]); + $this->request_url = '/admin/accueil/rechsimple?id_module=2&type_module=RECH_SIMPLE&config=accueil'; $this->dispatch($this->request_url, true); @@ -599,6 +607,14 @@ class AccueilControllerRechSimpleConfigurationTest extends Admin_AbstractControl public function inputTriShouldHavePertinenceSelected() { $this->assertXPath('//select[@name="tri"]//option[@value="*"][@selected="selected"]'); } + + + /** @test */ + public function selectProfilRedirectShouldContainsProfilAdulte() { + $this->assertXPathContentContains('//select[@name="profil_redirect"]//option[@value="2"]', + 'Adulte', + $this->_response->getBody()); + } } ?> \ No newline at end of file diff --git a/tests/library/Class/WebService/SIGB/CarthameTest.php b/tests/library/Class/WebService/SIGB/CarthameTest.php index 21886d2803fb22fe3386ddb6d298700d7b6c8064..78843a57eecdfd2f3b5bd5ba7d18df8a120ef5a7 100644 --- a/tests/library/Class/WebService/SIGB/CarthameTest.php +++ b/tests/library/Class/WebService/SIGB/CarthameTest.php @@ -46,7 +46,7 @@ class CarthameGetServiceTest extends PHPUnit_Framework_TestCase { } -abstract class CarthameTestCase extends PHPUnit_Framework_TestCase{ +abstract class CarthameTestCase extends Storm_Test_ModelTestCase { /** @var Storm_Test_ObjectWrapper */ protected $mock_web_client; @@ -54,6 +54,7 @@ abstract class CarthameTestCase extends PHPUnit_Framework_TestCase{ protected $service; public function setUp() { + parent::setUp(); $this->mock_web_client = Storm_Test_ObjectWrapper::on(new Class_WebService_SimpleWebClient()) ->whenCalled('open_url') ->answers('') @@ -187,6 +188,9 @@ class CarthameAnonymousNoticeTest extends CarthameTestCase { } + + + class CarthameEmprunteurPatrickBTest extends CarthameTestCase { /** @var Class_WebService_SIGB_Emprunteur */ protected $emprunteur; @@ -194,14 +198,17 @@ class CarthameEmprunteurPatrickBTest extends CarthameTestCase { public function setUp() { parent::setUp(); + $exemplaire = Class_Exemplaire::newInstanceWithId(3, + ['id_origine' => 'L8984', + 'id_notice' => '123', + 'id_bib' => 47]); Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Exemplaire') + ->whenCalled('findFirstBy')->answers(null) + ->whenCalled('findFirstBy') - ->with(array('id_origine' => 'L8984')) - ->answers(Class_Exemplaire::getLoader() - ->newInstanceWithId(3) - ->setIdOrigine('L8984') - ->setIdNotice('123') - ->setIdBib(47)); + ->with(['id_origine' => 'L8984']) + ->answers($exemplaire); + Class_Notice::getLoader() ->newInstanceWithId(123) diff --git a/tests/library/Class/WebService/SIGB/NanookTest.php b/tests/library/Class/WebService/SIGB/NanookTest.php index e9cb4c887a8dd92669bbc0613a591c83d1150af9..f557c5609df0916357fdd9a9c02075a318e1aafd 100644 --- a/tests/library/Class/WebService/SIGB/NanookTest.php +++ b/tests/library/Class/WebService/SIGB/NanookTest.php @@ -21,7 +21,7 @@ include_once 'NanookFixtures.php'; -class NanookGetServiceTest extends PHPUnit_Framework_TestCase { +class NanookGetServiceTest extends Storm_Test_ModelTestCase { public function setUp() { Class_WebService_SIGB_Nanook::reset(); $this->service = Class_WebService_SIGB_Nanook::getService(array('url_serveur' => 'http://localhost:8080/afi_Nanook/ilsdi/')); diff --git a/tests/library/Class/WebService/SIGB/OpsysServiceTest.php b/tests/library/Class/WebService/SIGB/OpsysServiceTest.php index a18421d82a57cf5f4a4dcba09a3bd26e58b44698..2eb2af9bde1bf5fe25ae1bdf559302dab054349a 100644 --- a/tests/library/Class/WebService/SIGB/OpsysServiceTest.php +++ b/tests/library/Class/WebService/SIGB/OpsysServiceTest.php @@ -47,7 +47,7 @@ class StubSoapClient { -abstract class OpsysServiceFactoryWithCatalogueWebTestCase extends PHPUnit_Framework_TestCase { +abstract class OpsysServiceFactoryWithCatalogueWebTestCase extends Storm_Test_ModelTestCase { protected $_service; public function setUp() { @@ -115,7 +115,7 @@ class OpsysServiceFactoryWithoutParamCatalogueWebTest extends OpsysServiceFactor -class OpsysServiceTestAutoConnect extends PHPUnit_Framework_TestCase { +class OpsysServiceTestAutoConnect extends Storm_Test_ModelTestCase { private $ouvre_session_res; private $client; @@ -170,7 +170,7 @@ class OpsysServiceTestAutoConnect extends PHPUnit_Framework_TestCase { } -class Class_System_OpsysServiceFactoryTestUrls extends PHPUnit_Framework_TestCase { +class Class_System_OpsysServiceFactoryTestUrls extends Storm_Test_ModelTestCase { public function setUp() { $this->factory = new Class_WebService_SIGB_Opsys_ServiceFactory(); } @@ -194,7 +194,7 @@ class Class_System_OpsysServiceFactoryTestUrls extends PHPUnit_Framework_TestCas -class Class_WebService_SIGB_OpsysServiceTestProxy extends PHPUnit_Framework_TestCase { +class Class_WebService_SIGB_OpsysServiceTestProxy extends Storm_Test_ModelTestCase { private $factory; private $mock_opsys_service; @@ -268,7 +268,7 @@ class Class_WebService_SIGB_OpsysServiceTestProxy extends PHPUnit_Framework_Test } -class OpsysServiceNoticeTestDispoExemplaire extends PHPUnit_Framework_TestCase { +class OpsysServiceNoticeTestDispoExemplaire extends Storm_Test_ModelTestCase { public function testPopDisponibiliteOnEmptyNoticeReturnsFalse(){ $notice = new Class_WebService_SIGB_Notice('123'); $this->assertFalse($notice->popDisponibilite()); @@ -290,7 +290,7 @@ class OpsysServiceNoticeTestDispoExemplaire extends PHPUnit_Framework_TestCase { -class OpsysServiceNoticeCacheTestGetExemplaire extends PHPUnit_Framework_TestCase { +class OpsysServiceNoticeCacheTestGetExemplaire extends Storm_Test_ModelTestCase { private $notices; private $cache; @@ -970,7 +970,7 @@ class OpsysServiceTestProlongerPret extends OpsysServiceWithSessionTestCase { -class OpsysServiceRecupererNoticeResponseTestCreateNotice extends PHPUnit_Framework_TestCase { +class OpsysServiceRecupererNoticeResponseTestCreateNotice extends Storm_Test_ModelTestCase { public function setUp() { $emplacement_reserve = Class_CodifEmplacement::newInstanceWithId(3) ->setLibelle('Réserve') @@ -1086,7 +1086,7 @@ class OpsysServiceRecupererNoticeResponseTestCreateNotice extends PHPUnit_Framew -class OpsysServiceEmprReserverResponseTest extends PHPUnit_Framework_TestCase { +class OpsysServiceEmprReserverResponseTest extends Storm_Test_ModelTestCase { private $default_rsp; public function setUp(){ @@ -1112,7 +1112,7 @@ class OpsysServiceEmprReserverResponseTest extends PHPUnit_Framework_TestCase { } -class OpsysServiceEmprunteurAttributesTest extends PHPUnit_Framework_TestCase { +class OpsysServiceEmprunteurAttributesTest extends Storm_Test_ModelTestCase { public function setUp(){ $this->opsys_service = $this->getMock('Mock_OpsysService', array('getEmpruntsOf', @@ -1187,7 +1187,7 @@ class OpsysServiceEmprunteurAttributesTest extends PHPUnit_Framework_TestCase { } -class OpsysServiceReservationAttributesTest extends PHPUnit_Framework_TestCase { +class OpsysServiceReservationAttributesTest extends Storm_Test_ModelTestCase { public function setUp(){ $this->reservation = new Class_WebService_SIGB_Reservation('23', new Class_WebService_SIGB_Exemplaire('potter')); $this->reservation->parseExtraAttributes(array( @@ -1251,7 +1251,7 @@ class EmpruntFixtures { -class OpsysServiceEmpruntAttributesTest extends PHPUnit_Framework_TestCase { +class OpsysServiceEmpruntAttributesTest extends Storm_Test_ModelTestCase { public function setUp() { $this->emprunt = EmpruntFixtures::potter(); } @@ -1287,7 +1287,7 @@ class OpsysServiceEmpruntAttributesTest extends PHPUnit_Framework_TestCase { -class OpsysServiceEmpruntRetardAttributesTest extends PHPUnit_Framework_TestCase { +class OpsysServiceEmpruntRetardAttributesTest extends Storm_Test_ModelTestCase { public function setUp() { $this->emprunt = EmpruntFixtures::potter(); $this->emprunt->setEnRetard(true); @@ -1320,7 +1320,7 @@ class OpsysServiceEmpruntRetardAttributesTest extends PHPUnit_Framework_TestCase -class OpsysServiceEmpruntTestSort extends PHPUnit_Framework_TestCase { +class OpsysServiceEmpruntTestSort extends Storm_Test_ModelTestCase { public function setUp() { $this->opsys_service = $this->getMock('Mock_OpsysService', array('getEmpruntsOf', 'getReservationsOf')); @@ -1367,7 +1367,7 @@ class OpsysServiceEmpruntTestSort extends PHPUnit_Framework_TestCase { -class OpsysServiceEmprunteurTestPretsEnRetard extends PHPUnit_Framework_TestCase { +class OpsysServiceEmprunteurTestPretsEnRetard extends Storm_Test_ModelTestCase { /** @var Class_WebService_SIGB_Emprunteur */ protected $emprunteur; diff --git a/tests/library/Class/WebService/SIGB/VSmartTest.php b/tests/library/Class/WebService/SIGB/VSmartTest.php index 59e24684bcea50dddb4d5e665fd4fc6823279973..7a0c4f4a60f126adb2dff6a382f5fd753916839a 100644 --- a/tests/library/Class/WebService/SIGB/VSmartTest.php +++ b/tests/library/Class/WebService/SIGB/VSmartTest.php @@ -20,7 +20,7 @@ */ include_once('VSmartFixtures.php'); -abstract class VSmartServiceTestCase extends PHPUnit_Framework_TestCase { +abstract class VSmartServiceTestCase extends Storm_Test_ModelTestCase { public function setUp() { Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifAnnexe') ->whenCalled('findFirstBy') @@ -40,7 +40,7 @@ abstract class VSmartServiceTestCase extends PHPUnit_Framework_TestCase { } -class VSmartServiceDummyFunctionsTest extends PHPUnit_Framework_TestCase { +class VSmartServiceDummyFunctionsTest extends Storm_Test_ModelTestCase { public function setUp() { $this->service = Class_WebService_SIGB_VSmart_Service::newInstance(); } @@ -63,7 +63,7 @@ class VSmartServiceDummyFunctionsTest extends PHPUnit_Framework_TestCase { } -class VSmartGetServiceTest extends PHPUnit_Framework_TestCase { +class VSmartGetServiceTest extends Storm_Test_ModelTestCase { public function setUp() { Class_WebService_SIGB_VSmart::reset(); $this->service = Class_WebService_SIGB_VSmart::getService(array('url_serveur' => 'vpn.moulins.fr')); @@ -392,7 +392,7 @@ class VSmartServiceWithEmprunteurFranckTest extends VSmartServiceTestCase { -class VSmartServiceBibGetAnthologieLitteratureTest extends PHPUnit_Framework_TestCase { +class VSmartServiceBibGetAnthologieLitteratureTest extends Storm_Test_ModelTestCase { public function setUp() { $mock_web_client = $this->getMock('Class_WebService_SimpleWebClient'); $mock_web_client @@ -435,7 +435,7 @@ class VSmartServiceBibGetAnthologieLitteratureTest extends PHPUnit_Framework_Tes -class VSmartServiceBibGetHarryPotterTest extends PHPUnit_Framework_TestCase { +class VSmartServiceBibGetHarryPotterTest extends Storm_Test_ModelTestCase { public function setUp() { $mock_web_client = $this->getMock('Class_WebService_SimpleWebClient'); $mock_web_client @@ -583,7 +583,7 @@ class VSmartServiceBibGetHarryPotterTest extends PHPUnit_Framework_TestCase { -class VSmartServiceFunctionsTest extends PHPUnit_Framework_TestCase { +class VSmartServiceFunctionsTest extends Storm_Test_ModelTestCase { public function setUp() { $this->mock_web_client = $this->getMock('Class_WebService_SimpleWebClient'); diff --git a/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php b/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d07f7f8f22519fa2a4d35496da23f5fc8483adcb --- /dev/null +++ b/tests/library/ZendAfi/View/Helper/TagRechercheSimpleTest.php @@ -0,0 +1,68 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * AFI-OPAC 2.0 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +class ZendAfi_View_Helper_TagRechercheSimpleTest extends ViewHelperTestCase { + /** @var ZendAfi_View_Helper_TagRechercheSimple */ + protected $_helper; + + /** @var Class_Album */ + protected $_album; + + /** @var array */ + protected $_preferences = null; + + public function setUp() { + parent::setUp(); + + $view = new ZendAfi_Controller_Action_Helper_View(); + $this->_helper = new ZendAfi_View_Helper_TagRechercheSimple(); + $this->_helper->setView($view); + + $this->_preferences = (new Class_Systeme_ModulesAccueil_RechercheSimple())->getDefaultValues(); + } + + + /** @test */ + public function withoutTypeDocAndProfilRedirectActionShouldBeRechercheSimpleWithoutMoreParams() { + $html = $this->_helper->tagRechercheSimple($this->_preferences, 1); + $this->assertNotXPath($html, '//form[contains(@action, "/simple/")]', $html); + } + + + /** @test */ + public function rechercheAvanceeShouldBeVisible() { + $html = $this->_helper->tagRechercheSimple($this->_preferences, 1); + $this->assertXPathContentContains($html, + '//a[contains(@href, "/recherche/avancee/statut/reset")]', + utf8_encode('Recherche avancée')); + } + + + /** @test */ + public function withTypeDocAndProfilRedirectActionShouldBeRechercheSimpleFacetteT2ProfilThree() { + $this->_preferences['type_doc'] = 2; + $this->_preferences['profil_redirect'] = 3; + $html = $this->_helper->tagRechercheSimple($this->_preferences, 1); + $this->assertXPath($html, '//form[contains(@action, "/recherche/simple/facette/T2/id_profil/3")]', $html); + } +} + +?> \ No newline at end of file