Skip to content
Snippets Groups Projects
AbonneControllerFicheTest.php 4.39 KiB
Newer Older
<?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
 * 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,
 * 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
abstract class AbstractAbonneControllerFicheTest extends AbstractControllerTestCase {
Patrick Barroca's avatar
Patrick Barroca committed
  public function setUp() {
    parent::setUp();
    $this->marcus = Class_Users::newInstanceWithId(10,
    ['prenom' => 'Marcus',
    'nom' => 'Miller',
    'pseudo' => '']);
    ZendAfi_Auth::getInstance()->logUser($this->marcus);
  }
}



class AbonneControllerFicheAsAdminTest extends AbstractAbonneControllerFicheTest {
Patrick Barroca's avatar
Patrick Barroca committed
  public function setUp() {
    parent::setUp();
    $this->marcus->beAdminPortail();
    $this->dispatch('/abonne/fiche', true);
  }
Patrick Barroca's avatar
Patrick Barroca committed
  /** @test */
  public function linkShouldToSuggestionAchatShouldBePresent() {
    $this->assertXPathContentContains('//a[contains(@href, "/abonne/suggestion-achat")]',
                                      'Suggérer un achat');
  }
Patrick Barroca's avatar
Patrick Barroca committed
  /** @test */
  public function linkToPretsShouldNotBePresent() {
    $this->assertNotXPath('//a[contains(@href, "/abonne/prets")]');
  }
Patrick Barroca's avatar
Patrick Barroca committed
  /** @test */
  public function linkToReservationsShouldNotBePresent() {
    $this->assertNotXPath('//a[contains(@href, "/abonne/reservations")]');
  }
Patrick Barroca's avatar
Patrick Barroca committed
  /** @test */
  public function linkToLogoutShouldBePresent() {
    $this->assertXPath('//a[contains(@href, "/auth/logout")]');
  }
}




class AbonneControllerFicheAsAbonneTest extends AbstractAbonneControllerFicheTest {
Patrick Barroca's avatar
Patrick Barroca committed
  public function setUp() {
    parent::setUp();
    $this->marcus->beAbonneSIGB();
    $this->dispatch('/abonne/fiche', true);
  }
Patrick Barroca's avatar
Patrick Barroca committed
  /** @test */
  public function linkToPretsShouldBePresent() {
    $this->assertXPath('//a[contains(@href, "/abonne/prets")]');
  }
Patrick Barroca's avatar
Patrick Barroca committed
  /** @test */
  public function linkToReservationsShouldNotBePresent() {
    $this->assertXPath('//a[contains(@href, "/abonne/reservations")]');
  }
Patrick Barroca's avatar
Patrick Barroca committed
  /** @test */
  public function linkToLogoutShouldBePresent() {
    $this->assertXPath('//a[contains(@href, "/auth/logout")]');
  }
Patrick Barroca's avatar
Patrick Barroca committed
  /** @test */
  public function marcusFirstNameShouldBePresent() {
    $this->assertXPathContentContains('//div[@class="abonneTitre"]', 'Marcus');
  }
Patrick Barroca's avatar
Patrick Barroca committed
  public function marcusLastNameShouldBePresent() {
    $this->assertXPathContentContains('//div[@class="abonneTitre"]//span[@data-name="last-name"]', 'Miller');
  }
  /** @test */
  public function LoansHistoryShouldNotBeDisplayed() {
    $this->assertNotXPathContentContains('//a', 'Voir mon historique de prêts');
  }

class AbonneControllerFicheNobodyLoggedTest extends AbstractAbonneControllerFicheTest {
Patrick Barroca's avatar
Patrick Barroca committed
  public function setUp() {
    parent::setUp();
    ZendAfi_Auth::getInstance()->clearIdentity();
    $this->dispatch('/abonne/fiche', true);
  }
Patrick Barroca's avatar
Patrick Barroca committed
  /** @test */
  public function controllerShouldBeAuth() {
    $this->assertController('auth');
  }
Patrick Barroca's avatar
Patrick Barroca committed
  /** @test */
  public function formLoginShouldBePresent() {
    $this->assertXPath('//form[@action="/auth/login"]');
  }
Patrick Barroca's avatar
Patrick Barroca committed
  /** @test */
  public function hiddenInputRedirectShouldContainsAbonneFiche() {
    $this->assertXPath('//input[@name="redirect"][@value="http://localhost' . BASE_URL . '/abonne/fiche"]');
  }
class AbonneControllerFicheAsAdminDisableSuggestTest extends AbstractAbonneControllerFicheTest {
  public function setUp() {
    parent::setUp();
    $this->fixture('Class_AdminVar', ['id' => 'DISABLE_SUGGESTIONS',
                                      'valeur' => '1']);
    $this->marcus->beAdminPortail();
    $this->dispatch('/abonne/fiche', true);
  }


  /** @test */
  public function linkToSuggestionAchatShouldNotBePresent() {
    $this->assertNotXPathContentContains('//a[contains(@href, "/abonne/suggestion-achat")]',
                                         'Suggérer un achat');