Newer
Older
<?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
*/
require_once 'AbstractControllerTestCase.php';
abstract class RechercheControllerNoticeTestCase extends AbstractControllerTestCase {
$this->notice = Class_Notice::getLoader()->findFirstBy([]);
}
class RechercheControllerReseauTest extends RechercheControllerNoticeTestCase {
public function setUp() {
Class_WebService_ReseauxSociaux::setDefaultWebClient(Storm_Test_ObjectWrapper::mock()
->whenCalled('open_url')
->answers(false));
parent::setUp();
$this->dispatch(sprintf('recherche/reseau/id_notice/%d/type_doc/1',
$this->notice->getId()),
true);
public function tearDown() {
Class_WebService_ReseauxSociaux::setDefaultWebClient(null);
}
public function getResauShouldContainsTwitterGif() {
$this->assertXPath('//img[contains(@src, "twitter.gif")]');
}
/** @test */
public function getResauShouldContainsTwitterLink() {
$this->assertContains('onclick="$.getScript(\'/social-network/share/on/facebook?url=',
$this->_response->getBody());
class RechercheControllerViewNoticeBabelthequeTest extends RechercheControllerNoticeTestCase {
/** @test */
public function withoutBabelthequeJSShouldNotBeLoaded() {
Class_AdminVar::newInstanceWithId('BABELTHEQUE_JS')->setValeur('');
$this->dispatch(sprintf('recherche/viewnotice/id/%d', $this->notice->getId()), true);
$this->assertNotXpath('//script[contains(@src, "babeltheque.js")]');
}
/** @test */
public function withBabelthequeJSShouldBeLoadedWithRightId() {
Class_AdminVar::newInstanceWithId('BABELTHEQUE_JS')->setValeur('http://www.babeltheque.com/bw_666.js');
$this->dispatch(sprintf('recherche/viewnotice/id/%d', $this->notice->getId()), true);
$this->assertXpath('//script[contains(@src, "babeltheque.js?bwid=666")]');
}
}
class RechercheControllerViewNoticeWithPreferencesTest extends RechercheControllerNoticeTestCase {
public function setUp() {
parent::setUp();
$preferences = [
'barre_nav' => 'Notice',
'entete' =>"ABCDEFGIKLMNOPRSTtYZ8v",
'onglets' => [
'detail' => ['titre' => 'Details', 'aff' => '1', 'ordre' => 1, 'largeur' => 10],
'avis' => ['titre' => 'avis', 'aff' => '1', 'ordre' => 2, 'largeur' => 10],
'exemplaires' => ['titre' => 'exemplaires', 'aff' => '2', 'ordre' => 3, 'largeur' => 10],
'resume' => ['titre' => 'resume', 'aff' => '2', 'ordre' => 4, 'largeur' => 10],
'tags' => ['titre' => 'tags', 'aff' => '2', 'ordre' => 5, 'largeur' => 10],
'biographie' => ['titre' => 'biographie', 'aff' => '2', 'ordre' => 6, 'largeur' => 10],
'similaires' => ['titre' => 'similaires', 'aff' => '2', 'ordre' => 7, 'largeur' => 10],
'bibliographie' => ['titre' => 'bibliographie','aff' => '3', 'ordre' => 7, 'largeur' => 10],
'morceaux' => ['titre' => 'morceaux', 'aff' => '3', 'ordre' => 8, 'largeur' => 10],
'bandeAnnonce' => ['titre' => 'bande annonce','aff' => '3', 'ordre' => 9, 'largeur' => 10],
'photos' => ['titre' => 'photos', 'aff' => '3', 'ordre' => 14, 'largeur' => 10],
'videos' => ['titre' => 'videos', 'aff' => '3', 'ordre' => 11, 'largeur' => 10],
'resnumeriques' => ['titre' => 'ressources n', 'aff' => '3', 'ordre' => 12, 'largeur' => 10],
'babeltheque' => ['titre' => 'babeltheque', 'aff' => '3', 'ordre' => 13, 'largeur' => 10],
'frbr' => ['titre' => 'frbr', 'aff' => '3', 'ordre' => 10, 'largeur' => 10]],
'boite' => null];
Class_Profil::getCurrentProfil()->setCfgModules(['recherche' => ['viewnotice1' => $preferences]]);
$this->notice
->setId(345)
->setAnnee('2002')
->setEditeur('Gallimard')
->setIsbn('1-234-56789-0')

llaffont
committed
->setUrlVignette('NO')
->setUrlImage('NO')
->getLoader()
->cacheInstance($this->notice);
$this->dispatch('recherche/viewnotice/id/345', true);
}
/** @test */
public function enteteShouldDisplayAnnee2002() {
$this->assertXPathContentContains('//table[@id="entete_notice"]//td', '2002');
}
/** @test */
public function enteteShouldDisplayEditeurGallimard() {
$this->assertXPathContentContains('//table[@id="entete_notice"]//td', 'Gallimard');
}
/** @test */
public function detailsBlocShouldHaveIdBloc_345_0() {
$this->assertXPathContentContains('//div[@id="bloc_345_0"][@class="notice_bloc_titre"]', 'Details');
}
/** @test */
public function javascriptShouldOpenFirstBlocDetails() {
$this->assertXPathContentContains('//script',
"infos_bloc(\"bloc_345_0\",'1-234-56789-0','detail',0,'',0, 'http://localhost".BASE_URL."/noticeajax/detail/id/345')");
}
/** @test */
public function javascriptShouldOpenSecondBlocAvis() {
$this->assertXPathContentContains('//script',
"infos_bloc(\"bloc_345_1\",'1-234-56789-0','avis',0,'',1, 'http://localhost".BASE_URL."/noticeajax/avis/id/345')");
}
/** @test */
public function noJavascriptShouldOpenThirdBlocExemplaires() {
$this->assertNotXPathContentContains('//script', "infos_bloc(\"bloc_345_2\"");
}
/** @test */
public function bibliographieOngletShouldHaveIdSet345_onglet_0() {
$this->assertXPathContentContains('//div[@id="set345_onglet_0"][@class="titre_onglet"]', 'bibliographie');
}
/** @test */
public function javascriptShouldOpenFirstOngletBibliographie() {
$this->assertXPathContentContains('//script',
"infos_onglet('set345_onglet_0','1-234-56789-0','bibliographie',0,'',0, 'http://localhost".BASE_URL."/noticeajax/bibliographie/id/345')");
}
/** @test */
public function frbrOngletShouldHaveIdSet345_onglet_3() {
$this->assertXPathContentContains('//div[@id="set345_onglet_3"][@class="titre_onglet"]', 'frbr');
}
/** @test */
public function noJavascriptShouldOpenSecondOnglet() {
$this->assertNotXPathContentContains('//script', "infos_onglet('set345_onglet_1')");
}
/** @test */
public function linkReserverShouldBeDisplayed() {
$this->assertXPathContentContains('//a[@class="reserver"]', 'Réserver');
}

llaffont
committed
/** @test */
public function vignetteShouldBeGenerated() {
$this->assertXPath('//div[@class="nothumbnail type_doc_1"]');

llaffont
committed
}
/** @test */
public function vignetteForZoomShouldNotBeGenerated() {
$this->assertNotXPath('//a[@id="vignette"]');

llaffont
committed
}

llaffont
committed
/** @test */
public function divViewNoticeShouldHaveClassTypeDocOne() {
$this->assertXPath('//div[@class="view_notice type_doc_1"]');
}
}
abstract class RechercheControllerViewNoticeTestCase extends RechercheControllerNoticeTestCase {
public function titleShouldBeDisplayed() {
array_first(explode('<br />', $this->notice->getTitrePrincipal())),
$this->_response->getBody());
public function tagReseauSociauxShouldBePresent() {
$this->assertXPath('//div[@id="reseaux-sociaux"]');
}
/** @test */
public function headShouldContainsRechercheJS() {
$this->assertXPath('//head//script[contains(@src,"public/opac/js/recherche.js")]');
}
}
class RechercheControllerViewNoticeClefAlphaTest extends RechercheControllerViewNoticeTestCase {
public function setUp() {
parent::setUp();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice')
->whenCalled('findAllBy')
->with(['clef_alpha' => 'TESTINGALPHAKEY---101'])
->answers([$this->notice]);
$this->dispatch('recherche/viewnotice/clef/TESTINGALPHAKEY---101/expressionRecherche/Millenium', true);
}
/** @test */
public function retourListeShouldLinkToRechercheSimple() {
$this->assertXPathContentContains('//div/a[contains(@href, "/recherche/simple/expressionRecherche/Millenium")]',
'Retour à la liste');
class RechercheControllerViewNoticeClefAlphaWithDoublonsTest extends RechercheControllerNoticeTestCase {
public function setUp() {
parent::setUp();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice')
->whenCalled('findAllBy')
->with(['clef_alpha' => 'TWILIGHT--SLADED-3-M6VIDEO-2010-4'])
->answers([Class_Notice::newInstanceWithId($this->notice->getId())
->setTitrePrincipal('Twilight 1')
->setClefAlpha('TWILIGHT--SLADED-3-M6VIDEO-2010-4')

llaffont
committed
->setFacettes('')
->setUrlVignette('NO')
->setUrlImage('NO'),
Class_Notice::newInstanceWithId(1)
->setTitrePrincipal('Twilight 2')
->setClefAlpha('TWILIGHT--SLADED-3-M6VIDEO-2010-4')
->setFacettes('')

llaffont
committed
->setUrlVignette('')
->setUrlImage('')
]);
}
/** @test */
public function withOnlyClefResponseShouldRedirectToRechercheTWILIGHT_SLADED() {
$this->dispatch('recherche/viewnotice/clef/'.urlencode('TWILIGHT--SLADED-3-M6VIDEO-2010-4'), true);
$this->assertRedirectTo('/opac/recherche?q=TWILIGHT+SLADED');
}
/** @test */
public function withClefAndIdResponseShouldNotRedirectTo() {
$this->dispatch('recherche/viewnotice/clef/'.urlencode('TWILIGHT--SLADED-3-M6VIDEO-2010-4').'/id/'.$this->notice->getId(), true);
$this->assertNotRedirect();
}
}

llaffont
committed
class RechercheControllerUploadVignetteTest extends RechercheControllerNoticeTestCase {

llaffont
committed
public function setUp() {
parent::setUp();
$this->notice->setTypeDoc(5);
}

llaffont
committed
/** @test */

llaffont
committed
public function linkToUploadVignetteShouldNotBePresentForAbonneSIGB() {
Class_Users::getIdentity()->beAbonneSIGB();

llaffont
committed
$this->dispatch(sprintf('recherche/viewnotice/id/%d', $this->notice->getId()), true);
$this->assertNotXPathContentContains('//a', 'Modifier la vignette');
}

llaffont
committed
/** @test */
public function linkToUploadVignetteShouldBePresentForModoBib() {
Class_Users::getIdentity()->changeRoleTo(ZendAfi_Acl_AdminControllerRoles::MODO_BIB);
$this->dispatch(sprintf('recherche/viewnotice/id/%d', $this->notice->getId()), true);
$this->assertXPathContentContains('//a', 'Modifier la vignette');
}
/** @test */
public function linkToUploadVignetteShouldNotBePresentForTypeDocMoreThanFive() {
Class_Users::getIdentity()->beAdminPortail();
$this->notice->setTypeDoc(6);
$this->dispatch(sprintf('recherche/viewnotice/id/%d', $this->notice->getId()), true);
$this->assertNotXPathContentContains('//a', 'Modifier la vignette');
}

llaffont
committed
}
class RechercheControllerViewNoticeAsAdminTest extends RechercheControllerNoticeTestCase {
public function setUp() {
parent::setUp();
$this->notice->setTypeDoc(5);
Class_Users::getIdentity()->beAdminPortail();
$this->dispatch(sprintf('recherche/viewnotice/id/%d', $this->notice->getId()), true);
}
/** @test */
public function linkToUploadVignetteShouldBePresent() {
$this->assertXPathContentContains('//a', 'Modifier la vignette');
}
/** @test */
public function linkToConfigModulesRechercheShouldHaveActionViewNotice() {
$this->assertXPath('//img[contains(@onclick, "admin/modules/recherche?config=site&type_module=recherche&id_profil=2&action1=viewnotice&action2=5")]');
class RechercheControllerReservationPickupAjaxActionTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifAnnexe')
->whenCalled('findAllBy')
->with(array('no_pickup' => '0',
'order' => 'libelle'))
->answers(array(Class_CodifAnnexe::getLoader()->newInstanceWithId(2)
->setLibelle('Annecy')
->setCode('ANN'),
Class_CodifAnnexe::getLoader()->newInstanceWithId(3)
->setLibelle('Cran')
->setCode('CRN')));
$this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=ANN');
}
/** @test */
public function shouldRenderAnnecyCheckedRadio() {
$this->assertXPath('//input[@name="code_annexe"][@value="ANN"][@checked="checked"]');
}
/** @test */
public function shouldRenderCranRadio() {
$this->assertXPath('//input[@name="code_annexe"][@value="CRN"]');
}
/** @test */
public function layoutShouldBeEmpty() {
$this->assertNotXPath('//div[@id="banniere"]');
}

llaffont
committed
abstract class RechercheControllerSimpleActionTestCase extends AbstractControllerTestCase {
public function lanceRecherche($params) {
$this->postDispatch('/recherche/simple', $params, true);

llaffont
committed
$this->assertRedirect('/recherche/simple');
$recherche = $_SESSION['recherche'];
$this->bootstrap();
$_SESSION['recherche'] = $recherche;
$this->dispatch('/recherche/simple', true);
}
}

llaffont
committed
class RechercheControllerSimpleActionWithDefaultConfigTest extends RechercheControllerSimpleActionTestCase {
public function setUp() {
parent::setUp();

llaffont
committed
Class_Profil::getCurrentProfil()->setCfgModules([]);
$this->dispatch('/recherche/simple/expressionRecherche/pomme/tri/alpha_auteur',true);

llaffont
committed

llaffont
committed
public function pommeShouldBePresentInRedirectedPageAsResultatInSession() {
$this->assertXPathContentContains('//div', 'pomme');
}
/** @test */
public function pageShouldContainsLinkToSuggestionAchats() {
$this->assertXPathContentContains('//a[contains(@href, "/abonne/suggestion-achat")]',
'Suggérer un achat');
}
public function selectedTriShouldBeAlphaAuteur() {
$this->assertXPath('//select[@name="tri"]//option[@value="alpha_auteur"][@selected="selected"]');
class RechercheControllerSimpleActionWithConfigWithoutSuggestionAchatAsAdminTest extends RechercheControllerSimpleActionTestCase {

llaffont
committed
public function setUp() {
parent::setUp();

llaffont
committed
Class_Profil::getCurrentProfil()->setCfgModules(['recherche' => ['resultatsimple' => ['suggestion_achat' => 0,
'liste_format' => 3]]]);
$_SESSION['recherche'] = ['selection' => ['expressionRecherche' => 'potter',
'mode' => 'simple'],
'resultat' => ['req_liste' => "select id_notice,MATCH(alpha_titre) AGAINST(' (POMME POMMES POM)' ) as rel1, MATCH(alpha_auteur) AGAINST(' (POMME POMMES POM)' ) as rel2 from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE) order by (rel1 * 1.5)+(rel2) desc",
'req_facettes' => "select id_notice,type_doc,facettes from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE) limit 15000",
'nombre' => 5,
'facettes' => [],
'tags' => []]];
Class_Users::getIdentity()->beAdminPortail();
$this->dispatch('/recherche/simple', true);

llaffont
committed
}
/** @test */
public function pageShouldNotContainsLinkToSuggestionAchats() {
$this->assertNotXPath('//a[contains(@href, "/abonne/suggestion-achat")]');
}
/** @test */
public function linkToConfigModulesRechercheShouldHaveActionResultatAction2Simple() {
$this->assertXPath('//img[contains(@onclick, "admin/modules/recherche?config=site&type_module=recherche&id_profil=2&action1=resultat&action2=simple")]');
}

llaffont
committed
}
class RechercheControllerSimpleActionWithWrongParametersTest extends RechercheControllerSimpleActionTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/recherche/simple/expressionRecherche/pomme/tri/zork', true);
}
/** @test */
public function pageShouldDisplayResults() {
$this->assertXPathContentContains('//div', 'pomme');
}
}
class RechercheControllerSimpleActionWithEmptyExpressionTest extends RechercheControllerSimpleActionTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/recherche/simple/expressionRecherche/%', true);
}
/** @test */
public function pageShouldDisplayAucunMotSignificatif() {
$this->assertXPathContentContains('//div//div//h2', 'aucun mot assez significatif pour la recherche',$this->_response->getBody());
}
}

llaffont
committed
abstract class RechercheControllerSimpleActionhListeFormatTestCase extends RechercheControllerSimpleActionTestCase {
protected $_liste_format;
public function setUp() {
parent::setUp();

llaffont
committed
Class_Profil::getCurrentProfil()
->setCfgModules(['recherche' => ['resultatsimple' => [
'liste_format' => $this->_liste_format ,
'liste_codes' => "TANECR"]]])
->setSelTypeDoc('1;2;3;4;5');

llaffont
committed

llaffont
committed
$_SESSION['recherche'] = ['selection' => ['expressionRecherche' => 'potter',
'mode' => 'simple'],
'resultat' => ['req_liste' => "select id_notice,MATCH(alpha_titre) AGAINST(' (POMME POMMES POM)' ) as rel1, MATCH(alpha_auteur) AGAINST(' (POMME POMMES POM)' ) as rel2 from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE) order by (rel1 * 1.5)+(rel2) desc",
'req_facettes' => "select id_notice,type_doc,facettes from notices Where MATCH(titres,auteurs,editeur,collection,matieres,dewey) AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE) limit 15000",
'nombre' => 5,
'facettes' => [],
'tags' => []]];
Class_IntBib::newInstanceWithId(1, ['nom_court' => 'Annecy']);
Class_TypeDoc::newInstanceWithId(1, ['label' => 'Livres']);
Class_TypeDoc::newInstanceWithId(2, ['label' => 'Périodique']);
$this->dispatch('/recherche/simple/expressionRecherche/potter/facettes/T1/facette/B1', true);

llaffont
committed
}
}
class RechercheControllerSimpleActionWithListeFormatMurTest extends RechercheControllerSimpleActionhListeFormatTestCase {
protected $_liste_format = Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR;
/** @test */
public function pageShouldContainsDivNotice() {
$this->assertXPath('//div[@class="liste_mur"]//div[@class="notice"]', $this->_response->getBody());

llaffont
committed
}
public function urlForSousFacettesShouldContainsFacettest1AndB1() {
$this->assertXPath('//div[@class="facette"]//a[contains(@href,"/facettes/T1-B1")]', $this->_response->getBody());
/** @test */
public function criteresRechercheShouldContainsBibAnnecy() {
$this->assertXPathContentContains('//div[@class="criteres_recherche"]//div[3]', 'Bibliothèque: Annecy');
}
/** @test */
public function facetteBibAnnecyShouldHaveLinkToRemove() {
$this->assertXPath('//div[@class="criteres_recherche"]//div[3]//a[@href="/recherche/simple/expressionRecherche/potter/facettes/T1"]');
}
/** @test */
public function criteresRechercheShouldContainsTypeDocLivre() {
$this->assertXPathContentContains('//div[@class="criteres_recherche"]//div', 'Type de document: Livre');
}
/** @test */
public function criteresRechercheShouldContainsFiltreTypeDocLivrePeriodique() {
$this->assertXPathContentContains('//div[@class="criteres_recherche"]//div', 'Filtre Type de document: Livres, Périodique');

llaffont
committed
}
class RechercheControllerSimpleActionWithListeFormatVignettesTest extends RechercheControllerSimpleActionhListeFormatTestCase {
protected $_liste_format = Class_Systeme_ModulesAppli::LISTE_FORMAT_VIGNETTES;
/** @test */
public function pageShouldContainsDivListeVignette() {
$this->assertXPath('//div[@class="liste_vignette"]');
}
/** @test */
public function pageShouldContainsTdAnnee() {
$this->assertXPathContentContains('//div[@class="liste_vignette"]//td', 'Année');
}
/** @test */
public function pageShouldContainsTdEditeur() {
$this->assertXPathContentContains('//div[@class="liste_vignette"]//td', 'Editeur');
}
/** @test */
public function pageShouldContainsTdCollection() {
$this->assertXPathContentContains('//div[@class="liste_vignette"]//td', 'Collection');
}
/** @test */
public function pageShouldContainsTdResume() {
$this->assertXPathContentContains('//div[@class="liste_vignette"]//td', 'Résumé');
}

llaffont
committed
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
}
class RechercheControllerSimpleActionWithListeFormatAccordeonTest extends RechercheControllerSimpleActionhListeFormatTestCase {
protected $_liste_format = Class_Systeme_ModulesAppli::LISTE_FORMAT_ACCORDEON;
/** @test */
public function ajaxToGetNotice() {
$this->assertXPath('//img[contains(@onclick, "getNoticeAjax")]');
}
}
class RechercheControllerSimpleActionWithListeFormatTableauTest extends RechercheControllerSimpleActionhListeFormatTestCase {
protected $_liste_format = Class_Systeme_ModulesAppli::LISTE_FORMAT_TABLEAU;
/** @test */
public function pageShouldContainsTdWithListeTitres() {
$this->assertXPath('//td[@class="listeTitre"]');
}
}

llaffont
committed
class RechercheControllerSimpleByISBNActionTest extends RechercheControllerSimpleActionTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/recherche/simple/expressionRecherche/2-203-00119-4', true);
}
/** @test */
public function pageResultatRechecheShouldBeDisplayed() {
$this->assertXPathContentContains('//div', 'Recherche: 2-203-00119-4',$this->_response->getBody());
}
}
class RechercheControllerAvanceeActionTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/recherche/simple/tri/alpha_titre', true);
}
/** @test */
public function pageRechercheAvanceeShouldBeDisplayed() {
$this->assertXPathContentContains('//h1', 'recherche');
}
/** @test */
public function selectTriShouldHaveAlphaTitreSelected() {
$this->assertXPath('//select[@name="tri"]//option[@value="alpha_titre"][@selected="selected"]',$this->_response->getBody());
}
/** @test */
public function urlPage2ShouldBeWithTriParameter() {
$this->assertXPath('//a[contains(@href,"/tri/alpha_titre/page/2")]',$this->_response->getBody());
}
}
class RechercheControllerPostReservationAction extends AbstractControllerTestCase {
protected $_sent_mails;
public function setUp() {
parent::setUp();
$_SESSION["captcha_code"] = '1234';
$mock_transport = new MockMailTransport();
Zend_Mail::setDefaultTransport($mock_transport);
Class_Bib::getLoader()->newInstanceWithId(4)->setLibelle('Astrolabe');
Class_Notice::newInstanceWithId(4,
['unimarc' => "01570nam0 2200325 450 0010007000000100033000070200017000400210027000571000041000841010008001251020007001331050018001401060006001582000106001642100075002702150044003452250023003893000125004123000020005373000137005573300265006943450018009594100051009775120027010286060033010556060060010886760012011487000045011608010039012052218529 a2-86642-370-4bbr.d8,95 EUR aFRb00347575 aFRbDLE-20031204-51138 a20031107d2003 m h0frey0103 ba| afre aFR ay z 000y| ar1 aCinéma d'animationbTexte impriméedessin animé, marionnettes, images de synthèsefBernard Génin a[Paris]c\"Cahiers du cinéma\"cSCEREN-CNDPdcop. 2003gimpr. en Italie a95 p.cill., couv. ill. en coul.d19 cm2 aLes petits cahiers aLa couv. porte en plus : \"du crayon à l'ordinateur, pour ou contre Disney, Europe-Japon : le dessin animé aujourd'hui\" aBibliogr. p. 93 aSCEREN = Services, cultures, éditions, ressources pour l'éducation nationale. CNDP = Centre national de documentation pédagogique aPrésente un historique du cinéma d'animation, un survol des différentes productions nationales à travers le monde (Etats-Unis, Japon, France, Canada), les techniques du volume animé, l'image de synthèse, mais aussi l'oeuvre de Disney et le film d'auteur. b9782866423704 032525826tLes Petits cahiers (Paris)x1633-90531 aLe cinéma d'animation| 31053394aAnimation (cinéma)| 31031625aDessins animés32195497xHistoire et critique a791.431 |32547161aGéninbBernardf1946-....4070 0aFRbBNFc20031107gAFNOR2intermrc"]);
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
$this->postDispatch('/recherche/reservation',
array('id_notice' => 4,
'id_bib' => 4,
'mail_bib' => 'zork@gloub.fr',
'user_name' => 'nanuk',
'demande' => 'je veux le livre',
'user_mail' => 'nanuk@gloub.com',
'code_saisi' => '1234',
'cote' => 'XYZ'),
true);
$this->_sent_mails = $mock_transport->getSentMails();
}
/** @test */
public function twoMailsShouldHaveBeenSent() {
$this->assertEquals(2, count($this->_sent_mails));
}
/** @test */
public function firstMailFromShouldBeNanuk() {
$this->assertEquals('nanuk@gloub.com',
array_first($this->_sent_mails)->getFrom());
}
/** @test */
public function firstMailToShouldBeZork() {
$this->assertContains('zork@gloub.fr',
array_first($this->_sent_mails)->getRecipients());
}
/** @test */
public function secondMailFromShouldBeNobody() {
$this->assertEquals('nobody@noreply.fr',
array_last($this->_sent_mails)->getFrom());
}
/** @test */
public function secondMailToShouldBeNanuk() {
$this->assertContains('nanuk@gloub.com',
array_last($this->_sent_mails)->getRecipients());
}
}
class RechercheControllerRebondTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
$facettes = Class_Notice::findFirstBy(['where' => 'facettes>""'])->getFacettes();
$code_rebond = explode(' ', trim($facettes))[0];
$this->dispatch('/recherche/rebond/expressionRecherche/Potter/code_rebond/'.$code_rebond.'/tri/alpha_titre', true);
}
/** @test */
public function comboTriShouldHaveAnneePublicationSelected() {
$this->assertXPathContentContains('//select[@id="tri"]//option[@value="alpha_titre"][@selected="selected"]',
'Titre',$this->_response->getBody());

llaffont
committed
}
/** @test */
public function lienRetourRechercheInitialeShouldBeRechercheSimple() {
$this->assertXPathContentContains('//a[@href="/recherche/simple/expressionRecherche/Potter/tri/alpha_titre"]',
'Retour',
$this->_response->getBody());

llaffont
committed
}
/** @test */
public function lienNouvelleRechercheShouldBeRechercheSimple() {
$this->assertXPathContentContains('//a[@href="/recherche/simple/statut/saisie"]',

llaffont
committed
'Nouvelle recherche',
$this->_response->getBody());
}
}
class RechercheControllerGuideeTest extends AbstractControllerTestCase {
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
public function setUp() {
parent::setUp();
$this->mock_sql = Storm_Test_ObjectWrapper::mock();
Zend_Registry::set('sql', $this->mock_sql);
$this->mock_sql
->whenCalled('fetchAll')
->with('select * from codif_dewey where LENGTH(id_dewey)=1 order by id_dewey')
->answers([ ['id_dewey'=>66,
'libelle' => 'Generalites',
'nb_notices'=>1],
['id_dewey'=>77,
'libelle' => 'Arts',
'nb_notices' => 0]]
)->beStrict();
$this->mock_sql
->whenCalled('fetchOne')
->with('select libelle from codif_dewey where id_dewey=\'66\'')
->answers( 'Generalites')->beStrict();
$this->mock_sql
->whenCalled('fetchOne')
->with('select libelle from codif_dewey where id_dewey=\'77\'')
->answers('Arts')->beStrict();
$this->dispatch('/recherche/simple/rubrique/X1/fil/;X1', true);
}
/** @test */
public function indiceShouldBeDisplayed() {
$this->assertXPathContentContains("//a[contains(@href,'recherche/simple/rubrique/X1')]", getVar("DEWEY_LIB"),$this->_response->getBody());
}
/** @test */
public function generalitesShouldBeDisplayed() {
$this->assertXPathContentContains("//a[contains(@href,'recherche/simple/rubrique/D66')]", 'Generalites',$this->_response->getBody());
public function artsShouldBeDisplayed() {
$this->assertXPathContentContains("//a[contains(@href,'recherche/simple/rubrique/D77')]", 'Arts',$this->_response->getBody());
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
class RechercheControllerGuideeHomePageTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
$this->mock_sql = Storm_Test_ObjectWrapper::mock();
Zend_Registry::set('sql', $this->mock_sql);
$this->mock_sql
->whenCalled('fetchAll')
->with('select * from codif_dewey where LENGTH(id_dewey)=1 order by id_dewey')
->answers([ ['id_dewey'=>66,
'libelle' => 'Generalites',
'nb_notices'=>1],
['id_dewey'=>77,
'libelle' => 'Arts',
'nb_notices' => 0]]
)->beStrict();
$this->mock_sql
->whenCalled('fetchOne')
->with('select libelle from codif_dewey where id_dewey=\'66\'')
->answers( 'Generalites')->beStrict();
$this->mock_sql
->whenCalled('fetchOne')
->with('select libelle from codif_dewey where id_dewey=\'77\'')
->answers('Arts')->beStrict();
$this->dispatch('/recherche/guidee', true);
}
/** @test */
public function x1ShouldBeDisplayed() {
$this->assertXPathContentContains("//a[contains(@href,'recherche/simple/rubrique/X1')]", getVar("DEWEY_LIB"),$this->_response->getBody());
}
/** @test */
public function x2ShouldBeDisplayed() {
$this->assertXPathContentContains("//a[contains(@href,'recherche/simple/rubrique/X2')]", getVar("PCDM4_LIB"),$this->_response->getBody());
}

efalcy
committed
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
}
class RechercheControllerGuideeWithFiltersSelectedTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
$this->mock_sql = Storm_Test_ObjectWrapper::mock();
$this->mock_moteur_recherche = Storm_Test_ObjectWrapper::mock();
$this->mock_codif = Storm_Test_ObjectWrapper::mock();
$this->mock_moteur_recherche
->whenCalled('getFacettes')
->answers([ "facettes" => [ "T" =>
[ "titre" => "Type de document",
1 => [
"id" => "D3",
"libelle" => "disques",
"nombre" =>"2",
"url" => "/une/url/Bidon"]
]] ,
"tags" => [
1=>[
"id" => "M1355",
"libelle" => "CD",
"nombre" => 2]],
"url_facette" => "/recherche/simple/facettes/"
]
);
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice')
->whenCalled('findAllByRequeteRecherche')
->answers([Class_Notice::newInstanceWithId(8),
Class_Notice::newInstanceWithId(9)]);
$this->mock_codif
->whenCalled('getNomFacette')
->answers('nom de la facette');
$this->mock_codif
->whenCalled('getLibelleFacette')
->answers('facette');
$this->mock_codif
->whenCalled('getNomChamp')
->answers('champ');
$this->mock_moteur_recherche
->whenCalled('lancerRecherche')
->answers([ "req_liste" => "select" ,
"nombre" => 10,
"req_facettes" => "select",
'facettes' => 'M123-A989'
]);
Class_Codification::setInstance($this->mock_codif);
Class_MoteurRecherche::setInstance($this->mock_moteur_recherche);
$this->mock_sql
->whenCalled('fetchOne')
->with('select libelle from codif_dewey where id_dewey=\'66\'')
->answers( 'Generalites')->beStrict();
$this->mock_sql
->whenCalled('fetchOne')
->with('select libelle from codif_dewey where id_dewey=\'77\'')
->answers('Arts')->beStrict();
Zend_Registry::set('sql', $this->mock_sql);
$this->dispatch('/recherche/simple/rubrique/D66/facette/A19684', true);
}
/** @test */
public function facettesShouldBeRemovedInRetirerUrl() {
$this->assertXPathContentContains("//a[contains(@href,'recherche/simple/rubrique/D66')]", "Retirer",$this->_response->getBody());
}
/** @test */
public function x2ShouldBeDisplayed() {
$this->assertXPathContentContains("//a[contains(@href,'recherche/simple/rubrique/X2')]", getVar("PCDM4_LIB"),$this->_response->getBody());
}