Behat - fix tests

pull/3064/head
Julio 6 years ago
parent aa807dd19d
commit ac70aba95c
  1. 1
      public/main/admin/user_update_import.php
  2. 1
      public/main/exercise/answer.class.php
  3. 1
      public/main/exercise/tests_category.php
  4. 1
      public/main/exercise/unique_answer.class.php
  5. 2
      public/main/inc/lib/api.lib.php
  6. 117
      public/main/inc/lib/sessionmanager.lib.php
  7. 5
      public/main/session/add_courses_to_session.php
  8. 3
      src/CoreBundle/Resources/views/Account/edit.html.twig
  9. 4
      tests/behat/features/profile.feature
  10. 2
      tests/behat/features/sessionAccess.feature
  11. 12
      tests/behat/features/sessionManagement.feature
  12. 2
      tests/behat/features/toolExercise.feature

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Entity\CQuizAnswer; use Chamilo\CourseBundle\Entity\CQuizAnswer;

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Entity\CQuizAnswer; use Chamilo\CourseBundle\Entity\CQuizAnswer;

@ -3662,7 +3662,7 @@ function api_not_allowed(
// Default code is 403 forbidden // Default code is 403 forbidden
$responseCode = empty($responseCode) ? 403 : $responseCode; $responseCode = empty($responseCode) ? 403 : $responseCode;
$message = empty($message) ? get_lang('Not authorized') : $message; $message = empty($message) ? get_lang('You are not allowed') : $message;
// Create new exception rendered by template: // Create new exception rendered by template:
// src/ThemeBundle/Resources/views/Exception/error.html.twig // src/ThemeBundle/Resources/views/Exception/error.html.twig

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\Course;
@ -524,16 +525,16 @@ class SessionManager
} }
$select = $select =
"SELECT DISTINCT "SELECT DISTINCT
s.name, s.name,
s.display_start_date, s.display_start_date,
s.display_end_date, s.display_end_date,
access_start_date, access_start_date,
access_end_date, access_end_date,
s.visibility, s.visibility,
s.session_category_id, s.session_category_id,
$inject_extra_fields $inject_extra_fields
s.id s.id
"; ";
if ($showCountUsers) { if ($showCountUsers) {
@ -1085,18 +1086,18 @@ class SessionManager
FROM $workTable w FROM $workTable w
LEFT JOIN $workTableAssignment a LEFT JOIN $workTableAssignment a
ON (a.publication_id = w.id AND a.c_id = w.c_id) ON (a.publication_id = w.id AND a.c_id = w.c_id)
WHERE WHERE
w.c_id = %s AND w.c_id = %s AND
parent_id = 0 AND parent_id = 0 AND
active IN (1, 0)"; active IN (1, 0)";
} else { } else {
$sql = "SELECT count(w.id) as count $sql = "SELECT count(w.id) as count
FROM $workTable w FROM $workTable w
LEFT JOIN $workTableAssignment a LEFT JOIN $workTableAssignment a
ON (a.publication_id = w.id AND a.c_id = w.c_id) ON (a.publication_id = w.id AND a.c_id = w.c_id)
WHERE WHERE
w.c_id = %s AND w.c_id = %s AND
parent_id = 0 AND parent_id = 0 AND
active IN (1, 0)"; active IN (1, 0)";
if (empty($sessionId)) { if (empty($sessionId)) {
@ -1760,7 +1761,7 @@ class SessionManager
$courses = self::getCoursesInSession($sessionId); $courses = self::getCoursesInSession($sessionId);
foreach ($courses as $courseId) { foreach ($courses as $courseId) {
$courseInfo = api_get_course_info_by_id($courseId); $courseInfo = api_get_course_info_by_id($courseId);
DocumentManager::deleteDocumentsFromSession($courseInfo, $sessionId); /*DocumentManager::deleteDocumentsFromSession($courseInfo, $sessionId);
$works = Database::select( $works = Database::select(
'*', '*',
$tbl_student_publication, $tbl_student_publication,
@ -1775,7 +1776,7 @@ class SessionManager
Database::query("DELETE FROM $tbl_student_publication_assignment WHERE publication_id = $index"); Database::query("DELETE FROM $tbl_student_publication_assignment WHERE publication_id = $index");
} }
my_delete($currentCourseRepositorySys.'/'.$work['url']); my_delete($currentCourseRepositorySys.'/'.$work['url']);
} }*/
} }
$sessionEntity = api_get_session_entity($sessionId); $sessionEntity = api_get_session_entity($sessionId);
@ -1828,7 +1829,7 @@ class SessionManager
{ {
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$id = intval($id); $id = intval($id);
$sql = "UPDATE $tbl_session $sql = "UPDATE $tbl_session
SET promotion_id = 0 SET promotion_id = 0
WHERE promotion_id = $id"; WHERE promotion_id = $id";
if (Database::query($sql)) { if (Database::query($sql)) {
@ -2043,8 +2044,8 @@ class SessionManager
// Delete users from the session // Delete users from the session
if ($empty_users === true) { if ($empty_users === true) {
$sql = "DELETE FROM $tbl_session_rel_user $sql = "DELETE FROM $tbl_session_rel_user
WHERE WHERE
session_id = $sessionId AND session_id = $sessionId AND
relation_type <> ".SESSION_RELATION_TYPE_RRHH; relation_type <> ".SESSION_RELATION_TYPE_RRHH;
// Don't reset session_rel_user.registered_at of users that will be registered later anyways. // Don't reset session_rel_user.registered_at of users that will be registered later anyways.
if (!empty($userList)) { if (!empty($userList)) {
@ -2084,7 +2085,7 @@ class SessionManager
} }
// update number of users in the session // update number of users in the session
$sql = "UPDATE $tbl_session $sql = "UPDATE $tbl_session
SET nbr_users = (SELECT count(user_id) FROM $tbl_session_rel_user WHERE session_id = $sessionId) SET nbr_users = (SELECT count(user_id) FROM $tbl_session_rel_user WHERE session_id = $sessionId)
WHERE id = $sessionId"; WHERE id = $sessionId";
Database::query($sql); Database::query($sql);
@ -2469,7 +2470,7 @@ class SessionManager
if (Database::affected_rows($result)) { if (Database::affected_rows($result)) {
// Update number of users in this relation // Update number of users in this relation
$sql = "UPDATE $tbl_session_rel_course SET $sql = "UPDATE $tbl_session_rel_course SET
nbr_users = nbr_users - 1 nbr_users = nbr_users - 1
WHERE session_id = $session_id AND c_id = $courseId"; WHERE session_id = $session_id AND c_id = $courseId";
Database::query($sql); Database::query($sql);
@ -3315,7 +3316,7 @@ class SessionManager
$extraField = new ExtraFieldModel('session'); $extraField = new ExtraFieldModel('session');
$field = $extraField->get_handler_field_info_by_field_variable('image'); $field = $extraField->get_handler_field_info_by_field_variable('image');
$sql = "SELECT $sql = "SELECT
s.id, s.id,
s.name, s.name,
s.id_coach, s.id_coach,
@ -3508,7 +3509,7 @@ class SessionManager
$sql = "DELETE FROM $tbl_session_rel_user $sql = "DELETE FROM $tbl_session_rel_user
WHERE WHERE
session_id = $sessionId AND session_id = $sessionId AND
relation_type =".SESSION_RELATION_TYPE_RRHH; relation_type =".SESSION_RELATION_TYPE_RRHH;
Database::query($sql); Database::query($sql);
@ -3559,14 +3560,14 @@ class SessionManager
if (api_is_multiple_url_enabled()) { if (api_is_multiple_url_enabled()) {
$sql = "SELECT s.session_id $sql = "SELECT s.session_id
FROM $tbl_session_rel_user s FROM $tbl_session_rel_user s
INNER JOIN $tbl_session_rel_access_url a INNER JOIN $tbl_session_rel_access_url a
ON (a.session_id = s.session_id) ON (a.session_id = s.session_id)
WHERE WHERE
s.user_id = $userId AND s.user_id = $userId AND
relation_type = ".SESSION_RELATION_TYPE_RRHH." AND relation_type = ".SESSION_RELATION_TYPE_RRHH." AND
access_url_id = ".api_get_current_access_url_id(); access_url_id = ".api_get_current_access_url_id();
} else { } else {
$sql = "SELECT s.session_id $sql = "SELECT s.session_id
FROM $tbl_session_rel_user s FROM $tbl_session_rel_user s
WHERE user_id = $userId AND relation_type=".SESSION_RELATION_TYPE_RRHH; WHERE user_id = $userId AND relation_type=".SESSION_RELATION_TYPE_RRHH;
} }
@ -3826,9 +3827,9 @@ class SessionManager
$whereConditions .= $keywordCondition; $whereConditions .= $keywordCondition;
$subQuery = $sessionQuery.$courseSessionQuery; $subQuery = $sessionQuery.$courseSessionQuery;
$sql = " $select $sql = " $select
FROM $tbl_session s FROM $tbl_session s
INNER JOIN $tbl_session_rel_access_url a INNER JOIN $tbl_session_rel_access_url a
ON (s.id = a.session_id) ON (s.id = a.session_id)
$sqlInjectJoins $sqlInjectJoins
WHERE WHERE
@ -3838,7 +3839,7 @@ class SessionManager
) )
$whereConditions $whereConditions
$extraFieldsConditions $extraFieldsConditions
$sqlInjectWhere $sqlInjectWhere
$orderCondition $orderCondition
$limitCondition"; $limitCondition";
@ -4311,10 +4312,10 @@ class SessionManager
$table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER); $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT session_rcru.status $sql = "SELECT session_rcru.status
FROM $table session_rcru FROM $table session_rcru
INNER JOIN $tbl_user user INNER JOIN $tbl_user user
ON (session_rcru.user_id = user.user_id) ON (session_rcru.user_id = user.user_id)
WHERE WHERE
session_rcru.session_id = '".intval($session_id)."' AND session_rcru.session_id = '".intval($session_id)."' AND
session_rcru.c_id ='".intval($courseId)."' AND session_rcru.c_id ='".intval($courseId)."' AND
user.user_id = ".intval($user_id); user.user_id = ".intval($user_id);
@ -4779,12 +4780,12 @@ class SessionManager
$sql = "SELECT name, s.id $sql = "SELECT name, s.id
FROM $table_session_course sc FROM $table_session_course sc
INNER JOIN $table_session s INNER JOIN $table_session s
ON (sc.session_id = s.id) ON (sc.session_id = s.id)
INNER JOIN $url u INNER JOIN $url u
ON (u.session_id = s.id) ON (u.session_id = s.id)
WHERE WHERE
u.access_url_id = $urlId AND u.access_url_id = $urlId AND
sc.c_id = '$courseId' "; sc.c_id = '$courseId' ";
$result = Database::query($sql); $result = Database::query($sql);
@ -5781,7 +5782,7 @@ class SessionManager
} }
$access_url_id = api_get_current_access_url_id(); $access_url_id = api_get_current_access_url_id();
UrlManager::add_session_to_url($session_id, $access_url_id); UrlManager::add_session_to_url($session_id, $access_url_id);
$sql = "UPDATE $tbl_session SET nbr_users = '$user_counter', nbr_courses = '$course_counter' $sql = "UPDATE $tbl_session SET nbr_users = '$user_counter', nbr_courses = '$course_counter'
WHERE id = '$session_id'"; WHERE id = '$session_id'";
Database::query($sql); Database::query($sql);
@ -6101,7 +6102,7 @@ class SessionManager
if (!empty($userConditionsFromDrh)) { if (!empty($userConditionsFromDrh)) {
$userUnion = " $userUnion = "
UNION ( UNION (
$select $select
FROM $tbl_user u FROM $tbl_user u
INNER JOIN $tbl_user_rel_access_url url ON (url.user_id = u.id) INNER JOIN $tbl_user_rel_access_url url ON (url.user_id = u.id)
$where $where
@ -6436,11 +6437,11 @@ class SessionManager
$courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER); $courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
// Select the teachers. // Select the teachers.
$sql = "SELECT DISTINCT(cu.user_id) $sql = "SELECT DISTINCT(cu.user_id)
FROM $course c FROM $course c
INNER JOIN $sessionCourse src INNER JOIN $sessionCourse src
ON c.id = src.c_id ON c.id = src.c_id
INNER JOIN $courseUser cu INNER JOIN $courseUser cu
ON (cu.c_id = c.id) ON (cu.c_id = c.id)
WHERE src.session_id IN ('$sessionToString') AND cu.status = 1"; WHERE src.session_id IN ('$sessionToString') AND cu.status = 1";
$result = Database::query($sql); $result = Database::query($sql);
@ -7111,15 +7112,15 @@ class SessionManager
$courseCondition = " c_id = $courseId AND "; $courseCondition = " c_id = $courseId AND ";
} }
$sql = "SELECT $sql = "SELECT
COUNT(u.id) as count, COUNT(u.id) as count,
u.id, u.id,
scu.status status_in_session, scu.status status_in_session,
u.status user_status u.status user_status
FROM $table scu FROM $table scu
INNER JOIN $tableUser u INNER JOIN $tableUser u
ON scu.user_id = u.id ON scu.user_id = u.id
WHERE WHERE
$courseCondition $courseCondition
scu.session_id = ".$sessionId." scu.session_id = ".$sessionId."
GROUP BY u.id"; GROUP BY u.id";
@ -7613,7 +7614,7 @@ class SessionManager
$sql = "SELECT DISTINCT s.* $sql = "SELECT DISTINCT s.*
FROM $sessionTable s FROM $sessionTable s
INNER JOIN $sessionUserTable sru INNER JOIN $sessionUserTable sru
ON s.id = sru.id_session ON s.id = sru.id_session
WHERE WHERE
(sru.id_user IN (".implode(', ', $userIdList).") (sru.id_user IN (".implode(', ', $userIdList).")
@ -8497,7 +8498,7 @@ class SessionManager
LEFT JOIN $tbl_session_category sc LEFT JOIN $tbl_session_category sc
ON (s.session_category_id = sc.id) ON (s.session_category_id = sc.id)
INNER JOIN $tbl_user u INNER JOIN $tbl_user u
ON (s.id_coach = u.user_id) ON (s.id_coach = u.user_id)
$where $where
$limit $limit
"; ";
@ -8508,19 +8509,19 @@ class SessionManager
if ($access_url_id != -1) { if ($access_url_id != -1) {
$query = "$select $query = "$select
FROM $tbl_session s FROM $tbl_session s
LEFT JOIN $tbl_session_field_values fv LEFT JOIN $tbl_session_field_values fv
ON (fv.item_id = s.id) ON (fv.item_id = s.id)
LEFT JOIN $tbl_session_field_options fvo LEFT JOIN $tbl_session_field_options fvo
ON (fv.field_id = fvo.field_id) ON (fv.field_id = fvo.field_id)
LEFT JOIN $tbl_session_rel_course src LEFT JOIN $tbl_session_rel_course src
ON (src.session_id = s.id) ON (src.session_id = s.id)
LEFT JOIN $tbl_course c LEFT JOIN $tbl_course c
ON (src.c_id = c.id) ON (src.c_id = c.id)
LEFT JOIN $tbl_session_category sc LEFT JOIN $tbl_session_category sc
ON (s.session_category_id = sc.id) ON (s.session_category_id = sc.id)
INNER JOIN $tbl_user u INNER JOIN $tbl_user u
ON (s.id_coach = u.user_id) ON (s.id_coach = u.user_id)
INNER JOIN $table_access_url_rel_session ar INNER JOIN $table_access_url_rel_session ar
ON (ar.session_id = s.id AND ar.access_url_id = $access_url_id) ON (ar.session_id = s.id AND ar.access_url_id = $access_url_id)
$where $where
$limit $limit
@ -8945,7 +8946,7 @@ class SessionManager
return []; return [];
} }
$sql = "SELECT * FROM $table $sql = "SELECT * FROM $table
WHERE c_id = $courseId AND user_id = $userId"; WHERE c_id = $courseId AND user_id = $userId";
$result = Database::query($sql); $result = Database::query($sql);
@ -8992,9 +8993,9 @@ class SessionManager
INNER JOIN ChamiloCoreBundle:SessionRelUser su INNER JOIN ChamiloCoreBundle:SessionRelUser su
WITH scu.user = su.user WITH scu.user = su.user
AND scu.session = su.session AND scu.session = su.session
WHERE WHERE
scu.course = :course AND scu.course = :course AND
su.relationType <> :relationType AND su.relationType <> :relationType AND
scu.session = :session scu.session = :session
") ")
->setParameters([ ->setParameters([

@ -1,9 +1,8 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* @package chamilo.admin
*
* @todo use formvalidator * @todo use formvalidator
*/ */
$cidReset = true; $cidReset = true;
@ -80,7 +79,7 @@ function remove_item(origin)
$CourseList = $SessionList = []; $CourseList = $SessionList = [];
$courses = $sessions = []; $courses = $sessions = [];
if (isset($_POST['formSent']) && $_POST['formSent']) { if (isset($_POST['formSent']) && $_POST['formSent'] && isset($_POST['SessionCoursesList'])) {
$courseList = $_POST['SessionCoursesList']; $courseList = $_POST['SessionCoursesList'];
$copyEvaluation = isset($_POST['copy_evaluation']); $copyEvaluation = isset($_POST['copy_evaluation']);
$copyCourseTeachersAsCoach = isset($_POST['import_teachers_as_course_coach']); $copyCourseTeachersAsCoach = isset($_POST['import_teachers_as_course_coach']);

@ -2,12 +2,11 @@
{% block content %} {% block content %}
{% autoescape false %} {% autoescape false %}
<h2> {{ 'Edit profile' | trans }}</h2>
<h3>{{ user.username }}</h3> <h3>{{ user.username }}</h3>
{{ form_start(form, { 'action': path('chamilo_core_account_edit'), 'attr': { 'class': 'edit' } }) }} {{ form_start(form, { 'action': path('chamilo_core_account_edit'), 'attr': { 'class': 'edit' } }) }}
{{ form_widget(form) }} {{ form_widget(form) }}
<div> <div>
<input class="btn btn-primary" type="submit" value="{{ 'Save'|trans }}" /> <input class="btn btn-primary" type="submit" value="{{ 'Update profile'|trans }}" />
</div> </div>
{{ form_end(form) }} {{ form_end(form) }}
{% endautoescape %} {% endautoescape %}

@ -10,14 +10,14 @@ Feature: Profile page
Then I follow "Edit profile" Then I follow "Edit profile"
Then I fill in the following: Then I fill in the following:
| profile_firstname | Andrew | | profile_firstname | Andrew |
And I press "Save" And I press "Update profile"
And wait for the page to be loaded And wait for the page to be loaded
Then I should see "Updated" Then I should see "Updated"
And I should see "Andrew" And I should see "Andrew"
Then I follow "Edit profile" Then I follow "Edit profile"
Then I fill in the following: Then I fill in the following:
| profile_firstname | Andrea | | profile_firstname | Andrea |
And I press "Save" And I press "Update profile"
Then I should see "Updated" Then I should see "Updated"
Then I am on "/main/social/home.php" Then I am on "/main/social/home.php"
Then I should see "Andrea" Then I should see "Andrea"

@ -54,7 +54,7 @@ Feature: Session access
Scenario: ywarnier connect to Session 2 Scenario: ywarnier connect to Session 2
Given I am logged as "ywarnier" Given I am logged as "ywarnier"
Then I am on course "TEMPPRIVATE" homepage in session "Session2" Then I am on course "TEMPPRIVATE" homepage in session "Session2"
Then I should see "You are not allowed" Then I should see "Unauthorised access to course"
Scenario: ywarnier connect to session that doesn't exists Scenario: ywarnier connect to session that doesn't exists
Given I am logged as "ywarnier" Given I am logged as "ywarnier"

@ -43,7 +43,7 @@ Feature: Session management tool
Then I should see "Update successful" Then I should see "Update successful"
Scenario: Check session description is not present Scenario: Check session description is not present
Given I am on "/user_portal.php?nosession=true" Given I am on "/main/index/user_portal.php"
Then I should see "Temp Session" Then I should see "Temp Session"
And I should not see "Description for Temp Session" And I should not see "Description for Temp Session"
@ -58,10 +58,10 @@ Feature: Session management tool
Scenario: Check session description with platform setting off Scenario: Check session description with platform setting off
Given I am a platform administrator Given I am a platform administrator
And I am on "/main/admin/settings.php?search_field=show_session_description&category=search_setting" And I am on "/admin/settings/search_settings?keyword=show_session_description"
And I check the "show_session_description" radio button with "false" value And I select "yes" from "form_show_session_description"
And I press "Save settings" And I press "Save"
Then I am on "/user_portal.php?nosession=true" Then I am on "/main/index/user_portal.php"
Then I should see "Temp Session" Then I should see "Temp Session"
And I should not see "Description for Temp Session" And I should not see "Description for Temp Session"
@ -71,7 +71,7 @@ Feature: Session management tool
And I check the "show_session_description" radio button with "true" value And I check the "show_session_description" radio button with "true" value
And I press "Save settings" And I press "Save settings"
Then I should see "Update successful" Then I should see "Update successful"
Then I am on "/user_portal.php?nosession=true" Then I am on "/main/index/user_portal.php"
Then I should see "Temp Session" Then I should see "Temp Session"
And I should see "Description for Temp Session" And I should see "Description for Temp Session"

@ -398,7 +398,7 @@ Feature: Exercise tool
| Total | 190 / 190 | 100% | | Total | 190 / 190 | 100% |
Scenario: Teacher looks at exercise results by categories Scenario: Teacher looks at exercise results by categories
Given I am on "/user_portal.php" Given I am on "/main/index/user_portal.php"
And I am on course "TEMP" homepage in session "Session Exercise" And I am on course "TEMP" homepage in session "Session Exercise"
Then I should see "TEMP (Session Exercise)" Then I should see "TEMP (Session Exercise)"
And I am on "/main/exercise/exercise.php?cid=1" And I am on "/main/exercise/exercise.php?cid=1"

Loading…
Cancel
Save