Skip to content
Snippets Groups Projects
AbonneVSmartTest.php 6.02 KiB
Newer Older
llaffont's avatar
llaffont committed
<?php
/**
 * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
 *
Laurent's avatar
Laurent committed
 * BOKEH is free software; you can redistribute it and/or modify
llaffont's avatar
llaffont committed
 * 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).
 *
Laurent's avatar
Laurent committed
 * BOKEH is distributed in the hope that it will be useful,
llaffont's avatar
llaffont committed
 * 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
Laurent's avatar
Laurent committed
 * along with BOKEH; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
llaffont's avatar
llaffont committed
 */

require_once 'AbstractControllerTestCase.php';

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