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
*/
require_once 'AbstractControllerTestCase.php';
abstract class AbstractAbonneControllerFormationsTestCase extends AbstractControllerTestCase {
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
protected $_amadou;
protected $_learn_java;
protected $_learn_python;
protected $_learn_smalltalk;
protected $_session_smalltalk_janvier;
protected $_session_smalltalk_juillet;
protected $_session_java_mars;
protected $_session_java_fevrier;
protected $_session_java_septembre;
protected $_session_python_juillet;
protected $_gallice_cafe;
protected $_bib_romains;
protected $_bonlieu;
protected function _loginHook($account) {
$account->ROLE = "abonne_sigb";
$account->ROLE_LEVEL = 2;
$account->ID_USER = '435';
$account->PSEUDO = "Amadou";
}
public function setUp() {
parent::setUp();
$test_time = new TimeSourceForTest('2014-05-01 14:00:00');
Class_Users::beVolatile();
Class_SessionFormation::beVolatile();
Class_SessionFormationInscription::beVolatile();
Class_Formation::beVolatile();
Class_Formation::setTimeSource($test_time);
Class_SessionFormation::setTimeSource($test_time);
Class_AdminVar::getLoader()
->newInstanceWithId('FORMATIONS')
->setValeur('1');
$this->_amadou = $this->fixture('Class_Users',
['id' => 435,
'login' => 'Amadou',
'password' => 'pwd',
'id_abon' => 435]);
$this->_amadou
->beAbonneSIGB()
->setUserGroups([$this->fixture('Class_UserGroup',['id' => 23])->addRightSuivreFormation()]);
ZendAfi_Auth::getInstance()->logUser($this->_amadou);
$this->_gallice_cafe = $this->fixture('Class_Lieu',
['id' => 98,
'libelle' => 'Galice']);
$this->_bib_romains = $this->fixture('Class_Lieu',
['id' => '99',
'libelle' => 'Bibliothèque des romains']);
$this->_bonlieu = $this->fixture('Class_Lieu',
['id' => 100,
'libelle' => 'Bonlieu',
'adresse' => "1, rue Jean-Jaures\nBP 294",
'code_postal' => 74007,
'ville' => 'Annecy',
'latitude' => '45.902179',
'longitude' => '6.128715']);
$this->_session_smalltalk_janvier = $this->fixture('Class_SessionFormation',
['id' => 11,
'formation_id' => 1,
'effectif_min' => 1,
'effectif_max' => 10,
'lieu' => $this->_gallice_cafe,
'date_debut' => '2014-01-10']);
$this->_session_smalltalk_juillet = $this->fixture('Class_SessionFormation',
['id' => 12,
'formation_id' => 1,
'effectif_min' => 1,
'effectif_max' => 10,
'lieu' => $this->_gallice_cafe,
'stagiaires' => [],
'date_debut' => '2014-07-11']);
$this->_learn_smalltalk = $this->fixture('Class_Formation',
['id' => 1,
'libelle' => 'Learn Smalltalk',
'sessions' => [$this->_session_smalltalk_janvier,
$this->_session_smalltalk_juillet],
]);
$this->_session_java_fevrier = $this->fixture('Class_SessionFormation',
['id' => 31,
'formation_id' => 3,
'effectif_min' => 2,
'effectif_max' => 5,
'lieu' => $this->_bonlieu,
'date_debut' => '2015-02-10',
'date_fin' => '2015-02-20',
'stagiaires' => [],
'date_limite_inscription' => '2015-01-20']);
$this->_session_java_mars = $this->fixture('Class_SessionFormation',
['id' => 32,
'formation_id' => 3,
'effectif_min' => 2,
'effectif_max' => 5,
'lieu' => $this->_gallice_cafe,
'date_debut' => '2014-03-01',
'stagiaires' => [],
'date_limite_inscription' => '2014-03-01']);
$this->_session_java_septembre = $this->fixture('Class_SessionFormation',
['id' => 30,
'formation_id' => 3,
'date_debut' => '2014-09-1',
'stagiaires' => [],
'date_limit_inscription' => '2014-08-15']);
$this->_session_java_septembre->beAnnule();
$this->_learn_java = $this->fixture('Class_Formation',
['id' => 3,
'libelle' => 'Learn Java',
'description' => 'whaaat ?',
'sessions' => [$this->_session_java_mars,
$this->_session_java_septembre,
$this->_session_java_fevrier]]);
$this->_session_python_juillet = $this->fixture('Class_SessionFormation',
['id' => 121,
'formation_id' => 12,
'date_debut' => '2014-07-10',
'contenu' => 'Introduction a la syntaxe',
'objectif' => 'Ecrire un premier programme',
'effectif_min' => 1,
'effectif_max' => 150,
'duree' => 36,
'horaires' => '8h-12h, 14h-18h',
'lieu' => $this->_bib_romains,
'stagiaires' => [$this->_amadou],
'intervenants' => [$this->fixture('Class_Users',
['id' =>76,
'login' => 'jpp',
'password' => 'pwd',
'nom' => 'Pirant',
'prenom' => 'Jean-Paul']),
$this->fixture('Class_users',
['id' => 77,
'login' => 'cc',
'password' => 'pwd',
'nom' => 'Cerisier',
'prenom' => 'Christophe'])
]]);
$this->_learn_python = $this->fixture('Class_Formation',
['id' => 12,
'libelle' => 'Learn Python',
'sessions' => [$this->_session_python_juillet]]);
$inscription_amadou_python = $this->fixture('Class_SessionFormationInscription',
['id' => 1,
'stagiaire' => $this->_amadou,
'session_formation' => $this->_session_python_juillet]);
$this->_amadou->setSessionFormationInscriptions([$inscription_amadou_python]);
}
class AbonneControllerFormationsListWithLearnJavaNotVisibleTest extends AbstractAbonneControllerFormationsTestCase {
public function setUp() {
parent::setUp();
$this->_learn_java->hide()->save();
$this->dispatch('/opac/formations', true);
}
/** @test */
function noH2ShouldContainsLearnJava() {
$this->assertNotXPathContentContains('//h2', 'Learn Java');
}
/** @test */
function sessionMarsShouldNotBeVisible() {
$this->assertNotXPathContentContains('//tbody//tr//td', '1 mars 2014');
}
class AbonneControllerFormationsSessionListWithLearnSmalltalkNotVisibleTest extends AbstractAbonneControllerFormationsTestCase {
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
public function setUp() {
parent::setUp();
}
/** @test */
public function trainingJavaShouldBeDisplayed() {
$this->dispatch('/opac/formations', true);
$this->assertXPathContentContains('//h2', 'Learn Java',$this->response->getBody());
}
/** @test */
function noH2ShouldContainsLearnSmalltalk() {
$this->_learn_smalltalk->hide()->save();
$this->dispatch('/opac/formations', true);
$this->assertNotXPathContentContains('//h2', 'Learn Smalltalk');
}
/** @test */
function sessionJuilletShouldNotBeVisibleIfParentTrainingIsHidden() {
$this->_learn_smalltalk->hide()->save();
$this->dispatch('/opac/formations', true);
$this->assertNotXPathContentContains('//tbody//tr//td', '11 juillet 2014');
}
/** @test */
function sessionJuilletShouldNotBeVisibleIfHidden() {
$this->_learn_smalltalk->show()->save();
$this->_session_smalltalk_juillet->hide()->save();
$this->dispatch('/opac/formations', true);
$this->assertNotXPathContentContains('//tbody//tr//td', '11 juillet 2014');
}
/** @test */
function sessionJuilletShouldBeVisibleIfShow() {
$this->_learn_smalltalk->show()->save();
$this->_session_smalltalk_juillet->show()->save();
$this->dispatch('/opac/formations', true);
$this->assertXPathContentContains('//tbody//tr//td', '11 juillet 2014');
}
class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormationsTestCase {
Class_Profil::getCurrentProfil()
->setBarreNavOn(true)
->setLibelle('Mon compte')
->setParentProfil(
Class_Profil::newInstanceWithId(42,
['cfg_modules' => ['abonne' => ['formations' => ['barre_nav' => 'Les formations']]]]));
/** @test */
function aH2ShouldContainsLearnJava() {
$this->assertXPathContentContains('//h2', 'Learn Java');
}
/** @test */
function aDivForDescriptionShouldContainsIfYouWantTo() {
$this->assertXPathContentContains('//div', 'whaaat ?');
}
/** @test */
function aH2ShouldContainsLearnPython() {
$this->assertXPathContentContains('//h2', 'Learn Python');
}
/** @test */
function session_java_mars_ShouldNotHaveLinkForInscrireAsInscriptionClosed() {
$this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session/id/32")]');
}
/** @test */
function session_java_septembre_ShouldNotHaveLinkForInscrireAsSessionAnnule() {
$this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session/id/30")]');
}
/** @test */
function session_janvier_smalltalk_ShouldNotHaveLinkForInscrireAsFinished() {
$this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session/id/11")]');
}
/** @test */
function session_juillet_smalltalk_ShouldNotDisplayLimiteAsNotSet() {
$this->assertNotXPathContentContains('//td[@class="session_12"]', 'Limite:');
}
/** @test */
function sessionJanuary2014ShouldBeFirst() {
$this->assertXPathContentContains('//tbody//tr[1]//td', '10 janvier 2014');
}
/** @test */
function sessionMarsShouldBeFirst() {
$this->assertXPathContentContains('//tbody//tr[1]//td', '1 mars 2014');
}
/** @test */
function sessionSeptemberShouldBeSecond() {
$this->assertXPathContentContains('//tbody//tr[2]//td', ' septembre 2014');
}
/** @test */
function sessionFebruary2015ShouldBeLast() {
$this->assertXPathContentContains('//tbody//tr[3]//td', ' février 2015');
}
/** @test */
function session10Juillet2014ShouldBeFirst() {
$this->assertXPathContentContains('//tbody//tr[1]//td', '10 juillet 2014');
}
/** @test */
function session11Juillet2014ShouldSecond() {
$this->assertXPathContentContains('//tbody//tr[2]//td', '11 juillet 2014');
}
/** @test */
function session_fevrier_17_lieuBonlieuShouldBeDisplayed() {
$this->assertXPathContentContains('//tbody//tr//td', 'Bonlieu');
}
/** @test */
function session_fevrier_17_ShouldHaveLinkForInscrire() {
$this->assertXPathContentContains('//tbody//tr//a[contains(@href, "abonne/inscrire-session/id/31")]',
"S'inscrire");
}
/** @test */
function session_fevrier_17_ShouldDisplayDateLimite15Fevrier() {
$this->assertXPathContentContains('//tbody//tr/td',
'20 janvier 2015');
}
/** @test */
function session_fevrier_17_ShouldHaveLinkForDetailSessionFormation() {
$this->assertXPathContentContains('//tbody//tr//a[contains(@href, "formations/detail-session/id/31")]',
'Détails de la session');
}
/** @test */
function session_mars_27_ShouldBeDisplayedUnderLearnJavaInFirstPosition() {
$this->assertXPathContentContains('//tbody//tr[1]', '1 mars 2014');
}
/** @test */
function session_septembre_java_ShouldBeAnnule() {
$this->assertXPathContentContains('//tr/td/span[@class="error"]', 'Annul');
}
/** @test */
function session_python_juillet_ShouldHaveLinkForDesinscrire() {
$this->assertXPathContentContains('//tr//a[contains(@href, "abonne/desinscrire-session/id/121")]',
"Se désinscrire");
}
/** @test */
function boiteTitleShouldBeFormations() {
$this->assertXPathContentContains('//h1', 'Formations');
}
/**
* @test
* @group pagetitles
*/
public function barreNavShouldContainsMonCompte() {
$this->assertXPathContentContains('//div[@class="barre_nav"]//span//a[contains(@href, "index/index?id_profil=2")]',
'Mon compte');
}
/** @test */
public function barreNavShouldContainsAccueilThatLinksToProfilOne() {
$this->assertXPathContentContains('//div[@class="barre_nav"]//a[contains(@href, "index/index?id_profil=1")]',
'Accueil');
}
class AbonneControllerFormationsFicheAbonneTest extends AbstractAbonneControllerFormationsTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/fiche?retour=/opac/abonne/fiche');
}
/** @test */
public function pageShouldContainsLinkToFormations() {
$this->assertXPathContentContains('//a[contains(@href, "formations")]', 'S\'inscrire à une formation');
}
/** @test */
public function pageShouldContainsVousEtesInscritFormationPython() {
$this->assertXPathContentContains('//ul//li', 'Learn Python, 10 juillet 2014');
}
/** @test */
public function pageShouldContainsLinkToDetailSessionPyhton() {
$this->assertXPath('//li//a[contains(@href, "formations/detail-session/id/121?retour=/abonne/fiche")]',$this->_response->getBody());
}
Class AbonneControllerFormationsFicheAbonneWithoutSufficientRigthsTest extends AbstractAbonneControllerFormationsTestCase {
/** @test */
public function whenFormationsDisabledPageShouldNotContainsLinkToFormations() {
Class_AdminVar::getLoader()
->newInstanceWithId('FORMATIONS')
->setValeur('0');
$this->dispatch('/opac/abonne/fiche');
$this->assertNotXPath('//a[contains(@href, "formations")]');
}
/** @test */
public function whenUserNotStagiairePageShouldNotContainsLinkToFormations() {
$this->_amadou->setUserGroups(array());
$this->dispatch('/opac/abonne/fiche');
$this->assertNotXPath('//a[contains(@href, "formations")]');
}
}
class AbonneControllerFormationsListWithoutRightSuivreFormationTest extends AbstractAbonneControllerFormationsTestCase {
public function setUp() {
parent::setUp();
$this->_amadou->setUserGroups([]);
$this->dispatch('/opac/formations');
}
/** @test */
function linkForInscrireShouldNotExists() {
$this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session")]');
}
/** @test */
function linkForDesinscrireShouldExists() {
$this->assertXPath('//a[contains(@href, "abonne/desinscrire-session")]');
}
/** @test */
public function messageVousNavezPasLesDroitsSuffisantsShouldBeVisible() {
$this->assertXPathContentContains('//p', "Vous n'avez pas les droits");
}
class AbonneControllerFormationsAmadouInscritSessionMarsJavaClosedTest extends AbstractAbonneControllerFormationsTestCase {
/** @test */
public function inscrireSessionShouldNotCallSave() {
$this->dispatch('/opac/abonne/inscrire-session/id/32');
$this->assertNotContains($this->_amadou, Class_SessionFormationInscription::findAllBy(['session_formation_id'=>32]));
}
class AbonneControllerFormationsAmadouInscritSessionFeebruaryJavaOpenTest extends AbstractAbonneControllerFormationsTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/inscrire-session/id/31');
}
/** @test */
public function sessionJavaMarsShouldBeValid() {
$this->assertTrue($this->_session_java_fevrier->isValid(),
implode(',', $this->_session_java_fevrier->getErrors()));
}
/** @test */
function amadouShouldBeInsessionSeptembreJavaStagiaires() {
$this->assertContains($this->_amadou, $this->_session_java_fevrier->getStagiaires());
}
/** @test */
function answerShouldRedirectToFormationList() {
$this->assertRedirectTo('/formations');
}
/** @test */
function aNewInscriptionShouldHaveBeenCreated() {
$this->assertCount(1, Class_SessionFormationInscription::findAllBy(['stagiaire_id' => 435,
'session_formation_id' => 31]));
}
}
abstract class AbonneControllerFormationsSessionJavaFevrierFullTestCase extends AbstractAbonneControllerFormationsTestCase {
public function setUp() {
parent::setUp();
$this
->_session_java_fevrier
->setEffectifMax(2)
->setStagiaires(Class_UserGroup::getLoader()
->newInstanceWithId(93)
->addRightSuivreFormation()
->setUsers(array(Class_Users::getLoader()->newInstanceWithId(94)->setLogin('titi'),
Class_Users::getLoader()->newInstanceWithId(95)->setLogin('toto')))
->getUsers());
}
}
class AbonneControllerFormationsSessionJavaFevrierFullListTest extends AbonneControllerFormationsSessionJavaFevrierFullTestCase {
public function setUp() {
parent::setUp();
Class_AdminVar::newInstanceWithId('CHAMPS_FICHE_UTILISATEUR',
['valeur' => 'pseudo;nom;prenom;mail']);
$this->dispatch('/opac/formations');
}
/** @test */
function session_fevrier_17_ShouldNotHaveLinkForInscrire() {
$this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session/id/31")]');
}
/** @test */
public function sessionShouldDisplayFull() {
$this->assertXPathContentContains('//tbody//tr/td/span[@class="error"]', 'Complet');
}
}
class AbonneControllerFormationsSessionJavaFevrierFullAndInscritListTest extends AbonneControllerFormationsSessionJavaFevrierFullTestCase {
/** @test */
public function pageShouldHaveLinkToDesinscrire() {
$this->_session_java_fevrier->addStagiaire($this->_amadou);
$this->_amadou->setSessionFormations(array($this->_session_java_fevrier));
$this->dispatch('/opac/formations');
$this->assertXPath('//a[contains(@href, "abonne/desinscrire-session/id/31")]');
}
}
class AbonneControllerFormationsAmadouInscritSessionJavaFevrierFullTest extends AbonneControllerFormationsSessionJavaFevrierFullTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/inscrire-session/id/31');
}
/** @test */
public function sessionShouldNotContainsAmadou() {
$this->assertNotContains('Amadou', Class_SessionFormation::find(31)->getStagiaires());
}
/** @test */
public function userShouldNotHaveBeenSaved() {
$this->assertEmpty(Class_Users::findAllBy(['session_formations' => 31]));
}
}
class AbonneControllerFormationsInscritSessionWithoutRightSuivreFormationTest extends AbstractAbonneControllerFormationsTestCase {
public function setUp() {
parent::setUp();
$this->_amadou->setUserGroups([]);
$this->dispatch('/opac/abonne/inscrire-session/id/32');
/** @test */
public function sessionShouldNotContainsAmadou() {
$this->assertNotContains('Amadou', Class_SessionFormation::find(31)->getStagiaires());
}
/** @test */
public function amadouShouldNotBeValid() {
$this->assertFalse($this->_amadou->isValid());
}
}
class AbonneControllerFormationsAmadouDesinscritSessionJuilletPythonTest extends AbstractAbonneControllerFormationsTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/desinscrire-session/id/121');
}
/** @test */
function answerShouldRedirectToFormationList() {
$this->assertRedirectTo('/formations');
}
/** @test */
function amadouSessionsShouldNotContainsSessionJuilletPython() {
$this->assertNotContains($this->_session_python_juillet, $this->_amadou->getSessionFormations());
}
/** @test */
function inscriptionObjectShouldHaveBeenDeleted() {
$inscription = Class_SessionFormationInscription::find(1);
$this->assertEquals(121, $inscription->getSessionFormationId());
$this->assertEquals(435, $inscription->getStagiaireId());
}
}
class AbonneControllerFormationsSessionFevrierJavaTest extends AbstractAbonneControllerFormationsTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/formations/detail-session/id/31', true);
}
/** @test */
public function pageShouldContainsLinkToInscrire() {
$this->assertXPathContentContains('//a[contains(@href, "abonne/inscrire-session/id/31")]',
'S\'inscrire');
}
/** @test */
public function ddShouldContainsNombreDeParticipants() {
$this->assertXPathContentContains('//dl/dd', 'minimum: 2, maximum: 5, actuel: 0');
}
/** @test */
function ddShouldContainsAdresseBonlieu() {
$this->assertXPathContentContains('//dd', 'Bonlieu');
$this->assertXPathContentContains('//dd', '1, rue Jean-Jaures');
$this->assertXPathContentContains('//dd', '74007 Annecy');
}
/** @test */
function ddShouldContainsGoogleMap() {
$this->assertXPath('//dd//img[@src="http://maps.googleapis.com/maps/api/staticmap?sensor=false&zoom=15&size=300x300¢er=45.902179%2C6.128715&markers=45.902179%2C6.128715"]');
}
}
class AbonneControllerFormationsSessionJuilletPythonDetailTest extends AbstractAbonneControllerFormationsTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/formations/detail-session/id/121');
}
/** @test */
public function actionShouldBeDetailSession() {
$this->assertAction('detail-session');
}
/** @test */
public function titleShouldBeFormationLearnPython_SessionDu21Juillet2023() {
$this->assertXPathContentContains('//h1[contains(text(), "Learn Python")]//span', '10 juillet 2014');
}
/** @test */
public function pageShouldContainsAButtontoGoBackToFormations() {
$this->assertXPathContentContains('//a[contains(@href, "formations")]', 'Retour');
}
/** @test */
public function pageShouldContainsLinkToDesinscrire() {
$this->assertXPathContentContains('//a[contains(@href, "abonne/desinscrire-session/id/121")]',
'Se désinscrire');
}
/** @test */
public function ddShouldContainsContenu() {
$this->assertXPathContentContains('//dl[@class="session_formation"]//dd', 'Introduction a la syntaxe');
}
/** @test */
public function ddShouldContainsNombreDeParticipants() {
$this->assertXPathContentContains('//dl/dd', 'minimum: 1, maximum: 150, actuel: 1');
}
/** @test */
public function ddShouldContainsDuree() {
$this->assertXPathContentContains('//dl/dd', '36 h');
}
/** @test */
public function ddShouldContainsLieu() {
$this->assertXPathContentContains('//dl/dd', 'Bibliothèque des romains');
}
/** @test */
public function ddShouldContainsHoraires() {
$this->assertXPathContentContains('//dl/dd', '8h-12h, 14h-18h');
}
/** @test */
public function ddIntervenantsShouldContainsJpp() {
$this->assertXPathContentContains('//dd//li', 'Pirant, Jean-Paul');
}
/** @test */
public function ddIntervenantsShouldContainsCc() {
$this->assertXPathContentContains('//dd//li', 'Cerisier, Christophe');
}
}
class AbonneControllerFormationsSessionJuilletPythonDetailRetourFicheTest extends AbstractAbonneControllerFormationsTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/formations/detail-session/id/121?retour=/abonne/fiche');
}
/** @test */
public function pageShouldContainsAButtontoGoBackToFicheAbonne() {
$this->assertXPathContentContains('//a[contains(@href, "abonne/fiche")]', 'Retour', $this->_response->getBody());
}
}
class AbonneControllerFormationsWrongIdsTest extends AbstractAbonneControllerFormationsTestCase {
/** @test */
public function onDetailSessionShouldRedirectToFormations() {
$this->dispatch('/opac/formations/detail-session/id/9999');
$this->assertRedirectTo('/formations/index');
}
/** @test */
public function onInscrireSessionShouldRedirectToFormations() {
$this->dispatch('/opac/abonne/inscrire-session/id/9999');
$this->assertRedirectTo('/formations');
}
/** @test */
public function ondesinscrireSessionShouldRedirectToFormations() {
$this->dispatch('/opac/abonne/desinscrire-session/id/9999');
$this->assertRedirectTo('/formations');
}
}
Class AbonneControllerFormationsInformationsTest extends AbstractControllerTestCase {
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
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
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
public function setup() {
parent::setup();
$test_time = new TimeSourceForTest('2014-05-09 14:00:00');
Class_Formation::setTimeSource($test_time);
Class_SessionFormation::setTimeSource($test_time);
$current_user = $this->fixture('Class_Users', [
'id' => 1,
'login' => 'log',
'password' => 'pwd',
'id_site' => 1,
'idabon' => '00044958',
'role_level' => 2,
'user_groups' => [$this->fixture('Class_UserGroup',['id' => 23])->addRightSuivreFormation()]
]);
ZendAfi_Auth::getInstance()->logUser($current_user);
$session_full = $this->fixture('Class_SessionFormation',
['id' => 1,
'formation_id' => 1,
'date_debut' => '2014-07-10',
'date_limite_inscription' => '2014-07-01',
'effectif_min' => 1,
'effectif_max' => 1,
'stagiaires' => [$current_user]]);
$session_canceled = $this->fixture('Class_SessionFormation',
['id' => 1,
'formation_id' => 1,
'date_debut' => '2014-07-10',
'effectif_min' => 1,
'effectif_max' => 10,
'stagiaires' => []]);
$session_canceled->beAnnule();
$session_subscription_exhausted = $this->fixture('Class_SessionFormation',
['id' => 1,
'formation_id' => 1,
'date_debut' => '2014-07-10',
'date_limite_inscription' => '2014-01-10',
'effectif_min' => 1,
'effectif_max' => 10,
'stagiaires' => []]);
$formation = $this->fixture('Class_Formation',
['id' => 1,
'libelle' => 'Farming cerths',
'sessions' => [$session_full,
$session_canceled,
$session_subscription_exhausted]]);
$current_user->setSessionFormationInscriptions([$this->fixture('Class_SessionFormationInscription',
['id' => 1,
'stagiaire' => $current_user,
'session_formation' => $formation])]);
$this->dispatch('/opac/formations', true);
}
/** @test */
function sessionShouldBeFull() {
$this->assertXPathContentContains('//tbody//tr/td/span[@class="error"]',
'Complet');
}
/** @test */
function sessionShouldBeCanceld() {
$this->assertXPathContentContains('//tbody//tr/td/span[@class="error"]',
'Annul');
}
/** @test */
function sessionShouldBeDisplaySubscribeTimeExhaust() {
$this->assertXPathContentContains('//tbody//tr/td/span[@class="error"]',
'Date de limite d\'inscription dépassée:');
}
/** @test */
function sessionShouldDisplaySubscribeTime() {
$this->assertXPathContentContains('//tbody//tr/td/span',
'Date de limite d\'inscription:');
}