Internal - Fix behat test

pull/3464/head
Julio Montoya 4 years ago
parent 11116b41fd
commit 721f6608ec
  1. 4
      .travis.yml
  2. 1
      public/main/admin/user_list.php
  3. 13
      public/main/inc/lib/api.lib.php
  4. 4
      tests/behat/features/sessionAccess.feature
  5. 2
      tests/behat/features/toolWork.feature

@ -120,7 +120,7 @@ script:
# - ../../vendor/behat/behat/bin/behat features/profile.feature -v
- ../../vendor/behat/behat/bin/behat features/promotion.feature -v
# - ../../vendor/behat/behat/bin/behat features/registration.feature -v
- ../../vendor/behat/behat/bin/behat features/sessionAccess.feature -v
- ../../vendor/behat/behat/bin/behat features/sessionAccess.feature -vvv
# - ../../vendor/behat/behat/bin/behat features/sessionManagement.feature -v
# - ../../vendor/behat/behat/bin/behat features/socialGroup.feature -v
# - ../../vendor/behat/behat/bin/behat features/systemAnnouncements.feature -v
@ -133,7 +133,7 @@ script:
# - ../../vendor/behat/behat/bin/behat features/toolGroup.feature -vv
- ../../vendor/behat/behat/bin/behat features/toolLink.feature -v
# - ../../vendor/behat/behat/bin/behat features/toolLp.feature -v
- ../../vendor/behat/behat/bin/behat features/toolWork.feature -v
- ../../vendor/behat/behat/bin/behat features/toolWork.feature -vvv
after_failure:
- sudo cat /var/log/apache2/error.log

@ -38,6 +38,7 @@ if (isset($_GET['user_id']) && 'login_as' === $action) {
$goTo = sprintf(get_lang('Login successful. Go to %s'), Display::url($url, $url));
Display::addFlash(Display::return_message($message, 'normal', false));
Display::addFlash(Display::return_message($goTo, 'normal', false));
api_location($url.'?_switch_user='.$oldUserInfo['username']);
/*Display::display_header(get_lang('User list'));

@ -7643,9 +7643,16 @@ function api_get_default_tool_setting($tool, $setting, $defaultValue)
*/
function api_can_login_as($loginAsUserId, $userId = null)
{
$loginAsUserId = (int) $loginAsUserId;
if (empty($loginAsUserId)) {
return false;
}
if (empty($userId)) {
$userId = api_get_user_id();
}
if ($loginAsUserId == $userId) {
return false;
}
@ -7654,10 +7661,6 @@ function api_can_login_as($loginAsUserId, $userId = null)
return false;
}
if ($loginAsUserId != strval(intval($loginAsUserId))) {
return false;
}
// Check if the user to login is an admin
if (api_is_platform_admin_by_id($loginAsUserId)) {
// Only super admins can login to admin accounts
@ -7677,7 +7680,7 @@ function api_can_login_as($loginAsUserId, $userId = null)
$userList = [];
if (is_array($users)) {
foreach ($users as $user) {
$userList[] = $user['user_id'];
$userList[] = $user['id'];
}
}
if (in_array($loginAsUserId, $userList)) {

@ -18,11 +18,11 @@ Feature: Session access
Then I should see "Update successful"
Then I should see "Subscribe users to this session"
Then I follow "Multiple registration"
And wait the page to be loaded when ready
And wait very long for the page to be loaded
Then I select "Warnier Yannick (ywarnier)" from "nosessionUsersList[]"
And I press "add_user"
And I press "next"
And wait for the page to be loaded
And wait very long for the page to be loaded
Then I should see "Session1"
Then I should see "TEMPPRIVATE"
Then I should see "ywarnier"

@ -30,7 +30,7 @@ Feature: Work tool
Scenario: Send work as student
Given I am a student
And I am on "/main/work/work.php?cid=1"
And wait for the page to be loaded
And wait very long for the page to be loaded
And I follow "Work 1"
Then I should see "Work 1"
Then I follow "Upload my assignment"

Loading…
Cancel
Save