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 {
$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")]',
/** @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');
}
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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"]');
}
}