Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
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
261
262
263
264
265
266
267
268
269
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
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
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
<?php
/**
* Copyright (c) 2012-2022, 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 AuthenticationIntentWithoutLoginWidgetTestCase extends AbstractControllerTestCase {
protected string $_url_tested;
public function setUp() {
parent::setUp();
ZendAfi_Auth::getInstance()->clearIdentity();
$this->_buildTemplateProfil(['id' => 1]);
$profile = $this->_buildTemplateProfil(['id' => 3,
'libelle' => 'Authentication Page',
'parent_id' => 1,
'intent' => 'authentication']);
$profile_patcher = (new Class_Template_ProfilePatcher(null))
->setProfile($profile);
$profile_patcher
->addWidget(Intonation_Library_Widget_Login_Definition::CODE,
Class_Profil::DIV_MAIN);
$this->fixture(Class_Notice::class,
['id' => 2]);
$this->fixture(Class_Exemplaire::class,
['id' => 1,
'id_notice' => 2,
'id_origine' => '12',
'code_barres' => '1249036',
'id_int_bib' => 1,
'id_bib' => 1]);
$this->fixture(Class_IntBib::class,
['id' => 1,
'label' => 'majolieville',
'comm_sigb' => Class_IntBib::COM_KOHA,
'comm_params' => ['url_serveur' => 'https://monsuperkoha.org']]);
$this->fixture(Class_Bib::class,
['id' => 1,
'libelle' => 'Montmin']);
$this->fixture(Class_Newsletter::class,
['id' => 35,
'titre' => 'Jeunesse',
'mail_subject' => 'Jeunesse'
]);
$this->fixture(Class_Notice::class,
['id' => 123,
'titre' => 'Le parfum de la dame en noir',
'type_doc' => Class_TypeDoc::LIVRE
]);
$this->fixture(Class_Exemplaire::class,
['id' => 1234,
'id_int_bib' => 1,
'id_bib' => 1,
'notice_id' => 123,
'cote' => 'BAC123',
'code_barres' => '1234'
]);
}
}
class AuthenticationIntentWithoutLoginViewAlbumTest
extends AuthenticationIntentWithoutLoginWidgetTestCase{
public function setUp() {
parent::setUp();
$this->fixture(Class_Album::class,
['id' => 4,
'notice_id' => 3,
'type_doc_id' => 'ArteVod',
'titre' => 'Seventh Son of a Seventh Son',
'status' => Class_Album::STATUS_VALIDATED]);
$this->fixture(Class_Exemplaire::class,
['id' => 15,
'notice' => $this->fixture(Class_Notice::class,
['id' => 3,
'titre' => 'Un titre',
'type_doc' => 'ArteVod']),
'id_origine' => 4,
'code_barres' => '786876786']);
$this->fixture(Class_AlbumRessource::class,
['id' => 1,
'id_album' => 4,
'titre' => 'Moonchild',
'url' => 'http://mabib.net/bib-numerique/notice/ido/1']);
$this->dispatch('/noticeajax/resources/id/3');
}
/** @test */
public function albumShouldContainAuthenticationLink() {
$this->assertXPathContentContains('//a[contains(@href,"/modules/arte-vod/album_id/4")][@target = "_blank"]',
utf8_encode('Visionner le film dans son intégralité'));
}
}
class AuthenticationIntentWithoutLoginRecordReviewsClefTest extends AuthenticationIntentWithoutLoginWidgetTestCase{
public function setUp() {
parent::setUp();
$this->dispatch('record/reviews/clef/qsdfqsdf/id/2');
}
/** @test */
public function seConnecterLinkShouldBeProfileIdThree() {
$this->assertXPathContentContains('//div//a[@href="/index/index/id_profil/3/redirect_url/'.urlencode('/record/reviews/clef/qsdfqsdf/id/2').'"]',
'Se connecter');
}
}
class AuthenticationIntentWithoutLoginRecord2LinksTest extends AuthenticationIntentWithoutLoginWidgetTestCase {
public function setUp() {
parent::setUp();
$this->fixture(Class_Notice::class,
['id' => 2,
'clef_oeuvre' => 'PSYKO',
'titre_principal' => 'Psyko'
]);
$this->dispatch('recherche/viewnotice/id/2');
}
/** @test */
public function mesPreferesLinkShouldBeIndexIndexIdProfile() {
$this->assertXPathContentContains('//a[contains(@href,"/abonne/ajouter-le-document-a-la-selection/selection_label/Mes+pr%C3%A9f%C3%A9r%C3%A9s/image/like/revert-image/dislike/record_id/2/ajax/")]',
'Mes préférés');
}
/** @test */
public function dejaLuLinkShouldBeIndexIndexIdProfile() {
$this->assertXPathContentContains('//a[contains(@href,"/abonne/ajouter-le-document-a-la-selection/")]',
'Déjà lu');
}
/** @test */
public function seConnecterAvisLinkShouldBeindex() {
$this->assertXPathContentContains('//a[contains(@href,"/index/index/id_profil/3/redirect_url/'.urlencode('/recherche/viewnotice/id/2').'")][@title="Connectez vous pour donner un avis"]',"Se connecter");
}
}
class AuthenticationIntentWithoutLoginRechercheSimpleLinksTest extends AuthenticationIntentWithoutLoginWidgetTestCase {
public function setUp() {
parent::setUp();
$this->fixture(Class_Notice::class,
['id' => 2,
'clef_oeuvre' => 'PSYKO',
'titre_principal' => 'Psyko'
]);
$sql = $this->mock()
->whenCalled('fetchAll')
->answers([[2, '']]);
Zend_Registry::set('sql', $sql);
Class_AdminVar::set('ENABLE_SEARCH_MULTIPLE_RECORD_SELECTION', 1);
Zend_Registry::get('session')->search_record_selection = [2];
$this->dispatch('recherche/simple/expressionRecherche/Psyko');
}
/** @test */
public function suivreLinkShouldBeBookmarkedSearchesAdd() {
$this->assertXPathContentContains('//a[contains(@href,"/bookmarked-searches/add/expressionRecherche/Psyko/label/R%C3%A9sultat+pour+Psyko+")]',
"Suivre");
}
/** @test */
public function addPanierLinkShouldBePanierAddSelection() {
$this->assertXPathContentContains('//div[@class="record-selection"]//a[contains(@href,"/panier/add-selection")][@title="Ajouter toutes les notices de la sélection à un panier"]',
"Mettre dans un panier");
}
}
abstract class AuthenticationIntentWithoutLoginDispatchTestCase extends AuthenticationIntentWithoutLoginWidgetTestCase {
protected string $_url_tested;
public function setUp() {
parent::setUp();
$this->_setReferer() ;
$this->dispatch($this->_url_tested);
}
public function tearDown(){
$_SERVER['HTTP_REFERER'] = null;
parent::tearDown();
}
protected function _setReferer(){
$_SERVER['HTTP_REFERER'] = '/recherche/viewnotice/id/12';
}
/** @test */
public function pageShouldRedirectToAuthenticationPage() {
$this->assertRedirectTo('/index/index/id_profil/3/redirect_url/'
.urlencode($_SERVER['HTTP_REFERER'])
.'/after_login_do/'
.urlencode($this->_url_tested));
}
}
class AuthenticationIntentWithoutLoginNoticeAjaxAddAvisTest extends AuthenticationIntentWithoutLoginDispatchTestCase{
protected string $_url_tested = '/noticeajax/add-avis/id/2';
}
class AuthenticationIntentWithoutLoginNoticeAjaxAddTagTest extends AuthenticationIntentWithoutLoginDispatchTestCase{
protected string $_url_tested = '/noticeajax/add-tag/id/2';
}
class AuthenticationIntentWithoutLoginRechercheConsultationPickupAjaxTest extends AuthenticationIntentWithoutLoginDispatchTestCase{
protected string $_url_tested = '/recherche/consultation-pickup-ajax/id/2';
}
class AuthenticationIntentWithoutLoginPanierAddSelectionTest extends AuthenticationIntentWithoutLoginDispatchTestCase{
protected string $_url_tested = '/panier/add-selection/id/2';
}
class AuthenticationIntentWithoutLoginPanierAddRecordAjaxTest extends AuthenticationIntentWithoutLoginDispatchTestCase{
protected string $_url_tested = '/panier/add-record-ajax/id/2';
}
class AuthenticationIntentRechercheReserverRedirectToLoginTest extends AuthenticationIntentWithoutLoginDispatchTestCase{
protected string $_url_tested = '/recherche/reservation/id_int_bib/1/id_bib/1/id_notice/123/cote/BAC123';
protected string $_referer = '/record/items/123';
}
class AuthenticationIntentDispatchAbonneInscrireSessionTest extends AuthenticationIntentWithoutLoginDispatchTestCase {
protected string $_url_tested = '/abonne/inscrire-session/id/1';
}
class AuthenticationIntentDispatchAbonneSuggestionAchatAddTest extends AuthenticationIntentWithoutLoginDispatchTestCase {
protected string $_url_tested = '/abonne/suggestion-achat-add/id/1';
}
class AuthenticationIntentDispatchAbonneFicheId1AddTest extends AuthenticationIntentWithoutLoginDispatchTestCase {
protected string $_url_tested = '/abonne/fiche/id/1';
}
class AuthenticationIntentDispatchAbonneConfigurationsAddTest extends AuthenticationIntentWithoutLoginDispatchTestCase {
protected string $_url_tested = '/abonne/configurations';
}
class AuthenticationIntentDispatchBookmarkedSearchesTest extends AuthenticationIntentWithoutLoginDispatchTestCase {
protected string $_url_tested = '/bookmarked-searches/add/label/qsdf/id/1';
}
abstract class AuthenticationIntentWithoutLoginBibNumeriqueDispatchTestCase extends AuthenticationIntentWithoutLoginWidgetTestCase {
protected string $_url_tested;
public function setUp() {
parent::setUp();
$this->dispatch($this->_url_tested);
}
/** @test */
public function pageShouldRedirectToAuthenticationPage() {
$this->assertRedirectTo('/index/index/id_profil/3/redirect_url/'
.urlencode($this->_url_tested));
}
}
class AuthenticationIntentBibNumeriqueControllerConsultBookOpenAjaxTest extends AuthenticationIntentWithoutLoginBibNumeriqueDispatchTestCase{
protected string $_url_tested = '/bib-numerique/consult-book-open-ajax/id/2';
}
class AuthenticationIntentBibNumeriqueControllerConsultBookAjaxTest extends AuthenticationIntentWithoutLoginBibNumeriqueDispatchTestCase{
protected string $_url_tested = '/bib-numerique/consult-book-ajax/id/2';
}
class AuthenticationIntentBibNumeriqueControllerConsultBookTest extends AuthenticationIntentWithoutLoginBibNumeriqueDispatchTestCase{
protected string $_url_tested = '/bib-numerique/consult-book/id/2';
}
class AuthenticationIntentBibNumeriqueControllerLoanBookAjaxTest extends AuthenticationIntentWithoutLoginBibNumeriqueDispatchTestCase{
protected string $_url_tested = '/bib-numerique/loan-book-ajax/id/2';
}
class AuthenticationIntentBibNumeriqueControllerDownloadBookAjaxTest extends AuthenticationIntentWithoutLoginBibNumeriqueDispatchTestCase{
protected string $_url_tested = '/bib-numerique/download-loan-book-ajax/id/2';
}
class AuthenticationIntentDispatchWithAfterLoginRedirectAndConnectionWithUserTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
$this->_buildTemplateProfil(['id' => 1,
'libelle' => 'accueil']);
$this->_buildTemplateProfil(['id' => 3,
'libelle' => 'auth',
'parent_id' => 1,
'intent' => 'authentication']);
$this->fixture(Class_Users::class,
['id' => 36,
'login' => 'pourlecoup',
'password' => 'puocelruop']);
$authenticated = false;
Zend_Registry::get('session')->redirect_url = "/recherche/viewnotice/id/2";
ZendAfi_Auth::setInstance($this->mock()
->whenCalled('getIdentity')
->willDo(
function() use(&$authenticated) {
if (!$authenticated)
return null;
$identity = new StdClass();
$identity->ID_USER = 36;
return $identity;
})
->whenCalled('authenticateLoginPassword')
->with('pourlecoup', 'puocelruop')
->willDo(
function() use(&$authenticated) {
return $authenticated = true;
})
->whenCalled('authenticateLoginPassword')
->with('pourlecoup', 'peza')
->willDo(
function() use(&$authenticated) {
return $authenticated = false;
}));
}
public function tearDown() {
ZendAfi_Auth::setInstance(null);
parent::tearDown();
}
public function authenticationMethod(){
return [['boite-login'],
['login']
];
}
/** @test
* @dataProvider authenticationMethod
*/
public function boiteLoginConnectWithAfterLoginSuccessRedirectShouldForwardToOpacViewnotice($auth_method) {
$this->postDispatch('opac/auth/'.$auth_method.'/id_profil/3',
['username' => 'pourlecoup',
'password' => 'puocelruop']);
$this->assertRedirectTo('/recherche/viewnotice/id/2');
}
/** @test
*/
public function loginConnectWithAfterLoginErrorRedirectShouldForwardToOpacViewnotice() {
$this->postDispatch('opac/auth/login/id_profil/3',
['username' => 'pourlecoup',
'password' => 'peza']);
$this->assertRedirectTo('/recherche/viewnotice/id/2');
}
}
class AuthenticationIntentAfterLoginRedirectTest extends AuthenticationIntentWithoutLoginWidgetTestCase {
public function setUp() {
parent::setUp();
(new ZendAfi_Controller_Action_Helper_FlashMessenger)
->addPopup('/recherche/reserver/record_id/2');
ZendAfi_Controller_Action_Helper_FlashMessenger::reset();
$this->dispatch('/record/items/clef/qsdfqsdf/id/2');
}
/** @test */
public function pageShouldContainsScriptOpacDialogWithRechercheReserverId2() {
$this->assertXPathContentContains('//script', 'opacDialogFromUrl("/recherche/reserver/record_id/2/render/popup");});');
}
/** @test */
public function sessionShouldNotContainsFlashMessengerPopupRechercheReserver() {
$this->assertNotFlashMessengerPopup();
}
}
class AuthenticationIntentPostLoginTest extends AuthenticationIntentWithoutLoginWidgetTestCase {
public function setUp() {
parent::setUp();
$this->fixture(Class_Users::class,
['id' => 879,
'login' => 'Thomas',
'password' => 'go']);
$this->postDispatch('/auth/login/redirect_url/'
. urlencode('/recherche/viewnotice/id/2')
. '/after_login_do/'
. urlencode('/recherche/reserver/record_id/2'),
['username' => 'Thomas',
'password' => 'go']);
}
/** @test */
public function shouldRedirectToRechercheViewnoticeIdTwo() {
$this->assertRedirectTo('/recherche/viewnotice/id/2');
}
/** @test */
public function sessionShouldNotContainsFlashMessengerPopupRechercheReserver() {
$this->assertFlashMessengerContainsPopup('/recherche/reserver/record_id/2/render/popup');
}
}
class AuthenticationIntentConnexionProfilWithRedirectTest
extends AuthenticationIntentWithoutLoginWidgetTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/index/index/id_profil/3/redirect_url/'
. urlencode('/recherche/viewnotice/id/2')
. '/after_login_do/'
. urlencode('/recherche/reserver/id/2'));
}
/** @test */
public function boiteLoginFormActionShouldContainsRedirectUrlToRechercheViewNoticeAndAfterLogin() {
$this->assertXPath('//form[contains(@action, "/auth/login/id_profil/3'
. '/redirect_url/'
. urlencode('/recherche/viewnotice/id/2')
. '/after_login_do/'
. urlencode('/recherche/reserver/id/2')
.'")]');
}
/** @test */
public function boiteLoginFormActionShouldNotContainsSimpleRedirect() {
$this->assertNotXPath('//form[contains(@action, "/redirect/")]');
}
/** @test */
public function afterLoginDoRechercheReserverShouldBeSavedInSession() {
$this->assertEquals('/recherche/reserver/id/2', Zend_Registry::get('session')->after_login_do);
}
/** @test */
public function redircetUrlRechercheViewnoticeShouldBeSavedInSession() {
$this->assertEquals('/recherche/viewnotice/id/2', Zend_Registry::get('session')->redirect_url);
}
}
abstract class AuthenticationIntentLoginWithIdentityProviderTestCase extends AuthenticationIntentWithoutLoginWidgetTestCase {
protected $_provider;
public function setUp() {
parent::setUp();
Class_AdminVar::set('ENABLE_IDENTITY_PROVIDERS', 1);
ZendAfi_Auth::getInstance()->clearIdentity();
$user = $this->fixture(Class_Users::class,
['id' => 98134,
'login' => 'mysuperid',
'nom' => 'James',
'prenom' => 'P.D.',
'password' => '1234',
'civilite' => "1",
'date_naissance' => '2022-12-08']);
$this->_provider =
$this->fixture(Class_IdentityProvider::class,
['id' => 1,
'label' => 'Médiathèque Deauville',
'type' => 'cas3',
'config' => json_encode
(['url' => 'http://moncompte.server.com/cas-server-v3/',
'auto_create_users' => 1,
'associate_on_login' => 1,
'mapping' =>
['nom' => 'lastname',
'prenom' => 'firstname',
'mail' => 'mail',
'id_site' => 'site_code']])]);
$this->fixture(Class_User_Identity::class,
['id' => 789,
'user_id' => 98134,
'provider_id' => 1,
'identifier' => 'mysuperid']);
$response = $this->mock()
->whenCalled('isError')->answers(false)
->whenCalled('getBody')
->answers(file_get_contents(__DIR__.'/IdentityProvider/cas3ticket.xml'));
Class_WebService_Cas3::setWebClient($this->mock()
->whenCalled('getResponse')
->answers($response));
Zend_Registry::get('session')->after_login_do = '/recherche/reserver/id/2';
Zend_Registry::get('session')->redirect_url = '/recherche/viewnotice/id/2';
}
}
class AuthenticationIntentLoginWithIdentityProviderTest extends AuthenticationIntentLoginWithIdentityProviderTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/auth/login/provider/1?ticket=testticket&redirect=');
}
/** @test */
public function jamesShouldBeLogged() {
$this->assertNotNull(Class_Users::getIdentity());
}
/**
* @test
* @depends jamesShouldBeLogged
*/
public function shouldRedirectToRechercheViewnoticeIdTwo() {
$this->assertRedirectTo('/recherche/viewnotice/id/2');
}
/**
* @test
* @depends jamesShouldBeLogged
*/
public function sessionShouldNotContainsFlashMessengerPopupRechercheReserver() {
$this->assertFlashMessengerContainsPopup('/recherche/reserver/id/2/render/popup');
}
}
class AuthenticationIntentLoginWithIdentityProviderWithRedirectProfileTest extends AuthenticationIntentLoginWithIdentityProviderTestCase {
protected $_provider;
public function setUp() {
parent::setUp();
$this->fixture(class_Profil::class,
['id' => 5,
'label' => 'Mon Profil test'
]);
$this->_provider->setProfilRedirect(5)->save();
$this->dispatch('/auth/login/provider/1?ticket=testticket&redirect=');
}
/** @test */
public function jamesShouldBeLogged() {
$this->assertNotNull(Class_Users::getIdentity());
}
/**
* @test
*/
public function shouldRedirectToRechercheViewnoticeIdTwo() {
$this->assertRedirectTo('/recherche/viewnotice/id/2');
}
/**
* @test
*/
public function sessionShouldNotContainsFlashMessengerPopupRechercheReserver() {
$this->assertFlashMessengerContainsPopup('/recherche/reserver/id/2/render/popup');
}
}
class AuthenticationIntentModulePlanetNemoNotLoggedTest
extends AuthenticationIntentWithoutLoginWidgetTestCase {
public function setUp() {
parent::setUp();
RessourcesNumeriquesFixtures::activatePlanetNemo();
$this->dispatch('/opac/modules/planetnemo');
}
/** @test */
public function bodyShouldContainsScriptToRedirectToIndexIndexIdProfil3AndRedirectParamToModulesPlanetNemo() {
$this->assertXPathContentContains('//script',
'/index/index/id_profil/3/redirect_url/');
$this->assertXPathContentContains('//script',
'%2Fmodules%2Fplanetnemo');
}
}
class AuthenticationIntentModulesArteVodNotLoggedTest extends AuthenticationIntentWithoutLoginWidgetTestCase {
public function setUp() {
parent::setUp();
Class_AdminVar::set('ArteVod_SSO_KEY', '123');
Class_AdminVar::set('ArteVod_LOGIN', '123');
$this->dispatch('/opac/modules/arte-vod');
}
/** @test */
public function shouldRedirectToIndexIndexIdProfil3AndRedirectUrlParamToModulesArteVod() {
$this->assertRedirectTo('/index/index/id_profil/3/redirect_url/'.urlencode('http://localhost'. BASE_URL . '/modules/arte-vod'));
}
}
class AuthenticationIntentDispatchAuthSubscribeNewsletterTest extends AuthenticationIntentWithoutLoginWidgetTestCase {
public function setUp() {
parent::setUp();
$this->fixture(Class_Newsletter::class,
['id' => 35,
'titre' => 'Jeunesse',
'mail_subject' => 'Jeunesse'
]);
$_SERVER['HTTP_REFERER'] = 'http://localhost/vos-acces';
$this->dispatch('/auth/newsletter-register/id/35');
}
public function tearDown(){
$_SERVER['HTTP_REFERER']='';
parent::tearDown();
}
/** @test */
public function linkDejaUnCompteShouldBeAuthenticationProfil() {
$this->assertXPathContentContains('//a[@href="/index/index/id_profil/3/redirect_url/'
. urlencode($_SERVER['HTTP_REFERER'])
. '/after_login_do/'
. urlencode('/auth/newsletter-register/id/35')
.'"]'
, "J'ai déjà un compte"
);
}
}
class AuthenticationIntentLogoutTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
Zend_Registry::get('session')->after_login_do = '/recherche/reserver/id/2';
Zend_Registry::get('session')->redirect_url = '/recherche/viewnotice/id/2';
$this->dispatch('/auth/logout');
}
/** @test */
public function sessionRedirectUrlShouldBeEmpty() {
$this->assertEmpty(Zend_Registry::get('session')->redirect_url);
}
/** @test */
public function sessionAfterLoginDoShouldBeEmpty() {
$this->assertEmpty(Zend_Registry::get('session')->after_login_do);
}
}