@@ -38,9 +38,27 @@ public function setUp(): void
3838
3939 protected function getAffectedTables ()
4040 {
41- return ['notes ' , 'submissions ' , 'submission_settings ' , 'publications ' , 'publication_settings ' ,
42- 'users ' , 'user_groups ' , 'user_settings ' , 'user_group_settings ' , 'user_user_groups ' , 'event_log ' , 'sections ' ,
43- 'section_settings ' , 'authors ' , 'author_settings ' , 'edit_decisions ' , 'stage_assignments ' , 'user_group_stage ' , 'review_assignments ' ];
41+ return [
42+ 'notes ' ,
43+ 'submissions ' ,
44+ 'submission_settings ' ,
45+ 'publications ' ,
46+ 'publication_settings ' ,
47+ 'users ' ,
48+ 'user_groups ' ,
49+ 'user_settings ' ,
50+ 'user_group_settings ' ,
51+ 'user_user_groups ' ,
52+ 'event_log ' ,
53+ 'sections ' ,
54+ 'section_settings ' ,
55+ 'authors ' ,
56+ 'author_settings ' ,
57+ 'edit_decisions ' ,
58+ 'stage_assignments ' ,
59+ 'user_group_stage ' ,
60+ 'review_assignments '
61+ ];
4462 }
4563
4664 private function createSubmission (): int
@@ -142,42 +160,32 @@ private function addCurrentPublicationToSubmission(): void
142160 $ submissionDao ->updateObject ($ submission );
143161 }
144162
145- private function createEditorUsers (bool $ isSectionEditor = false )
163+ private function createEditorUsers (array $ editorsUsersData , bool $ asSectionEditors = false )
146164 {
147165 $ userGroupDao = DAORegistry::getDAO ('UserGroupDAO ' );
148166 $ userDao = DAORegistry::getDAO ('UserDAO ' );
149167
150- $ firstEditorUser = new User ();
151- $ firstEditorUser ->setUsername ('examplePeter ' );
152- $ firstEditorUser ->setEmail ('peter@exemple.com ' );
153- $ firstEditorUser ->setPassword ('examplepass ' );
154- $ firstEditorUser ->setGivenName ("Peter " , $ this ->locale );
155- $ firstEditorUser ->setFamilyName ("Parker " , $ this ->locale );
156-
157- $ secondEditorUser = new User ();
158- $ secondEditorUser ->setUsername ('exampleJhon ' );
159- $ secondEditorUser ->setEmail ('jhon@exemple.com ' );
160- $ secondEditorUser ->setPassword ('exemplepass ' );
161- $ secondEditorUser ->setGivenName ("Jhon " , $ this ->locale );
162- $ secondEditorUser ->setFamilyName ("Carter " , $ this ->locale );
163-
164- $ firstEditorUserId = $ userDao ->insertObject ($ firstEditorUser );
165- $ secondEditorUserId = $ userDao ->insertObject ($ secondEditorUser );
166-
167- if ($ isSectionEditor ) {
168- $ sectionEditorGroupId = $ this ->createSectionEditorUserGroup ();
169- $ userGroupDao ->assignUserToGroup ($ firstEditorUserId , $ sectionEditorGroupId );
170- $ this ->createStageAssignments ([$ firstEditorUserId ], $ sectionEditorGroupId );
171- $ userGroupDao ->assignGroupToStage ($ this ->contextId , $ sectionEditorGroupId , 5 );
172- return $ firstEditorUser ;
173- } else {
174- $ editorGroupId = $ this ->createJournalEditorUserGroup ();
175- $ userGroupDao ->assignUserToGroup ($ firstEditorUserId , $ editorGroupId );
176- $ userGroupDao ->assignUserToGroup ($ secondEditorUserId , $ editorGroupId );
177- $ this ->createStageAssignments ([$ firstEditorUserId , $ secondEditorUserId ], $ editorGroupId );
178- $ userGroupDao ->assignGroupToStage ($ this ->contextId , $ editorGroupId , 5 );
179- return [$ firstEditorUser , $ secondEditorUser ];
168+ $ editorsUsers = [];
169+ foreach ($ editorsUsersData as $ editorUserData ) {
170+ $ editorUser = new User ();
171+ $ editorUser ->setAllData ($ editorUserData );
172+ $ editorsUsers [] = $ editorUser ;
173+ }
174+
175+ $ editorUserGroupId = $ asSectionEditors
176+ ? $ this ->createSectionEditorUserGroup ()
177+ : $ this ->createJournalEditorUserGroup ();
178+
179+ foreach ($ editorsUsers as $ editorUser ) {
180+ $ editorUserId = $ userDao ->insertObject ($ editorUser );
181+
182+ $ userGroupDao ->assignUserToGroup ($ editorUserId , $ editorUserGroupId );
183+ $ this ->createStageAssignments ([$ editorUserId ], $ editorUserGroupId );
180184 }
185+
186+ $ userGroupDao ->assignGroupToStage ($ this ->contextId , $ editorUserGroupId , 5 );
187+
188+ return $ editorsUsers ;
181189 }
182190
183191 private function createDecision ($ submissionId , $ decision , $ dateDecided ): void
@@ -202,7 +210,7 @@ private function createStageAssignments(array $userIds, $groupId): void
202210
203211 /**
204212 * @group OJS
205- */
213+ */
206214 public function testSubmissionIsArticle (): void
207215 {
208216 $ articleFactory = new ScieloArticleFactory ();
@@ -213,7 +221,7 @@ public function testSubmissionIsArticle(): void
213221
214222 /**
215223 * @group OJS
216- */
224+ */
217225 public function testArticleCreationWhenItHasNoTitles (): void
218226 {
219227 $ this ->title = null ;
@@ -231,10 +239,26 @@ public function testArticleCreationWhenItHasNoTitles(): void
231239
232240 /**
233241 * @group OJS
234- */
242+ */
235243 public function testSubmissionGetsJournalEditors (): void
236244 {
237- $ editorsUsers = $ this ->createEditorUsers ();
245+ $ journalEditorsData = [
246+ [
247+ 'username ' => 'examplePeter ' ,
248+ 'email ' => 'peter@example.com ' ,
249+ 'password ' => 'examplepass ' ,
250+ 'givenName ' => [$ this ->locale => "Peter " ],
251+ 'familyName ' => [$ this ->locale => "Parker " ]
252+ ],
253+ [
254+ 'username ' => 'exampleJhon ' ,
255+ 'email ' => 'jhon@example.com ' ,
256+ 'password ' => 'examplepass ' ,
257+ 'givenName ' => [$ this ->locale => "Jhon " ],
258+ 'familyName ' => [$ this ->locale => "Carter " ]
259+ ]
260+ ];
261+ $ editorsUsers = $ this ->createEditorUsers ($ journalEditorsData );
238262
239263 $ articleFactory = new ScieloArticleFactory ();
240264 $ scieloArticle = $ articleFactory ->createSubmission ($ this ->submissionId , $ this ->locale );
@@ -245,7 +269,39 @@ public function testSubmissionGetsJournalEditors(): void
245269
246270 /**
247271 * @group OJS
248- */
272+ */
273+ public function testSubmissionGetsDisabledJournalEditors (): void
274+ {
275+ $ journalEditorsData = [
276+ [
277+ 'username ' => 'examplePeter ' ,
278+ 'email ' => 'peter@example.com ' ,
279+ 'password ' => 'examplepass ' ,
280+ 'givenName ' => [$ this ->locale => "Peter " ],
281+ 'familyName ' => [$ this ->locale => "Parker " ]
282+ ],
283+ [
284+ 'username ' => 'exampleCharles ' ,
285+ 'email ' => 'charles@example.com ' ,
286+ 'password ' => 'examplepass ' ,
287+ 'givenName ' => [$ this ->locale => "Charles " ],
288+ 'familyName ' => [$ this ->locale => "Xavier " ],
289+ 'disabled ' => true
290+ ]
291+ ];
292+ $ editorsUsers = $ this ->createEditorUsers ($ journalEditorsData );
293+
294+ $ articleFactory = new ScieloArticleFactory ();
295+ $ scieloArticle = $ articleFactory ->createSubmission ($ this ->submissionId , $ this ->locale );
296+
297+ $ expectedEditors = $ editorsUsers [0 ]->getFullName ()
298+ . ", " . $ editorsUsers [1 ]->getFullName ();
299+ $ this ->assertEquals ($ expectedEditors , $ scieloArticle ->getJournalEditors ());
300+ }
301+
302+ /**
303+ * @group OJS
304+ */
249305 public function testSubmissionGetsNoJournalEditors (): void
250306 {
251307 $ articleFactory = new ScieloArticleFactory ();
@@ -256,20 +312,48 @@ public function testSubmissionGetsNoJournalEditors(): void
256312
257313 /**
258314 * @group OJS
259- */
315+ */
260316 public function testSubmissionGetsSectionEditor (): void
261317 {
262- $ sectionEditorsUser = $ this ->createEditorUsers (true );
318+ $ sectionEditorData = [
319+ 'username ' => 'exampleJhon ' ,
320+ 'email ' => 'jhon@example.com ' ,
321+ 'password ' => 'examplepass ' ,
322+ 'givenName ' => [$ this ->locale => "Jhon " ],
323+ 'familyName ' => [$ this ->locale => "Carter " ]
324+ ];
325+ $ sectionEditorUser = $ this ->createEditorUsers ([$ sectionEditorData ], true )[0 ];
326+
327+ $ articleFactory = new ScieloArticleFactory ();
328+ $ scieloArticle = $ articleFactory ->createSubmission ($ this ->submissionId , $ this ->locale );
329+
330+ $ this ->assertEquals ($ sectionEditorUser ->getFullName (), $ scieloArticle ->getSectionEditor ());
331+ }
332+
333+ /**
334+ * @group OJS
335+ */
336+ public function testSubmissionGetsDisabledSectionEditor (): void
337+ {
338+ $ sectionEditorData = [
339+ 'username ' => 'exampleCharles ' ,
340+ 'email ' => 'charles@example.com ' ,
341+ 'password ' => 'examplepass ' ,
342+ 'givenName ' => [$ this ->locale => "Charles " ],
343+ 'familyName ' => [$ this ->locale => "Xavier " ],
344+ 'disabled ' => true
345+ ];
346+ $ sectionEditorUser = $ this ->createEditorUsers ([$ sectionEditorData ], true )[0 ];
263347
264348 $ articleFactory = new ScieloArticleFactory ();
265349 $ scieloArticle = $ articleFactory ->createSubmission ($ this ->submissionId , $ this ->locale );
266350
267- $ this ->assertEquals ($ sectionEditorsUser ->getFullName (), $ scieloArticle ->getSectionEditor ());
351+ $ this ->assertEquals ($ sectionEditorUser ->getFullName (), $ scieloArticle ->getSectionEditor ());
268352 }
269353
270354 /**
271355 * @group OJS
272- */
356+ */
273357 public function testSubmissionGetsNoSectionEditor (): void
274358 {
275359 $ sectionEditorGroupId = $ this ->createSectionEditorUserGroup ();
@@ -284,7 +368,7 @@ public function testSubmissionGetsNoSectionEditor(): void
284368
285369 /**
286370 * @group OJS
287- */
371+ */
288372 public function testSubmissionGetsLastDecision (): void
289373 {
290374 $ decision = SUBMISSION_EDITOR_DECISION_INITIAL_DECLINE ;
@@ -299,7 +383,7 @@ public function testSubmissionGetsLastDecision(): void
299383
300384 /**
301385 * @group OJS
302- */
386+ */
303387 public function testSubmissionGetsLastDecisionOfNewRound (): void
304388 {
305389 $ decision = SUBMISSION_EDITOR_DECISION_NEW_ROUND ;
@@ -314,7 +398,7 @@ public function testSubmissionGetsLastDecisionOfNewRound(): void
314398
315399 /**
316400 * @group OJS
317- */
401+ */
318402 public function testSubmissionGetsNoLastDecision (): void
319403 {
320404 $ articleFactory = new ScieloArticleFactory ();
@@ -325,7 +409,7 @@ public function testSubmissionGetsNoLastDecision(): void
325409
326410 /**
327411 * @group OJS
328- */
412+ */
329413 public function testSubmissionGetsReviews (): void
330414 {
331415 $ recommendation = SUBMISSION_REVIEWER_RECOMMENDATION_ACCEPT ;
@@ -350,7 +434,7 @@ public function testSubmissionGetsReviews(): void
350434
351435 /**
352436 * @group OJS
353- */
437+ */
354438 public function testSubmissionGetsFinalDecisionWithDateInitialDecline (): void
355439 {
356440 $ finalDecisionCode = SUBMISSION_EDITOR_DECISION_INITIAL_DECLINE ;
@@ -367,7 +451,7 @@ public function testSubmissionGetsFinalDecisionWithDateInitialDecline(): void
367451
368452 /**
369453 * @group OJS
370- */
454+ */
371455 public function testSubmissionGetsFinalDecisionWithDateDecline (): void
372456 {
373457 $ finalDecisionCode = SUBMISSION_EDITOR_DECISION_DECLINE ;
@@ -384,7 +468,7 @@ public function testSubmissionGetsFinalDecisionWithDateDecline(): void
384468
385469 /**
386470 * @group OJS
387- */
471+ */
388472 public function testSubmissionGetsFinalDecisionWithDateAccept (): void
389473 {
390474 $ finalDecisionCode = SUBMISSION_EDITOR_DECISION_ACCEPT ;
0 commit comments