Internal - Fix behat tests

pull/3464/head
Julio Montoya 5 years ago
parent b00a91585d
commit fa75cc7c5f
  1. 4
      .travis.yml
  2. 2
      public/main/admin/configure_inscription.php
  3. 11
      public/main/admin/user_add.php
  4. 4
      public/main/admin/user_edit.php
  5. 2
      public/main/auth/inscription.php
  6. 2
      public/main/auth/profile.php
  7. 9
      public/main/inc/lib/formvalidator/FormValidator.class.php
  8. 2
      public/main/survey/fillsurvey.php
  9. 4
      src/CoreBundle/Entity/Course.php
  10. 3
      tests/behat/features/bootstrap/FeatureContext.php
  11. 8
      tests/behat/features/createUser.feature

@ -106,7 +106,7 @@ script:
- php bin/console cache:clear - php bin/console cache:clear
- sudo chmod -R 777 var public - sudo chmod -R 777 var public
- cd tests/behat - 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/adminFillUsers.feature -vvv
- ../../vendor/behat/behat/bin/behat features/adminSettings.feature -vvv - ../../vendor/behat/behat/bin/behat features/adminSettings.feature -vvv
- ../../vendor/behat/behat/bin/behat features/career.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/companyReports.feature -v
- ../../vendor/behat/behat/bin/behat features/course.feature -vvv - ../../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/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/createUserViaCSV.feature -v
# - ../../vendor/behat/behat/bin/behat features/extraFieldUser.feature -v # - ../../vendor/behat/behat/bin/behat features/extraFieldUser.feature -v
# - ../../vendor/behat/behat/bin/behat features/profile.feature -v # - ../../vendor/behat/behat/bin/behat features/profile.feature -v

@ -182,7 +182,7 @@ if ($display_all_form) {
if ('true' == api_get_setting('registration', 'email')) { if ('true' == api_get_setting('registration', 'email')) {
$form->addRule('email', get_lang('Required field'), 'required'); $form->addRule('email', get_lang('Required field'), 'required');
} }
$form->addRule('email', get_lang('e-mailWrong'), 'email'); $form->addEmailRule('email');
// USERNAME // USERNAME
$form->addElement('text', 'username', get_lang('Username'), ['size' => USERNAME_MAX_LENGTH, 'disabled' => 'disabled']); $form->addElement('text', 'username', get_lang('Username'), ['size' => USERNAME_MAX_LENGTH, 'disabled' => 'disabled']);

@ -138,13 +138,18 @@ $form->applyFilter('official_code', 'html_filter');
$form->applyFilter('official_code', 'trim'); $form->applyFilter('official_code', 'trim');
// e-mail // e-mail
$form->addElement('text', 'email', get_lang('e-mail'), ['size' => '40', 'autocomplete' => 'off', 'id' => 'email']); $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')) { 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')) { 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'); $form->addRule('email', get_lang('This login is already in use'), 'username_available');
} }

@ -133,9 +133,9 @@ $form->applyFilter('official_code', 'trim');
// e-mail // e-mail
$form->addElement('text', 'email', get_lang('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')) { 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')) { if ('true' == api_get_setting('login_is_email')) {

@ -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('This login is already in use'), 'username_available');
} }
$form->addRule('email', get_lang('e-mailWrong'), 'email'); $form->addEmailRule('email');
// USERNAME // USERNAME
if ('true' != api_get_setting('login_is_email')) { if ('true' != api_get_setting('login_is_email')) {

@ -175,7 +175,7 @@ if ('true' == api_get_setting('registration', 'email') && in_array('email', $pro
$form->applyFilter('email', 'stripslashes'); $form->applyFilter('email', 'stripslashes');
$form->applyFilter('email', 'trim'); $form->applyFilter('email', 'trim');
$form->addRule('email', get_lang('Required field'), 'required'); $form->addRule('email', get_lang('Required field'), 'required');
$form->addRule('email', get_lang('e-mailWrong'), 'email'); $form->addEmailRule('email');
} }
// PHONE // PHONE

@ -1864,6 +1864,15 @@ EOT;
}); });
</script>"); </script>");
} }
public function addEmailRule(string $element)
{
$this->addRule(
$element,
get_lang('The email address is not complete or contains some invalid characters'),
'email'
);
}
} }
/** /**

@ -504,7 +504,7 @@ if ('' != $survey_data['form_fields'] &&
if ('true' == api_get_setting('registration', 'email')) { if ('true' == api_get_setting('registration', 'email')) {
$form->addRule('email', get_lang('Required field'), 'required'); $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']) { if (isset($list['phone']) && 1 == $list['phone']) {

@ -28,10 +28,10 @@ use Symfony\Component\Validator\Constraints as Assert;
* attributes={"security"="is_granted('ROLE_ADMIN')"}, * attributes={"security"="is_granted('ROLE_ADMIN')"},
* iri="https://schema.org/Course", * iri="https://schema.org/Course",
* normalizationContext={"groups"={"course:read"}, "swagger_definition_name"="Read"}, * 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(PropertyFilter::class)
* @ApiFilter(OrderFilter::class, properties={"id", "title"}) * @ApiFilter(OrderFilter::class, properties={"id", "title"})
* *

@ -201,8 +201,7 @@ class FeatureContext extends MinkContext
*/ */
public function iAmNotLogged() public function iAmNotLogged()
{ {
$this->visit('/index.php?logout=logout'); $this->visit('/logout');
$this->visit('I am on homepage');
} }
/** /**

@ -104,6 +104,7 @@ Feature: Users management as admin
Scenario: HRM follows teacher Scenario: HRM follows teacher
And I am on "/main/admin/user_list.php?keyword=hrm&submit=&_qf__search_simple=" 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 "HRM lastname"
And I should see "Human Resources Manager" And I should see "Human Resources Manager"
And I follow "Assign users" And I follow "Assign users"
@ -115,6 +116,7 @@ Feature: Users management as admin
Scenario: HRM follows student Scenario: HRM follows student
And I am on "/main/admin/user_list.php?keyword=hrm&submit=&_qf__search_simple=" 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 "HRM lastname"
And I should see "Human Resources Manager" And I should see "Human Resources Manager"
And I follow "Assign users" And I follow "Assign users"
@ -125,7 +127,8 @@ Feature: Users management as admin
Then I should see "The assigned users have been updated" Then I should see "The assigned users have been updated"
Scenario: HRM logs as teacher 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" And I am on "/main/mySpace/teachers.php"
Then I should see "teacher lastname" Then I should see "teacher lastname"
Then I follow "teacher lastname" Then I follow "teacher lastname"
@ -135,7 +138,8 @@ Feature: Users management as admin
Then I should see "Login successful" Then I should see "Login successful"
Scenario: HRM logs as student 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" And I am on "/main/mySpace/student.php"
Then I should see "student lastname" Then I should see "student lastname"
Then I follow "student lastname" Then I follow "student lastname"

Loading…
Cancel
Save