Newer
Older
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 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).
*
* AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once 'AbstractControllerTestCase.php';
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
trait TAbonneControllerMultimediaFixtureHoldSuccessOnSept12 {
protected function _launch() {
$this->onLoaderOfModel('Class_Multimedia_Location')
->whenCalled('findByIdOrigine')
->answers(Class_Multimedia_Location::newInstanceWithId(1));
$this->onLoaderOfModel('Class_Multimedia_Device')
->whenCalled('findByIdOrigineAndLocation')
->answers(Class_Multimedia_Device::newInstanceWithId(1));
$this->onLoaderOfModel('Class_Multimedia_DeviceHold')
->whenCalled('getHoldOnDeviceAtTime')
->answers(Class_Multimedia_DeviceHold::newInstanceWithId(333)
->setIdUser($this->_user->getId())
->setEnd(strtotime('2012-09-12 16:40:00')));
parent::_launch();
}
}
trait TAbonneControllerMultimediaFixtureWithUserLaurentInDevsAgiles {
protected function _initUser() {
$this->_user = AbonneControllerMultimediaUsersFixtures::getLaurent();
$this->_group= 'Devs agiles';
}
}
abstract class AbonneControllerMultimediaAuthenticateTestCase extends AbstractControllerTestCase {
protected $_json;
public function setUp() {
parent::setUp();
Zend_Auth::getInstance()->clearIdentity();
}
/**
* @param $url string
* @return stdClass
*/
protected function getJson($url) {
$this->dispatch($url, true);
return json_decode($this->_response->getBody());
}
/**
* @param $user Class_Users
*/
protected function _expectUserToLoad($user) {
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users')
->whenCalled('findFirstBy')
->with(array('login'=> $user->getLogin()))
->answers($user)
->whenCalled('findFirstBy')
->answers(null);
}
/**
* @param $user Class_Users
* @param $group_label string
*/
protected function _expectGroupForUser($user, $group_label) {
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_UserGroupMembership')
->whenCalled('findAllBy')
->with(array('role' => 'user', 'model' => $user))
->answers(array(Class_UserGroupMembership::getLoader()
->newInstance()
->setUserGroup(Class_UserGroup::getLoader()
->newInstanceWithId(1)
->setLibelle($group_label))));
}
}

