diff --git a/.travis.yml b/.travis.yml index 6420ccf8d9..a05215fbca 100755 --- a/.travis.yml +++ b/.travis.yml @@ -106,7 +106,7 @@ script: - php bin/console cache:clear - sudo chmod -R 777 var public - cd tests/behat - - ../../vendor/behat/behat/bin/behat features/actionUserLogin.feature -vvv + - ../../vendor/behat/behat/bin/behat features/actionUserLogin.feature -v - ../../vendor/behat/behat/bin/behat features/adminFillUsers.feature -vvv - ../../vendor/behat/behat/bin/behat features/adminSettings.feature -vvv - ../../vendor/behat/behat/bin/behat features/career.feature -vvv @@ -114,7 +114,7 @@ script: # - ../../vendor/behat/behat/bin/behat features/companyReports.feature -v - ../../vendor/behat/behat/bin/behat features/course.feature -vvv # - ../../vendor/behat/behat/bin/behat features/course_user_registration.feature -v - - ../../vendor/behat/behat/bin/behat features/createUser.feature -v + - ../../vendor/behat/behat/bin/behat features/createUser.feature -vvv # - ../../vendor/behat/behat/bin/behat features/createUserViaCSV.feature -v # - ../../vendor/behat/behat/bin/behat features/extraFieldUser.feature -v # - ../../vendor/behat/behat/bin/behat features/profile.feature -v diff --git a/public/main/admin/configure_inscription.php b/public/main/admin/configure_inscription.php index b26d9270af..46e1d05811 100644 --- a/public/main/admin/configure_inscription.php +++ b/public/main/admin/configure_inscription.php @@ -182,7 +182,7 @@ if ($display_all_form) { if ('true' == api_get_setting('registration', 'email')) { $form->addRule('email', get_lang('Required field'), 'required'); } - $form->addRule('email', get_lang('e-mailWrong'), 'email'); + $form->addEmailRule('email'); // USERNAME $form->addElement('text', 'username', get_lang('Username'), ['size' => USERNAME_MAX_LENGTH, 'disabled' => 'disabled']); diff --git a/public/main/admin/user_add.php b/public/main/admin/user_add.php index 944a2cf9b3..fed9b7a3b1 100644 --- a/public/main/admin/user_add.php +++ b/public/main/admin/user_add.php @@ -138,13 +138,18 @@ $form->applyFilter('official_code', 'html_filter'); $form->applyFilter('official_code', 'trim'); // e-mail $form->addElement('text', 'email', get_lang('e-mail'), ['size' => '40', 'autocomplete' => 'off', 'id' => 'email']); -$form->addRule('email', get_lang('e-mailWrong'), 'email'); +$form->addEmailRule('email'); if ('true' == api_get_setting('registration', 'email')) { - $form->addRule('email', get_lang('e-mailWrong'), 'required'); + $form->addRule('email', get_lang('Required field'), 'required'); } if ('true' == api_get_setting('login_is_email')) { - $form->addRule('email', sprintf(get_lang('The login needs to be maximum %s characters long'), (string) USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH); + $form->addRule( + 'email', + sprintf(get_lang('The login needs to be maximum %s characters long'), (string) USERNAME_MAX_LENGTH), + 'maxlength', + USERNAME_MAX_LENGTH + ); $form->addRule('email', get_lang('This login is already in use'), 'username_available'); } diff --git a/public/main/admin/user_edit.php b/public/main/admin/user_edit.php index f600bcca47..0c6e4d222d 100644 --- a/public/main/admin/user_edit.php +++ b/public/main/admin/user_edit.php @@ -133,9 +133,9 @@ $form->applyFilter('official_code', 'trim'); // e-mail $form->addElement('text', 'email', get_lang('e-mail')); -$form->addRule('email', get_lang('e-mailWrong'), 'email'); +$form->addEmailRule('email'); if ('true' == api_get_setting('registration', 'email')) { - $form->addRule('email', get_lang('e-mailWrong'), 'required'); + $form->addRule('email', get_lang('Required field'), 'required'); } if ('true' == api_get_setting('login_is_email')) { diff --git a/public/main/auth/inscription.php b/public/main/auth/inscription.php index 7243daa80a..cbe80af326 100644 --- a/public/main/auth/inscription.php +++ b/public/main/auth/inscription.php @@ -157,7 +157,7 @@ if (false === $user_already_registered_show_terms && $form->addRule('email', get_lang('This login is already in use'), 'username_available'); } - $form->addRule('email', get_lang('e-mailWrong'), 'email'); + $form->addEmailRule('email'); // USERNAME if ('true' != api_get_setting('login_is_email')) { diff --git a/public/main/auth/profile.php b/public/main/auth/profile.php index 84c8b71678..d8fbfbf744 100644 --- a/public/main/auth/profile.php +++ b/public/main/auth/profile.php @@ -175,7 +175,7 @@ if ('true' == api_get_setting('registration', 'email') && in_array('email', $pro $form->applyFilter('email', 'stripslashes'); $form->applyFilter('email', 'trim'); $form->addRule('email', get_lang('Required field'), 'required'); - $form->addRule('email', get_lang('e-mailWrong'), 'email'); + $form->addEmailRule('email'); } // PHONE diff --git a/public/main/inc/lib/formvalidator/FormValidator.class.php b/public/main/inc/lib/formvalidator/FormValidator.class.php index 25d41b3106..d49a737c62 100644 --- a/public/main/inc/lib/formvalidator/FormValidator.class.php +++ b/public/main/inc/lib/formvalidator/FormValidator.class.php @@ -1864,6 +1864,15 @@ EOT; }); "); } + + public function addEmailRule(string $element) + { + $this->addRule( + $element, + get_lang('The email address is not complete or contains some invalid characters'), + 'email' + ); + } } /** diff --git a/public/main/survey/fillsurvey.php b/public/main/survey/fillsurvey.php index b93af417dc..dd2d0aaecd 100644 --- a/public/main/survey/fillsurvey.php +++ b/public/main/survey/fillsurvey.php @@ -504,7 +504,7 @@ if ('' != $survey_data['form_fields'] && if ('true' == api_get_setting('registration', 'email')) { $form->addRule('email', get_lang('Required field'), 'required'); } - $form->addRule('email', get_lang('e-mailWrong'), 'email'); + $form->addEmailRule('email'); } if (isset($list['phone']) && 1 == $list['phone']) { diff --git a/src/CoreBundle/Entity/Course.php b/src/CoreBundle/Entity/Course.php index 1a9270a88a..47a99878ff 100644 --- a/src/CoreBundle/Entity/Course.php +++ b/src/CoreBundle/Entity/Course.php @@ -28,10 +28,10 @@ use Symfony\Component\Validator\Constraints as Assert; * attributes={"security"="is_granted('ROLE_ADMIN')"}, * iri="https://schema.org/Course", * normalizationContext={"groups"={"course:read"}, "swagger_definition_name"="Read"}, - * denormalizationContext={"groups"={"course:write","course_category:write"}}, + * denormalizationContext={"groups"={"course:write"}}, * ) * - * @ApiFilter(SearchFilter::class, properties={"title": "partial", "code": "partial", "category": "partial"}) + * @ApiFilter(SearchFilter::class, properties={"title": "partial", "code": "partial"}) * @ApiFilter(PropertyFilter::class) * @ApiFilter(OrderFilter::class, properties={"id", "title"}) * diff --git a/tests/behat/features/bootstrap/FeatureContext.php b/tests/behat/features/bootstrap/FeatureContext.php index ae40800fc9..338769468e 100644 --- a/tests/behat/features/bootstrap/FeatureContext.php +++ b/tests/behat/features/bootstrap/FeatureContext.php @@ -201,8 +201,7 @@ class FeatureContext extends MinkContext */ public function iAmNotLogged() { - $this->visit('/index.php?logout=logout'); - $this->visit('I am on homepage'); + $this->visit('/logout'); } /** diff --git a/tests/behat/features/createUser.feature b/tests/behat/features/createUser.feature index 15e1d8f85f..4e6ec0071f 100644 --- a/tests/behat/features/createUser.feature +++ b/tests/behat/features/createUser.feature @@ -104,6 +104,7 @@ Feature: Users management as admin Scenario: HRM follows teacher And I am on "/main/admin/user_list.php?keyword=hrm&submit=&_qf__search_simple=" + And wait the page to be loaded when ready And I should see "HRM lastname" And I should see "Human Resources Manager" And I follow "Assign users" @@ -115,6 +116,7 @@ Feature: Users management as admin Scenario: HRM follows student And I am on "/main/admin/user_list.php?keyword=hrm&submit=&_qf__search_simple=" + And wait the page to be loaded when ready And I should see "HRM lastname" And I should see "Human Resources Manager" And I follow "Assign users" @@ -125,7 +127,8 @@ Feature: Users management as admin Then I should see "The assigned users have been updated" Scenario: HRM logs as teacher - Given I am logged as "hrm" + Given I am not logged + Then I am logged as "hrm" And I am on "/main/mySpace/teachers.php" Then I should see "teacher lastname" Then I follow "teacher lastname" @@ -135,7 +138,8 @@ Feature: Users management as admin Then I should see "Login successful" Scenario: HRM logs as student - Given I am logged as "hrm" + Given I am not logged + Then I am logged as "hrm" And I am on "/main/mySpace/student.php" Then I should see "student lastname" Then I follow "student lastname"