<?php /** * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. * * 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). * * 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 * 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 { 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'); } } 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"]'); } } ?>