llaffont
committed
class AbonneControllerMultimediaAuthenticateValidationTest extends AbonneControllerMultimediaAuthenticateTestCase {
public function setUp() {
parent::setUp();
$this->_expectUserToLoad(AbonneControllerMultimediaUsersFixtures::getLaurent());
/** @test */
public function responseShouldNotBeARedirect() {
$json = $this->getJson('/abonne/authenticate/login/any/password/any');
/** @test */
public function withoutPosteShouldReturnErrorMissingParameter() {
$json = $this->getJson('/abonne/authenticate/login/any');
$this->assertEquals('MissingParameter', $json->error);
}
/** @test */
public function withoutSiteShouldReturnErrorMissingParameter() {
$json = $this->getJson('/abonne/authenticate/login/any/password/any/poste/1');
$this->assertEquals('MissingParameter', $json->error);
}
/** @test */
public function getAbonneZorkShouldReturnErrorUserNotFound() {
$json = $this->getJson('/abonne/authenticate/login/any/password/toto/poste/1/site/1');
$this->assertEquals("UserNotFound", $json->error);
}
/** @test */
public function authenticateAbonneLaurentPasswordXXXShouldReturnWrongPassword() {
$json = $this->getJson('/abonne/authenticate/login/laurent/password/xxx/poste/1/site/1');
$this->assertEquals("PasswordIsWrong", $json->error);
}

llaffont
committed
class AbonneControllerMultimediaAuthenticateMireilleTest extends AbonneControllerMultimediaAuthenticateTestCase {
public function setUp() {
parent::setUp();
$user = AbonneControllerMultimediaUsersFixtures::getMireille();
$this->_expectUserToLoad($user);
$this->_json = $this->getJson('/abonne/authenticate/login/mireille/password/afi/poste/1/site/1');
}
public function shouldReturnSubscriptionExpired() {
$this->assertEquals('SubscriptionExpired', $this->_json->error);
}
}

llaffont
committed
abstract class AbonneControllerMultimediaAuthenticateValidTestCase extends AbonneControllerMultimediaAuthenticateTestCase {
protected $_user;
protected $_group;
public function setUp() {
parent::setUp();
$this->_initUser();
$this->_expectUserToLoad($this->_user);
$this->_expectGroupForUser($this->_user, $this->_group);
$this->_launch();
}
protected function _launch() {
$this->_json = $this->getJson(sprintf('/abonne/authenticate/login/%s/password/%s/poste/1/site/1',
$this->_user->getLogin(),
$this->_user->getPassword()));
}
protected function _initUser() {}
}

llaffont
committed
class AbonneControllerMultimediaAuthenticateLaurentTest extends AbonneControllerMultimediaAuthenticateValidTestCase {
use
TAbonneControllerMultimediaFixtureHoldSuccessOnSept12,
TAbonneControllerMultimediaFixtureWithUserLaurentInDevsAgiles;
/** @test */
public function shouldNotReturnError() {
$this->assertFalse(property_exists($this->_json, 'error'));
/** @test */
public function idShoudBe8() {
$this->assertEquals('8', $this->_json->id);
/** @test */
public function loginShoudBelaurent() {
$this->assertEquals('laurent', $this->_json->login);
/** @test */
public function passwordShoudBeAfi() {
$this->assertEquals('afi', $this->_json->password);
}
/** @test */
public function nomShoudBelaffont() {
$this->assertEquals('laffont', $this->_json->nom);
/** @test */
public function prenomShoudBelaurent() {
$this->assertEquals('laurent', $this->_json->prenom);
/** @test */
public function dateNaissanceShoudBe1978_02_17() {
$this->assertEquals('1978/02/17', $this->_json->date_naissance);
/** @test */
public function groupShoudBeAdulteAbonneAdminAndAgile() {
$this->assertEquals(array('adulte','abonne','admin_bib', 'Devs agiles'),
$this->_json->groupes);
/** @test */
public function shouldHaveHold() {
$this->assertEquals(1, $this->_json->auth);
public function holdShouldLastUntil16h40() {

llaffont
committed
$this->assertEquals('2012-09-12T16:40:00+02:00', $this->_json->until);
}

llaffont
committed
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
class AbonneControllerMultimediaAuthenticateLaurentDeviceNotFoundTest extends AbonneControllerMultimediaAuthenticateValidTestCase {
use TAbonneControllerMultimediaFixtureWithUserLaurentInDevsAgiles;
protected function _launch() {
$this->onLoaderOfModel('Class_Multimedia_Location')
->whenCalled('findByIdOrigine')
->answers(Class_Multimedia_Location::newInstanceWithId(1));
$this->onLoaderOfModel('Class_Multimedia_Device')
->whenCalled('findByIdOrigineAndLocation')
->answers(null);
parent::_launch();
}
/** @test */
public function jsonShouldContainsErrorDeviceNotFound() {
$this->assertEquals('DeviceNotFound', $this->_json->error);
}
}
class AbonneControllerMultimediaAuthenticateArnaudTest extends AbonneControllerMultimediaAuthenticateValidTestCase {
use TAbonneControllerMultimediaFixtureHoldSuccessOnSept12;
protected function _initUser() {
$this->_user = AbonneControllerMultimediaUsersFixtures::getArnaud();
$this->_group= 'Patrons';
public function groupsShouldBeInviteAndPatrons() {
$this->assertEquals(array('invite', 'Patrons'), $this->_json->groupes);
}
/** @test */
public function shouldNotReturnError() {
$this->assertFalse(property_exists($this->_json, 'error'));
}
}
class AbonneControllerMultimediaAuthenticateBaptisteTest extends AbonneControllerMultimediaAuthenticateValidTestCase {
use TAbonneControllerMultimediaFixtureHoldSuccessOnSept12;
protected function _initUser() {
$this->_user = AbonneControllerMultimediaUsersFixtures::getBaptiste();
$this->_group= 'Devs Oldschool';
}
/** @test */
public function groupsShouldBeMineurAbonneAndOldSchool() {
$this->assertEquals(array('mineur','abonne_sigb', 'Devs Oldschool'), $this->_json->groupes);

llaffont
committed
/* Début test du workflow de réservation */
abstract class AbonneControllerMultimediaHoldTestCase extends AbstractControllerTestCase {
protected $_session;

pbarroca
committed
protected $_bean;
public function setUp() {
parent::setUp();
$this->_session = new Zend_Session_Namespace('abonneController');

pbarroca
committed
$bean = new stdClass();
$bean->location = 0;
$bean->day = '';
$bean->time = '';
$bean->duration = 0;
$bean->device = 0;
$this->_session->holdBean = $this->_bean = $bean;

llaffont
committed
Class_Users::getIdentity()
->setUserGroups([Class_UserGroup::newInstanceWithId(12)
->setMaxDay(120)
->setMaxWeek(240)
->setMaxMonth(360)]);

llaffont
committed
$this
->onLoaderOfModel('Class_Multimedia_DeviceHold')
->whenCalled('getDurationForUserBetweenTimes')
->answers(0);
}
protected function _prepareLocationInSession() {

pbarroca
committed
$this->_bean->location = 123;

llaffont
committed
Class_Bib::newInstanceWithId(3)
->setLibelle('Antibes');

llaffont
committed

llaffont
committed
Class_Multimedia_Location::newInstanceWithId(123)
->setIdSite(3)
->setLibelle('Antibes')
->setSlotSize(30)
->setMaxSlots(4)
->setHoldDelayMin(0)
->setHoldDelayMax(60)
->setOuvertures([Class_Ouverture::chaqueLundi('08:30', '12:00', '12:00', '17:45')->setId(1)->cache(),
Class_Ouverture::chaqueMercredi('08:30', '12:00', '12:00', '17:45')->setId(3)->cache(),
Class_Ouverture::chaqueJeudi('08:30', '12:00', '12:00', '17:45')->setId(4)->cache()]);

pbarroca
committed
protected function _prepareDayInSession() {

llaffont
committed
$this->_bean->day = '2012-09-12';

pbarroca
committed
}
protected function _prepareTimeAndDurationInSession() {
$this->_bean->time = '9:45';
$this->_bean->duration = 45;
}
protected function _assertCurrentTimelineStep($step) {
$this->_assertTimeLineStepWithClass($step, 'selected');
}
protected function _assertPassedTimelineStep($step) {
$this->_assertTimeLineStepWithClass($step, 'passed');
}
protected function _assertTimeLineStepWithClass($step, $class) {
$this->assertXPathContentContains('//div[@class="timeline"]//li[@class="' . $class . '"]',
$step);
}

llaffont
committed
/* Premier écran de choix du lieu */
class AbonneControllerMultimediaHoldLocationTest extends AbonneControllerMultimediaHoldTestCase {
public function setUp() {
parent::setUp();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Multimedia_Location')
->whenCalled('findAllBy')
->answers(array(
Class_Multimedia_Location::getLoader()->newInstanceWithId(1)
->setLibelle('Salle 1'),
Class_Multimedia_Location::getLoader()->newInstanceWithId(2)
->setLibelle('Salle 2')));
$this->dispatch('/abonne/multimedia-hold-location', true);
}
/** @test */
public function currentTimelineStepShouldBeLieu() {
$this->_assertCurrentTimelineStep('Lieu');
}
/** @test */
public function locationSalle1ShouldBePresent() {

pbarroca
committed
$this->assertXPathContentContains('//a[contains(@href, "/multimedia-hold-location/location/1")]', 'Salle 1');
}
/** @test */
public function locationSalle2ShouldBePresent() {

pbarroca
committed
$this->assertXPathContentContains('//a[contains(@href, "/multimedia-hold-location/location/2")]', 'Salle 2');
}
}

llaffont
committed
/* Validation du lieu, on est redirigé sur l'écran choix du jour */

pbarroca
committed
class AbonneControllerMultimediaHoldLocationChoiceTest extends AbonneControllerMultimediaHoldTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/abonne/multimedia-hold-location/location/1', true);
}
/** @test */
public function shouldRedirectToNextStep() {
$this->assertRedirectTo('/abonne/multimedia-hold-day');
}
/** @test */
public function beanShouldHaveLocationSet() {
$this->assertEquals(1, $this->_session->holdBean->location);

llaffont
committed
/* Second écran choix du jour */
class AbonneControllerMultimediaHoldDayTest extends AbonneControllerMultimediaHoldTestCase {
public function setUp() {
parent::setUp();

pbarroca
committed
$this->_prepareLocationInSession();
$this->dispatch('/abonne/multimedia-hold-day', true);
/** @test */
public function currentTimelineStepShouldBeJour() {
$this->_assertCurrentTimelineStep('Jour');
}
/** @test */
public function timelineStepShouldBePassed() {
$this->_assertPassedTimelineStep('Lieu');
}
/** @test */
public function calendarShouldBePresent() {
$this->assertXPath('//div[@class="calendar"]');
}
}

llaffont
committed
/* Validation du second écran choix du jour, redirection vers le choix de l'heure */

pbarroca
committed
class AbonneControllerMultimediaHoldDayChoiceTest extends AbonneControllerMultimediaHoldTestCase {
public function setUp() {
parent::setUp();
$this->_prepareLocationInSession();

llaffont
committed
$this->dispatch('/abonne/multimedia-hold-day/day/2012-09-12', true);

pbarroca
committed
}
/** @test */
public function shouldRedirectToNextStep() {
$this->assertRedirectTo('/abonne/multimedia-hold-hours');
}
/** @test */
public function beanShouldHaveDaySet() {

llaffont
committed
$this->assertEquals('2012-09-12', $this->_session->holdBean->day);

pbarroca
committed
}
}

llaffont
committed
/* Validation du second écran mais l'utilisateur a dépassé son quota de réservation */
class AbonneControllerMultimediaHoldDayChoiceWithOverQuotaTest extends AbonneControllerMultimediaHoldTestCase {
public function setUp() {
parent::setUp();
$this->_prepareLocationInSession();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Multimedia_DeviceHold')
->whenCalled('getDurationForUserBetweenTimes')
->answers(8000);

llaffont
committed
$this->dispatch('/abonne/multimedia-hold-day/day/2012-09-12', true);
}
/** @test */
public function shouldNotRedirect() {
$this->assertNotRedirect();
}
/** @test */
public function quotaErrorShouldBePresent() {
$this->assertXPathContentContains('//div', 'Quota déjà atteint ce jour');
}
}

llaffont
committed
/* Troisième écran choix de l'heure de début de réservation */
class AbonneControllerMultimediaHoldHoursTest extends AbonneControllerMultimediaHoldTestCase {
public function setUp() {
parent::setUp();
$this->_prepareLocationInSession();

pbarroca
committed
$this->_prepareDayInSession();
Class_Multimedia_Location::setTimeSource(Storm_Test_ObjectWrapper::mock()
->whenCalled('time')

llaffont
committed
->willDo(function() {return strtotime('2012-09-12 09:00:00');}));

pbarroca
committed
$this->dispatch('/abonne/multimedia-hold-hours', true);
/** @test */
public function currentTimelineStepShouldBeHoraires() {
$this->_assertCurrentTimelineStep('Horaires');
}
/** @test */
public function listOfStartTimesShouldBePresent() {
$this->assertXPathCount('//select[@id="time"]/option', 17, $this->_response->getBody());
}
/** @test */
public function startingAt10ShouldBePossible() {
$this->assertXPathContentContains('//option[@value="10:00"]', '10h00');
}
/** @test */
public function startingAt8AndHalfShouldNotBePossible() {
$this->assertNotXpath('//option[@value="08:30"]');
}

pbarroca
committed
public function oneHourDurationOptionShouldBePresent() {
$this->assertXPathContentContains('//option[@value="60"]', '1h');
}
/** @test */
public function oneHourAndAHalfDurationLinkShouldBePresent() {

pbarroca
committed
$this->assertXPathContentContains('//option[@value="90"]', '1h30mn');
}
}

llaffont
committed
/* Troisième écran choix de l'heure, redirection sur le choix du poste */

pbarroca
committed
class AbonneControllerMultimediaHoldHoursChoiceTest extends AbonneControllerMultimediaHoldTestCase {
public function setUp() {
parent::setUp();
$this->_prepareLocationInSession();
$this->_prepareDayInSession();
$this->dispatch('/abonne/multimedia-hold-hours/time/' . urlencode('9:45') . '/duration/45', true);
}
/** @test */
public function shouldRedirectToNextStep() {
$this->assertRedirectTo('/abonne/multimedia-hold-device');
}
/** @test */
public function beanShouldHaveTimeAndDurationSet() {
$this->assertEquals('9:45', $this->_session->holdBean->time);
$this->assertEquals('45', $this->_session->holdBean->duration);

llaffont
committed
/* Troisième écran choix d'une heure déjà allouée */

pbarroca
committed
class AbonneControllerMultimediaHoldHoursChooseAlreadyHeldTest extends AbonneControllerMultimediaHoldTestCase {
public function setUp() {
parent::setUp();
$this->_prepareLocationInSession();
$this->_prepareDayInSession();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Multimedia_DeviceHold')
->whenCalled('countBetweenTimesForUser')
->answers(1);
$this->dispatch('/abonne/multimedia-hold-hours/time/' . urlencode('9:45') . '/duration/45', true);
}
/** @test */
public function errorMessageShouldBePresent() {
$this->assertXPathContentContains('//div[@class="error"]', 'Vous avez déjà une réservation dans ce créneau horaire');
}
}

llaffont
committed
/* Quatrième écran choix du poste */
class AbonneControllerMultimediaHoldDeviceTest extends AbonneControllerMultimediaHoldTestCase {
public function setUp() {
parent::setUp();
$this->_prepareLocationInSession();

pbarroca
committed
$this->_prepareDayInSession();
$this->_prepareTimeAndDurationInSession();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Multimedia_DeviceGroup')
->whenCalled('findAllBy')
->answers(array(Class_Multimedia_DeviceGroup::getLoader()
->newInstanceWithId(3)));
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Multimedia_Device')
->whenCalled('findAllBy')
->answers(array(Class_Multimedia_Device::getLoader()
->newInstanceWithId(1)
->setLibelle('Poste 1')
->setOs('Ubuntu Lucid')
->setDisabled(0)));
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Multimedia_DeviceHold')
->whenCalled('countBy')
->answers(0);

pbarroca
committed
$this->dispatch('/abonne/multimedia-hold-device', true);
/** @test */
public function currentTimelineStepShouldBePoste() {
$this->_assertCurrentTimelineStep('Poste');
}
/** @test */
public function posteUnShouldBeHoldable() {
$this->assertXPathContentContains(

pbarroca
committed
'//a[contains(@href, "multimedia-hold-device/device/1")]',
'Poste 1', $this->_response->getBody());
}
}

llaffont
committed
/* Quatrième écran validation du choix du poste, redirection vers la confirmation */

pbarroca
committed
class AbonneControllerMultimediaHoldDeviceChoiceTest extends AbonneControllerMultimediaHoldTestCase {
public function setUp() {
parent::setUp();
$this->_prepareLocationInSession();
$this->_prepareDayInSession();
$this->_prepareTimeAndDurationInSession();
$this->dispatch('/abonne/multimedia-hold-device/device/1', true);
}
/** @test */
public function shouldRedirectToNextStep() {
$this->assertRedirectTo('/abonne/multimedia-hold-confirm');
}
/** @test */
public function beanShouldHaveDeviceSet() {
$this->assertEquals(1, $this->_session->holdBean->device);
}
}

llaffont
committed
/* Cinquième écran confirmation de la réservation */

pbarroca
committed
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
class AbonneControllerMultimediaHoldConfirmTest extends AbonneControllerMultimediaHoldTestCase {
public function setUp() {
parent::setUp();
$this->_prepareLocationInSession();
$this->_prepareDayInSession();
$this->_prepareTimeAndDurationInSession();
$this->_bean->device = 23;
Class_Multimedia_Device::getLoader()->newInstanceWithId(23)
->setLibelle('Poste 1')
->setOs('Ubuntu Lucid');
$this->dispatch('/abonne/multimedia-hold-confirm', true);
}
/** @test */
public function currentTimelineStepShouldBeConfirmation() {
$this->_assertCurrentTimelineStep('Confirmation');
}
/** @test */
public function locationShouldBeAntibes() {
$this->assertXPathContentContains('//li', 'Lieu : Antibes');
}
/** @test */

llaffont
committed
public function dayShouldBeSeptemberTwelve2012() {
$this->assertXPathContentContains('//li', 'Jour : 12 septembre 2012');

pbarroca
committed
}
/** @test */
public function startTimeShouldBe9h45() {
$this->assertXPathContentContains('//li', 'À partir de : 9h45');
}
/** @test */
public function durationShouldBeFortyFiveMinutes() {
$this->assertXPathContentContains('//li', 'Durée : 45mn');
}
/** @test */
public function deviceShouldBePoste1() {
$this->assertXPathContentContains('//li', 'Poste : Poste 1 - Ubuntu Lucid');
}
/** @test */
public function confirmationLinkShouldBePresent() {
$this->assertXPathContentContains('//a[contains(@href, "multimedia-hold-confirm/validate/1")]', 'Confirmer');

pbarroca
committed

llaffont
committed
/* Cinquième écran, réservation confirmée */

pbarroca
committed
class AbonneControllerMultimediaHoldConfirmValidatedTest extends AbonneControllerMultimediaHoldTestCase {
public function setUp() {
parent::setUp();
$this->_prepareLocationInSession();
$this->_prepareDayInSession();
$this->_prepareTimeAndDurationInSession();
$this->_bean->device = 23;
Class_Multimedia_Device::getLoader()->newInstanceWithId(23)
->setLibelle('Poste 1')
->setOs('Ubuntu Lucid');
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Multimedia_DeviceHold')
->whenCalled('save')
->willDo(function ($model) {$model->setId(455);return true;});
$this->dispatch('/abonne/multimedia-hold-confirm/validate/1', true);
}
/** @test */
public function shouldRedirectToHoldView() {
$this->assertRedirectTo('/abonne/multimedia-hold-view/id/455');
}
}

llaffont
committed
/* Sixième écran, visualisation de la réservation */

pbarroca
committed
class AbonneControllerMultimediaHoldViewTest extends AbonneControllerMultimediaHoldTestCase {
public function setUp() {
parent::setUp();
Class_Multimedia_DeviceHold::getLoader()->newInstanceWithId(455)
->setUser(Class_Users::getLoader()->getIdentity())
->setDevice(Class_Multimedia_Device::getLoader()->newInstanceWithId(34)
->setLibelle('Poste 34')
->setOs('Archlinux')
->setGroup(Class_Multimedia_DeviceGroup::getLoader()->newInstanceWithId(1)
->setLibelle('Groupe 1')
->setLocation(Class_Multimedia_Location::getLoader()->newInstanceWithId(1)
->setLibelle('Antibes'))))
->setStart(strtotime('2012-12-28 14:30:00'))
->setEnd(strtotime('2012-12-28 16:00:00'));
$this->dispatch('/abonne/multimedia-hold-view/id/455', true);
}
/** @test */
public function locationShouldBeAntibes() {
$this->assertXPathContentContains('//li', 'Lieu : Antibes');
}
/** @test */

llaffont
committed
public function dayShouldBeSeptemberTwentyHeight2012() {

pbarroca
committed
$this->assertXPathContentContains('//li', 'Jour : 28 décembre 2012');
}
/** @test */
public function startTimeShouldBe14h30() {
$this->assertXPathContentContains('//li', 'À partir de : 14h30');
}
/** @test */
public function durationShouldBeNinetyMinutes() {
$this->assertXPathContentContains('//li', 'Durée : 90mn');
}
/** @test */
public function deviceShouldBePoste34() {
$this->assertXPathContentContains('//li', 'Poste : Poste 34 - Archlinux');
}

pbarroca
committed
/** @test */
public function cancelationLinkShouldBePresent() {
$this->assertXPath('//a[contains(@href, "multimedia-hold-view/id/455/delete/1")]');
}

pbarroca
committed
}

llaffont
committed

pbarroca
committed
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
class AbonneControllerMultimediaHoldViewDeleteTest extends AbonneControllerMultimediaHoldTestCase {
protected $_wrapper;
public function setUp() {
parent::setUp();
Class_Multimedia_DeviceHold::getLoader()->newInstanceWithId(455)
->setUser(Class_Users::getLoader()->getIdentity());
$this->_wrapper = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Multimedia_DeviceHold')
->whenCalled('delete')
->answers(null);
$this->dispatch('/abonne/multimedia-hold-view/id/455/delete/1', true);
}
/** @test */
public function deleteShouldHaveBeenCalled() {
$this->assertTrue($this->_wrapper->methodHasBeenCalled('delete'));
}
/** @test */
public function shouldRedirectToFicheAbonne() {
$this->assertRedirectTo('/abonne/fiche');
}
}

llaffont
committed

pbarroca
committed
class AbonneControllerMultimediaHoldViewOfAnotherUserTest extends AbonneControllerMultimediaHoldTestCase {
public function setUp() {
parent::setUp();
Class_Multimedia_DeviceHold::getLoader()->newInstanceWithId(455)
->setUser(Class_Users::getLoader()->newInstanceWithId(999));
$this->dispatch('/abonne/multimedia-hold-view/id/455', true);
}
/** @test */
public function shouldRedirectToFicheAbonne() {
$this->assertRedirectTo('/abonne/fiche');
}

pbarroca
committed
}

llaffont
committed

pbarroca
committed
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
class AbonneControllerMultimediaHoldFicheAbonneTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
Class_AdminVar::getLoader()->newInstanceWithId('MULTIMEDIA_KEY')
->setValeur('aaaaaaaaaaaaaaabbaabba');
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Multimedia_DeviceHold')
->whenCalled('getFutureHoldsOfUser')
->with(Class_Users::getLoader()->getIdentity())
->answers(array(Class_Multimedia_DeviceHold::getLoader()->newInstanceWithId(12)
->setStart(strtotime('2012-28-12 14:00:00'))
->setEnd(strtotime('2012-28-12 15:00:00'))
->setDevice(Class_Multimedia_Device::getLoader()->newInstanceWithId(34)
->setLibelle('Poste 1')
->setOs('Archlinux')
->setGroup(Class_Multimedia_DeviceGroup::getLoader()->newInstanceWithId(3)
->setLocation(Class_Multimedia_Location::getLoader()->newInstanceWithId(2)
->setLibelle('Antibes'))))));
$this->dispatch('/abonne/fiche', true);
}
/** @test */
public function addHoldLinkShouldBePresent() {
$this->assertXPath('//a[contains(@href, "multimedia-hold-location")]');
}
/** @test */
public function viewHoldLinkShouldBePresent() {
$this->assertXPath('//a[contains(@href, "multimedia-hold-view/id/12")]');
}
}

llaffont
committed
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
class AbonneControllerMultimediaUsersFixtures {
public static function getLaurent() {
return Class_Users::getLoader()->newInstanceWithId(8)
->setLogin("laurent")
->setPassword("afi")
->setNom('laffont')
->setPrenom('laurent')
->setRoleLevel(4)
->setIdabon('bca2')
->setNaissance('1978-02-17');
}
public static function getBaptiste() {
return Class_Users::getLoader()->newInstanceWithId(9)
->setLogin("baptiste")
->setPassword("afi")
->setRoleLevel(2)
->setNaissance('2005-02-17')
->setDateFin('3000-01-01');
}
public static function getMireille() {
return Class_Users::getLoader()->newInstanceWithId(10)
->setLogin("mireille")
->setPassword("afi")
->setDateFin('1999-01-01');
}
public static function getArnaud() {
return Class_Users::getLoader()->newInstanceWithId(11)
->setLogin("arnaud")
->setPassword("lelache");
}