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
abstract class AbstractAbonneControllerFicheTest extends AbstractControllerTestCase {
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 {
public function setUp() {
parent::setUp();
$this->marcus->beAdminPortail();
$this->dispatch('/abonne/fiche', true);
}
/** @test */
public function linkShouldToSuggestionAchatShouldBePresent() {
$this->assertXPathContentContains('//a[contains(@href, "/abonne/suggestion-achat")]',
'Suggérer un achat');
}
/** @test */
public function linkToPretsShouldNotBePresent() {
$this->assertNotXPath('//a[contains(@href, "/abonne/prets")]');
}
/** @test */
public function linkToReservationsShouldNotBePresent() {
$this->assertNotXPath('//a[contains(@href, "/abonne/reservations")]');
}
/** @test */
public function linkToLogoutShouldBePresent() {
$this->assertXPath('//a[contains(@href, "/auth/logout")]');
}
}
class AbonneControllerFicheAsAbonneTest extends AbstractAbonneControllerFicheTest {
public function setUp() {
parent::setUp();
$this->marcus->beAbonneSIGB();
$this->dispatch('/abonne/fiche', true);
}
/** @test */
public function linkToPretsShouldBePresent() {
$this->assertXPath('//a[contains(@href, "/abonne/prets")]');
}
/** @test */
public function linkToReservationsShouldNotBePresent() {
$this->assertXPath('//a[contains(@href, "/abonne/reservations")]');
}
/** @test */
public function linkToLogoutShouldBePresent() {
$this->assertXPath('//a[contains(@href, "/auth/logout")]');
}
/** @test */
public function marcusFirstNameShouldBePresent() {
$this->assertXPathContentContains('//div[@class="abonneTitre"]', 'Marcus');
}
/** @test */
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 {
public function setUp() {
parent::setUp();
ZendAfi_Auth::getInstance()->clearIdentity();
$this->dispatch('/abonne/fiche', true);
}
/** @test */
public function controllerShouldBeAuth() {
$this->assertController('auth');
}
/** @test */
public function formLoginShouldBePresent() {
$this->assertXPath('//form[@action="/auth/login"]');
}
/** @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")]',