Newer
Older
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* 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).
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once 'AbstractControllerTestCase.php';
abstract class AbonneVSmartTestCase extends AbstractControllerTestCase {
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
protected
$_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->manon = Class_Users::newInstanceWithId(34, ['pseudo' => 'Marcus',
'login' => 'mlaffont',
'password' => '123',
'role_level' =>ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB]);
$this->manon->save();
ZendAfi_Auth::getInstance()->logUser($this->manon);
$emprunteur = $this->getMockBuilder('Class_WebService_SIGB_Emprunteur')
->disableOriginalConstructor()
->getMock();
$emprunteur
->expects($this->once())
->method('getEmprunts')
->will($this->returnValue([Class_WebService_SIGB_Emprunt::newInstanceWithEmptyExemplaire()
->setDateRetour('25/12/2022'),
Class_WebService_SIGB_Emprunt::newInstanceWithEmptyExemplaire()
->setDateRetour('25/12/2010')]));
$emprunteur
->expects($this->once())
->method('getNbReservations')
->will($this->returnValue(3));
$emprunteur
->expects($this->once())
->method('getUserInformationsPopupUrl')
->will($this->returnValue('http://12.34.56.78/moulins/LoginWebSSo.csp'));
$this->manon
->setPrenom('Manon')
->setNom('Laffont')
->setMail('mlaffont@gmail.com')
->setPseudo('manoune')
->setDateDebut(null)
->setFicheSIGB(array('type_comm' => Class_IntBib::COM_VSMART,
'nom_aff' => 'Marcus',
'fiche' => $emprunteur))
->setRole('abonne_sigb')
->setRoleLevel(ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB)
->setIdSite(2)
->setIdabon('00123')
->setNewsletters(array())
->setDateDebut('2001-02-16')
->setDateFin('2045-02-16');
$panier_bd = Class_PanierNotice::newInstanceWithId(2,
['id_panier' => 1,
'libelle' => 'Mes BD',
'date_maj' => '10/02/2011',
'notices' => 'COMBAT ORDINAIRE;BLACKSAD',
'user' => $this->manon]);
$panier_bd->save();
$this->panier_romans = Class_PanierNotice::newInstanceWithId(15,
['id_panier' => 2,
'libelle' => 'Mes Romans',
'date_maj' => '25/05/2010',
'notices' => 'MONTESPAN',
'user' => $this->manon]);
$this->panier_romans->save();
}

llaffont
committed
class AbonneVSmartTest extends AbonneVSmartTestCase {
Class_AdminVar::newInstanceWithId('INTERDIRE_MODIF_FICHE_ABONNE', ['valeur' => false]);
$this->dispatch('/opac/abonne/fiche/id/34', true);
}
/** @test */
function actionShouldBeFiche() {
$this->assertAction('fiche');
}
/** @test */
function aDivAbonneFicheShouldContainsVousAvezDeuxPretsEnCoursUnEnRetard() {
$this->assertXPathContentContains('//div/a[contains(@href, "abonne/prets")]',
'Vous avez 2 prêts en cours (1 en retard)');
}
/** @test */
function aDivAbonneFicheShouldContainsVousAvezTroisReservationsEnCours() {
$this->assertXPathContentContains('//div/a[contains(@href, "abonne/reservations")]',
'Vous avez 3 réservations en cours');
}
/** @test */
function aDivAbonneFicheShouldContainsVousAvezDeuxPaniersDeNotice() {
$this->assertXPathContentContains('//div/a[contains(@href, "panier")]',
'Vous avez 2 paniers',$this->_response->getBody());
}
/** @test */
function modifierMaFicheShouldBeALinkToPopup() {
$this->assertXPathContentContains('//a[@onclick="openIFrameDialog(\'http://12.34.56.78/moulins/LoginWebSSo.csp\');"]',
'Modifier ma fiche');
}
/** @test */
function abonnementShouldBeDisplayedValid() {
$this->assertXPathContentContains('//div', "Votre abonnement est valide jusqu'au 16-02-2045",
$this->_response->getBody());
}

llaffont
committed
class AbonneWithExpiredSubscriptionVSmartTest extends AbonneVSmartTestCase {
public function setUp() {
parent::setUp();
$this->manon->setDateFin('2001-12-25');
$this->dispatch('/opac/abonne/fiche/id/34');
}
/** @test */
function abonnementShouldBeDisplayedInvalid() {
$this->assertXPathContentContains('//div', "Votre abonnement est terminé depuis le 25-12-2001",
$this->_response->getBody());
}