@@ -79,8 +79,8 @@ class TestRegistrationPresenter extends Tester\TestCase
79
79
$ this ->presenter = PresenterTestHelper::createPresenter ($ this ->container , RegistrationPresenter::class);
80
80
$ this ->presenter ->registrationConfig = new RegistrationConfig (
81
81
[
82
- 'enabled ' => true ,
83
- 'implicitGroupsIds ' => []
82
+ 'enabled ' => true ,
83
+ 'implicitGroupsIds ' => []
84
84
]
85
85
);
86
86
@@ -118,14 +118,14 @@ class TestRegistrationPresenter extends Tester\TestCase
118
118
'POST ' ,
119
119
['action ' => 'createAccount ' ],
120
120
[
121
- 'email ' => $ email ,
122
- 'firstName ' => $ firstName ,
123
- 'lastName ' => $ lastName ,
124
- 'password ' => $ password ,
125
- 'passwordConfirm ' => $ password ,
126
- 'instanceId ' => $ instanceId ,
127
- 'titlesBeforeName ' => $ titlesBeforeName ,
128
- 'titlesAfterName ' => $ titlesAfterName
121
+ 'email ' => $ email ,
122
+ 'firstName ' => $ firstName ,
123
+ 'lastName ' => $ lastName ,
124
+ 'password ' => $ password ,
125
+ 'passwordConfirm ' => $ password ,
126
+ 'instanceId ' => $ instanceId ,
127
+ 'titlesBeforeName ' => $ titlesBeforeName ,
128
+ 'titlesAfterName ' => $ titlesAfterName
129
129
]
130
130
);
131
131
$ response = $ this ->presenter ->run ($ request );
@@ -170,20 +170,20 @@ class TestRegistrationPresenter extends Tester\TestCase
170
170
'POST ' ,
171
171
['action ' => 'createAccount ' ],
172
172
[
173
- 'email ' => $ email ,
174
- 'firstName ' => $ firstName ,
175
- 'lastName ' => $ lastName ,
176
- 'password ' => $ password ,
177
- 'passwordConfirm ' => $ password ,
178
- 'instanceId ' => $ instanceId ,
179
- 'titlesBeforeName ' => $ titlesBeforeName ,
180
- 'titlesAfterName ' => $ titlesAfterName
173
+ 'email ' => $ email ,
174
+ 'firstName ' => $ firstName ,
175
+ 'lastName ' => $ lastName ,
176
+ 'password ' => $ password ,
177
+ 'passwordConfirm ' => $ password ,
178
+ 'instanceId ' => $ instanceId ,
179
+ 'titlesBeforeName ' => $ titlesBeforeName ,
180
+ 'titlesAfterName ' => $ titlesAfterName
181
181
]
182
182
);
183
183
$ this ->presenter ->registrationConfig = new RegistrationConfig (
184
184
[
185
- 'enabled ' => true ,
186
- 'implicitGroupsIds ' => [$ groupId ]
185
+ 'enabled ' => true ,
186
+ 'implicitGroupsIds ' => [$ groupId ]
187
187
]
188
188
);
189
189
$ response = $ this ->presenter ->run ($ request );
@@ -226,19 +226,19 @@ class TestRegistrationPresenter extends Tester\TestCase
226
226
'POST ' ,
227
227
['action ' => 'createAccount ' ],
228
228
[
229
- 'email ' => $ email ,
230
- 'firstName ' => $ firstName ,
231
- 'lastName ' => $ lastName ,
232
- 'password ' => $ password ,
233
- 'passwordConfirm ' => $ password ,
234
- 'instanceId ' => $ instanceId ,
235
- 'titlesBeforeName ' => $ titlesBeforeName ,
236
- 'titlesAfterName ' => $ titlesAfterName
229
+ 'email ' => $ email ,
230
+ 'firstName ' => $ firstName ,
231
+ 'lastName ' => $ lastName ,
232
+ 'password ' => $ password ,
233
+ 'passwordConfirm ' => $ password ,
234
+ 'instanceId ' => $ instanceId ,
235
+ 'titlesBeforeName ' => $ titlesBeforeName ,
236
+ 'titlesAfterName ' => $ titlesAfterName
237
237
]
238
238
);
239
239
$ this ->presenter ->registrationConfig = new RegistrationConfig (
240
240
[
241
- 'enabled ' => false ,
241
+ 'enabled ' => false ,
242
242
]
243
243
);
244
244
@@ -265,14 +265,14 @@ class TestRegistrationPresenter extends Tester\TestCase
265
265
'POST ' ,
266
266
['action ' => 'createAccount ' ],
267
267
[
268
- 'email ' => $ email ,
269
- 'firstName ' => $ firstName ,
270
- 'lastName ' => $ lastName ,
271
- 'password ' => $ password ,
272
- 'passwordConfirm ' => $ password ,
273
- 'instanceId ' => $ instanceId ,
274
- 'titlesBeforeName ' => $ titlesBeforeName ,
275
- 'titlesAfterName ' => $ titlesAfterName
268
+ 'email ' => $ email ,
269
+ 'firstName ' => $ firstName ,
270
+ 'lastName ' => $ lastName ,
271
+ 'password ' => $ password ,
272
+ 'passwordConfirm ' => $ password ,
273
+ 'instanceId ' => $ instanceId ,
274
+ 'titlesBeforeName ' => $ titlesBeforeName ,
275
+ 'titlesAfterName ' => $ titlesAfterName
276
276
]
277
277
);
278
278
@@ -302,14 +302,14 @@ class TestRegistrationPresenter extends Tester\TestCase
302
302
'POST ' ,
303
303
['action ' => 'createAccount ' ],
304
304
[
305
- 'email ' => $ email ,
306
- 'firstName ' => $ firstName ,
307
- 'lastName ' => $ lastName ,
308
- 'password ' => $ password ,
309
- 'passwordConfirm ' => $ passwordConfirm ,
310
- 'instanceId ' => $ instanceId ,
311
- 'titlesBeforeName ' => $ titlesBeforeName ,
312
- 'titlesAfterName ' => $ titlesAfterName
305
+ 'email ' => $ email ,
306
+ 'firstName ' => $ firstName ,
307
+ 'lastName ' => $ lastName ,
308
+ 'password ' => $ password ,
309
+ 'passwordConfirm ' => $ passwordConfirm ,
310
+ 'instanceId ' => $ instanceId ,
311
+ 'titlesBeforeName ' => $ titlesBeforeName ,
312
+ 'titlesAfterName ' => $ titlesAfterName
313
313
]
314
314
);
315
315
@@ -336,14 +336,14 @@ class TestRegistrationPresenter extends Tester\TestCase
336
336
'POST ' ,
337
337
['action ' => 'createAccount ' ],
338
338
[
339
- 'email ' => $ email ,
340
- 'firstName ' => $ firstName ,
341
- 'lastName ' => $ lastName ,
342
- 'password ' => $ password ,
343
- 'passwordConfirm ' => $ password ,
344
- 'instanceId ' => $ instanceId ,
345
- 'titlesBeforeName ' => $ titlesBeforeName ,
346
- 'titlesAfterName ' => $ titlesAfterName
339
+ 'email ' => $ email ,
340
+ 'firstName ' => $ firstName ,
341
+ 'lastName ' => $ lastName ,
342
+ 'password ' => $ password ,
343
+ 'passwordConfirm ' => $ password ,
344
+ 'instanceId ' => $ instanceId ,
345
+ 'titlesBeforeName ' => $ titlesBeforeName ,
346
+ 'titlesAfterName ' => $ titlesAfterName
347
347
]
348
348
);
349
349
@@ -363,8 +363,8 @@ class TestRegistrationPresenter extends Tester\TestCase
363
363
'POST ' ,
364
364
['action ' => 'validateRegistrationData ' ],
365
365
[
366
- 'email ' => "totallyFreeEmail@EmailFreeTotally.freeEmailTotally " ,
367
- 'password ' => "totallySecurePasswordWhichIsNot123456 "
366
+ 'email ' => "totallyFreeEmail@EmailFreeTotally.freeEmailTotally " ,
367
+ 'password ' => "totallySecurePasswordWhichIsNot123456 "
368
368
]
369
369
);
370
370
$ response = $ this ->presenter ->run ($ request );
@@ -511,8 +511,99 @@ class TestRegistrationPresenter extends Tester\TestCase
511
511
]
512
512
);
513
513
},
514
- BadRequestException::class
514
+ ForbiddenRequestException::class
515
+ );
516
+ }
517
+
518
+ public function testCreateInvitationWithSameName ()
519
+ {
520
+ $ student = $ this ->presenter ->users ->getByEmail (PresenterTestHelper::STUDENT_GROUP_MEMBER_LOGIN );
521
+ Assert::notNull ($ student );
522
+
523
+ $ email = "newguy@recodex.com " ;
524
+ $ firstName = $ student ->getFirstName ();
525
+ $ lastName = $ student ->getLastName ();
526
+ $ instances = $ this ->instances ->findAll ();
527
+ $ instanceId = array_pop ($ instances )->getId ();
528
+ $ titlesBeforeName = "titlesBeforeName " ;
529
+ $ titlesAfterName = "titlesAfterName " ;
530
+
531
+ $ groups = [];
532
+ foreach ($ this ->presenter ->groups ->findAll () as $ group ) {
533
+ if (!$ group ->isArchived () && !$ group ->isOrganizational ()) {
534
+ $ groups [] = $ group ->getId ();
535
+ }
536
+ }
537
+ Assert::truthy ($ groups );
538
+
539
+ PresenterTestHelper::loginDefaultAdmin ($ this ->container );
540
+ $ payload = PresenterTestHelper::performPresenterRequest (
541
+ $ this ->presenter ,
542
+ $ this ->presenterPath ,
543
+ 'POST ' ,
544
+ ['action ' => 'createInvitation ' ],
545
+ [
546
+ 'email ' => $ email ,
547
+ 'firstName ' => $ firstName ,
548
+ 'lastName ' => $ lastName ,
549
+ 'titlesBeforeName ' => $ titlesBeforeName ,
550
+ 'titlesAfterName ' => $ titlesAfterName ,
551
+ 'instanceId ' => $ instanceId ,
552
+ 'groups ' => $ groups ,
553
+ 'locale ' => 'en ' ,
554
+ ]
555
+ );
556
+
557
+ Assert::count (1 , $ payload );
558
+ $ user = current ($ payload );
559
+ Assert::equal ($ student ->getId (), $ user ["id " ]);
560
+ }
561
+
562
+ public function testCreateInvitationWithSameNameEnabled ()
563
+ {
564
+ $ student = $ this ->presenter ->users ->getByEmail (PresenterTestHelper::STUDENT_GROUP_MEMBER_LOGIN );
565
+ Assert::notNull ($ student );
566
+
567
+ $ email = "newguy@recodex.com " ;
568
+ $ firstName = $ student ->getFirstName ();
569
+ $ lastName = $ student ->getLastName ();
570
+ $ instances = $ this ->instances ->findAll ();
571
+ $ instanceId = array_pop ($ instances )->getId ();
572
+ $ titlesBeforeName = "titlesBeforeName " ;
573
+ $ titlesAfterName = "titlesAfterName " ;
574
+
575
+ $ groups = [];
576
+ foreach ($ this ->presenter ->groups ->findAll () as $ group ) {
577
+ if (!$ group ->isArchived () && !$ group ->isOrganizational ()) {
578
+ $ groups [] = $ group ->getId ();
579
+ }
580
+ }
581
+ Assert::truthy ($ groups );
582
+
583
+ $ this ->emailHelperMock ->shouldReceive ("send " )
584
+ ->with ("noreply@recodex " , [$ email ], "en " , 'User Admin Admin has invited you in ReCodEx! ' , Mockery::any ())
585
+ ->once ()->andReturn (true );
586
+
587
+ PresenterTestHelper::loginDefaultAdmin ($ this ->container );
588
+ $ payload = PresenterTestHelper::performPresenterRequest (
589
+ $ this ->presenter ,
590
+ $ this ->presenterPath ,
591
+ 'POST ' ,
592
+ ['action ' => 'createInvitation ' ],
593
+ [
594
+ 'email ' => $ email ,
595
+ 'firstName ' => $ firstName ,
596
+ 'lastName ' => $ lastName ,
597
+ 'titlesBeforeName ' => $ titlesBeforeName ,
598
+ 'titlesAfterName ' => $ titlesAfterName ,
599
+ 'instanceId ' => $ instanceId ,
600
+ 'groups ' => $ groups ,
601
+ 'locale ' => 'en ' ,
602
+ 'ignoreNameCollision ' => true ,
603
+ ]
515
604
);
605
+
606
+ Assert::equal ("OK " , $ payload );
516
607
}
517
608
518
609
public function testAcceptInvitation ()
0 commit comments