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 AbstractAbonneControllerPretsTestCase extends AbstractControllerTestCase {
protected $_old_zend_cache;
protected function _loginHook($account) {
$account->ROLE = "abonne_sigb";
$account->ROLE_LEVEL = 2;
$account->ID_USER = '123456';
$account->PSEUDO = "Florence";
$this->account = $account;
}
public function setUp() {
parent::setUp();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users')->whenCalled('save')->answers(true);
$this->florence = Class_Users::getLoader()->newInstanceWithId('123456');
$this->zend_cache = Storm_Test_ObjectWrapper::mock();
Storm_Cache::setDefaultZendCache($this->zend_cache);
$this->zend_cache
->whenCalled('remove')
->answers(true);
}
public function assertUserRemovedFromEmprunteurCache($user) {
$user_key = md5(serialize(['local',
Class_WebService_SIGB_EmprunteurCache::newInstance()->keyFor($user)]));
$this->assertTrue($this->zend_cache
->methodHasBeenCalledWithParams('remove', array($user_key)));
abstract class AbonneControllerPretsListTwoPretsTestCase extends AbstractAbonneControllerPretsTestCase {
public function setUp() {
parent::setUp();
$potter = new Class_WebService_SIGB_Emprunt('12', new Class_WebService_SIGB_Exemplaire(123));
$potter->getExemplaire()->setTitre('Potter');
$potter->parseExtraAttributes(['Dateretourprevue' => '29/10/2022',
'Section' => 'Espace jeunesse',
'Auteur' => 'JK Rowling',
'Bibliotheque' => 'Astrolabe',
'N° de notice' => '1234',
'Type' => 'P1']);
$this->fixture('Class_Exemplaire',
['id' => 967,
'id_origine' => 1234,
'zone995' => serialize([['clef' => 'a', 'valeur' => 'PotterItem']]),
'notice' => $this->fixture('Class_Notice',
['id' => 889,
'titre_principal' => 'Potter',
'unimarc' => '00577nam0 2200181 450 001001500000010001800015100004100033101000800074200010700082210003000189215001100219461002000230606002900250676000800279700004500287801005600332940000700388frOr1314913787 a9781408812792 a20140320 0103 aEng1 aHarry Potter and the deathly hallowsdHarry Potter et les reliques de la mortfJoanne Kathleen Rowling aLondrescBloomsburyd2010 a831 p. 1tHarry Potterv7 aAnglais (langue)2Rameau a420 1aRowlingbJoanne Kathleenf1965-....4070 aFRbBibliothèque de l\'agglomération de Saint-Omer apm'])]);
$alice = new Class_WebService_SIGB_Emprunt('13', new Class_WebService_SIGB_Exemplaire(456));
$alice->getExemplaire()->setTitre('Alice');
$alice->parseExtraAttributes(['Dateretourprevue' => '21/10/2010',
'Section' => 'Espace jeunesse',
'Auteur' => 'Lewis Caroll',
'Bibliotheque' => 'Almont',
'N° de notice' => '5678']);
$this->fixture('Class_Exemplaire',
['id' => 918,
'id_origine' => 5678,
'zone995' => serialize([['clef' => 'a', 'valeur' => 'AliceItem']]),
'notice' => $this->fixture('Class_Notice',
['id' => 827,
'titre_principal' => 'Alice',
'unimarc' => '01175cam0 22002771 450 001001500000010003700015100004100052101000800093102000700101105001800108106000600126200009300132210002400225211001300249215006400262300002400326307002900350330027300379345001800652461005600670700001800726701003000744801003300774856008300807940000700890frOr0354235228 a978-2-35592-635-8bbr.d7,65 EUR a20140225d2014 | |0fre|0103||||ba afre aFR a 0||y| ar1 aAlice au royaume de TrèfleeCheshire cat Waltzh5fQuinRosegdessin Mamenosuke Fujimaru aPariscKi-oond2014 1a20140227 a1 vol. (164 p.)cillustrations en noir et blancd18 x 13 cm aTraduit du japonais aSens de lecture japonais aPerdue dans la forêt aux portes, Alice tombe nez à nez avec Ace. Devenue malgré elle la confidente du chevalier, elle ne sait comment repousser ses avances. Lorsque le chat du Cheshire, qui a assisté à la scène, intervient, la rencontre tourne à l\'affrontement. b9782355926358 1tAlice au royaume de Trèfle : Cheshire cat Waltzv5 1aQuinRose4070 1aFujimarubMamenosuke4440 aFRbElectrec20140225gAFNOR uhttp://www.electre.com//GetBlob.ashx?Ean=9782355926358,0-1913692&Size=Original aLR'])]);
$emprunteur = new Class_WebService_SIGB_Emprunteur('1234', 'Florence');
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
$emprunteur->empruntsAddAll([$potter, $alice]);
$this->florence
->setFicheSigb(['type_comm' => 2, //OPSYS
'fiche' => $emprunteur,
'message' => '',
'erreur' => '',
'nom_aff' => 'FloFlo'])
->setPseudo('FloFlo');
}
}
class AbonneControllerPretsExportTwoPretsTest extends AbonneControllerPretsListTwoPretsTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/loan-export');
}
/** @test */
public function controllerAndActionShouldBeAbonnePrets() {
$this->assertController('abonne');
$this->assertAction('loan-export');
}
/** @test */
public function responseBodyShouldBeAttachment() {
$this->assertHeaderContains('Content-Disposition', 'attachment');
}
/** @test */
public function responseFileNameShouldContainsPrets() {
$this->assertHeaderContains('Content-Disposition', 'filename="prets_');
$this->assertHeaderContains('Content-Type', 'name="prets_');
}
/** @test */
public function bodyShouldContainsUnimarcs() {
$this->assertSame('01200nam0 22002891 450 001001400000010003700014100004100051101000800092102000700100105001800107106000600125200009300131210002400224211001300248215006400261300002400325307002900349330027300378345001800651461005600669700001800725701003000743801003300773856008300806940000700889995001400896frOr0354235228 a978-2-35592-635-8bbr.d7,65 EUR a20140225d2014 | |0fre|0103||||ba afre aFR a 0||y| ar1 aAlice au royaume de TrefleeCheshire cat Waltzh5fQuinRosegdessin Mamenosuke Fujimaru aPariscKi-oond2014 1a20140227 a1 vol. (164 p.)cillustrations en noir et blancd18 x 13 cm aTraduit du japonais aSens de lecture japonais aPerdue dans la foret aux portes, Alice tombe nez a nez avec Ace. Devenue malgre elle la confidente du chevalier, elle ne sait comment repousser ses avances. Lorsque le chat du Cheshire, qui a assiste a la scene, intervient, la rencontre tourne a l\'affrontement. b9782355926358 1tAlice au royaume de Trefle : Cheshire cat Waltzv5 1aQuinRose4070 1aFujimarubMamenosuke4440 aFRbElectrec20140225gAFNOR uhttp://www.electre.com//GetBlob.ashx?Ean=9782355926358,0-1913692&Size=Original aLR 1aAliceItem00603nam0 22001931 450 001001400000010001800014100004100032101000800073200010700081210003000188215001100218461002000229606002900249676000800278700004500286801005600331940000700387995001500394frOr1314913787 a9781408812792 a20140320 0103 aEng1 aHarry Potter and the deathly hallowsdHarry Potter et les reliques de la mortfJoanne Kathleen Rowling aLondrescBloomsburyd2010 a831 p. 1tHarry Potterv7 aAnglais (langue)2Rameau a420 1aRowlingbJoanne Kathleenf1965-....4070 aFRbBibliotheque de l\'agglomeration de Saint-Omer apm 1aPotterItem',
$this->_response->getBody());
}
}
class AbonneControllerPretsListTwoPretsTest extends AbonneControllerPretsListTwoPretsTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/prets');
}
/** @test */
public function controllerAndActionShouldBeAbonnePrets() {
$this->assertController('abonne');
$this->assertAction('prets');
}
/** @test */
public function cacheShouldHaveBeenCleared() {
$this->assertUserRemovedFromEmprunteurCache($this->florence);
}
/** @test */
public function userNameShouldBePresent() {
$this->assertQueryContentContains('div.abonneTitre', 'FloFlo');
}
/** @test */
public function loanExportLinkShouldBePresent() {
$this->assertXPathContentContains('//a[contains(@href, "/abonne/loan-export")]',
'Export unimarc',
$this->_response->getBody());
/** @test */
public function tableShouldHaveClassTableSorter() {
$this->assertXPath('//table[@class="tablesorter"]');
}
/** @test */
public function tableSorterShouldBeLoaded() {
$this->assertXPath('//script[contains(@src, "tablesorter.min")]');
$this->assertXPath('//link[contains(@href, "tablesorter/css/theme.default.css")]');
$this->assertXPathContentContains('//script', '$(".tablesorter").tablesorter()');
}
/** @test */
public function aliceLoanShouldBePresent() {
$this->assertXPathContentContains("//tbody/tr[1][@class=\"pret_en_retard\"]//td//a[contains(@href, '/recherche/viewnotice/id/827/retour_abonne/prets')]",
'Alice');
/** @test */
public function aliceLibraryShouldBeAlmont() {
$this->assertXPathContentContains("//tbody/tr[1]//td", 'Almont');
/** @test */
public function aliceAuthorShouldBeLewisCaroll() {
$this->assertXPathContentContains("//tbody/tr[1]//td", 'Lewis Caroll');
/** @test */
public function aliceDueDateShouldBeTwentyOneOctober() {
$this->assertXPathContentContains("//tbody/tr[1]//td", '21/10/2010');
/** @test */
public function aliceLoanShouldHaveExtendLink() {
$this->assertXPathContentContains("//tbody/tr[1]//td//a[@href='/abonne/prolongerPret/id_pret/13']",
/** @test */
public function potterLoanShouldBePresent() {
$this->assertXPathContentContains("//tbody/tr[2]//td", 'Potter', $this->_response->getBody());
/** @test */
public function potterLibraryShouldBeAstrolab() {
$this->assertXPathContentContains("//tbody/tr[2]//td", 'Astrolabe');
/** @test */
public function potterAuthorShouldBeJKRolling() {
$this->assertXPathContentContains("//tbody/tr[2]//td", 'JK Rowling');
/** @test */
public function potterDueDateShouldBeTwentyNineOctober2022() {
$this->assertXPathContentContains("//tbody/tr[2][not(@class)]//td", '29/10/2022');
/** @test */
public function potterLoanShouldHaveExtendLink() {
$this->assertXPathContentContains("//tbody/tr[2]//td//a[@href='/abonne/prolongerPret/id_pret/12']",
/** @test **/
public function colonneInformationShouldBeDisplay(){
$this->assertXPathContentContains('//thead//th','Informations');
}
/** @test **/
public function colonneInformationShouldContainsP1(){
$this->assertXPathContentContains('//tbody//td','P1', $this->_response->getBody());
}
class AbonneControllerPretsListReservationTest extends AbstractAbonneControllerPretsTestCase {
public function setUp() {
parent::setUp();
Class_Exemplaire::beVolatile();
$potter =
(new Class_WebService_SIGB_Reservation('12',
(new Class_WebService_SIGB_Exemplaire(123))->setTitre('Potter')))
->parseExtraAttributes(array('Etat' => 'Réservation émise',
'Rang' => '2',
'Bibliotheque' => 'Tombouctou',
'N° de notice' => 564));
Class_Exemplaire::newInstance(['id_origine' => 564,
'notice' => $this->fixture('Class_Notice',
['id' => 823,
'titre_principal' => 'Potter'])
])->assertSave();
$dobby =
(new Class_WebService_SIGB_Reservation('13',
(new Class_WebService_SIGB_Exemplaire(124))->setTitre('Dobby')))
->parseExtraAttributes(array('Etat' => 'Réservation émise',
'Rang' => '2',
'N° de notice' => 565));
Class_Exemplaire::newInstance(['id_origine' => 565,
'notice' => $this->fixture('Class_Notice',
['id' => 824,
'titre_principal' => 'Dobby'])
])->assertSave();
$this->florence
->setFicheSigb(['type_comm' => Class_IntBib::COM_OPSYS,
'fiche' => (new Class_WebService_SIGB_Emprunteur('1234', 'Florence'))
->reservationsAddAll([$potter, $dobby]),
'message' => '',
'erreur' => '',
'nom_aff' => 'FloFlo']);
$this->dispatch('/opac/abonne/reservations');
}
/** @test */
public function controllerShouldBeAbonne() {
/** @test */
public function cacheShouldHaveBeenCleared() {
$this->assertUserRemovedFromEmprunteurCache($this->florence);
}
/** @test */
public function actionShouldBeReservations() {
$this->assertAction('reservations');
}
/** @test */
public function nomShouldBeFloFlo() {
$this->assertQueryContentContains('div.abonneTitre', 'FloFlo');
/** @test */
public function tableShouldHaveClassTableSorter() {
$this->assertXPath('//table[@class="tablesorter"]');
}
/** @test */
public function tableSorterShouldBeLoaded() {
$this->assertXPath('//script[contains(@src, "tablesorter.min")]');
}
public function titreShouldBePotterAndLinkToNotice() {
$this->assertXPathContentContains('//tbody/tr[1]//td//a[contains(@href, "recherche/viewnotice/id/823/retour_abonne/reservations")]',
'Potter',
$this->_response->getBody());
/** @test */
public function etatShouldBeReservationEmise() {
$this->assertXPathContentContains('//tbody/tr[1]//td', 'Réservation émise');
/** @test */
public function rangShouldBeTwo() {
$this->assertXPathContentContains('//tbody/tr[1]//td', '2');
/** @test */
public function linkToDeleteShouldBeAsExpected() {
$this->assertXPath("//tbody/tr[1]//td//a[@href='/abonne/reservations/id_delete/12']");
/** @test */
public function bibliothequeShouldBeTombouctou() {
$this->assertXPathContentContains('//tbody/tr[1]//td', 'Tombouctou', $this->_response->getBody());
/** @test */
public function secondReservationTitleShouldBeDobby() {
$this->assertXPathContentContains('//tbody/tr[2]//td//a', 'Dobby',
$this->_response->getBody());
}