Internal - Add work behat test, fix queries

pull/3464/head
Julio Montoya 6 years ago
parent 3fc332551f
commit da03040b70
  1. 2
      .travis.yml
  2. 5
      public/main/inc/lib/groupmanager.lib.php
  3. 2
      public/main/work/upload.php
  4. 15
      public/main/work/work.lib.php
  5. 45
      src/CoreBundle/Framework/Container.php
  6. 2
      tests/behat/features/bootstrap/FeatureContext.php
  7. 2
      tests/behat/features/sessionAccess.feature
  8. 2
      tests/behat/features/toolAgenda.feature
  9. 5
      tests/behat/features/toolGroup.feature
  10. 22
      tests/behat/features/toolWork.feature

@ -133,7 +133,7 @@ script:
- ../../vendor/behat/behat/bin/behat features/toolGroup.feature -vvv
- ../../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 -v
after_failure:
- sudo cat /var/log/apache2/error.log

@ -2292,11 +2292,10 @@ class GroupManager
$sql = "SELECT DISTINCT g.*
FROM $table_group g
LEFT JOIN $table_group_user gu
ON (gu.group_id = g.iid AND g.c_id = gu.c_id)
ON (gu.group_id = g.iid)
LEFT JOIN $table_tutor_user tu
ON (tu.group_id = g.iid AND g.c_id = tu.c_id)
ON (tu.group_id = g.iid)
WHERE
g.c_id = $courseId AND
(gu.user_id = $user_id OR tu.user_id = $user_id) ";
if (null !== $sessionId) {

@ -54,7 +54,7 @@ if ($onlyOnePublication) {
}
}
$homework = get_work_assignment_by_id($workInfo['id']);
$homework = get_work_assignment_by_id($workInfo['iid']);
$validationStatus = getWorkDateValidationStatus($homework);
$interbreadcrumb[] = [

@ -867,11 +867,11 @@ function deleteDirWork($id)
// Deleting all contents inside the folder
$sql = "UPDATE $table SET active = 2
WHERE c_id = $course_id AND filetype = 'folder' AND id = $id";
WHERE filetype = 'folder' AND iid = $id";
Database::query($sql);
$sql = "UPDATE $table SET active = 2
WHERE c_id = $course_id AND parent_id = $id";
WHERE parent_id = $id";
Database::query($sql);
/*$new_dir = $work_data_url.'_DELETED_'.$id;
@ -988,7 +988,7 @@ function updateWorkUrl($id, $new_path, $parent_id)
$sql = "UPDATE $table SET
url = '$new_url',
parent_id = '$parent_id'
WHERE c_id = $course_id AND id = $id";
WHERE iid = $id";
return Database::query($sql);
}
@ -1021,7 +1021,6 @@ function updateDirName($work_data, $newPath)
$sql = "UPDATE $table SET
title = '".$originalNewPath."'
WHERE
c_id = $course_id AND
iid = $work_id";
Database::query($sql);
}
@ -4721,15 +4720,10 @@ function updatePublicationAssignment($workId, $params, $courseInfo, $groupId)
$my_last_id = Database::insert_id();
if ($my_last_id) {
$sql = "UPDATE $table SET
id = iid
WHERE iid = $my_last_id";
Database::query($sql);
$sql = "UPDATE $workTable SET
has_properties = $my_last_id,
view_properties = 1
WHERE c_id = $course_id AND id = $workId";
WHERE iid = $workId";
Database::query($sql);
}
} else {
@ -4740,7 +4734,6 @@ function updatePublicationAssignment($workId, $params, $courseInfo, $groupId)
enable_qualification = '".$qualification."'
WHERE
publication_id = $workId AND
c_id = $course_id AND
iid = ".$data['iid'];
Database::query($sql);
}

@ -257,23 +257,12 @@ class Container
return self::$container->get('Symfony\Component\Mailer\Mailer');
}
/**
* @return SettingsManager
*/
public static function getSettingsManager()
public static function getSettingsManager(): SettingsManager
{
return self::$container->get('chamilo.settings.manager');
}
/*public static function setSettingsManager($manager)
{
self::$settingsManager = $manager;
}*/
/**
* @return \Chamilo\CourseBundle\Manager\SettingsManager
*/
public static function getCourseSettingsManager()
public static function getCourseSettingsManager(): \Chamilo\CourseBundle\Manager\SettingsManager
{
return self::$container->get('Chamilo\CourseBundle\Manager\SettingsManager');
}
@ -291,50 +280,32 @@ class Container
return self::$container->get(UserRepository::class);
}
/**
* @return CAttendanceRepository
*/
public static function getAttendanceRepository()
public static function getAttendanceRepository(): CAttendanceRepository
{
return self::$container->get(CAttendanceRepository::class);
}
/**
* @return CAnnouncementRepository
*/
public static function getAnnouncementRepository()
public static function getAnnouncementRepository(): CAnnouncementRepository
{
return self::$container->get(CAnnouncementRepository::class);
}
/**
* @return AccessUrlRepository
*/
public static function getAccessUrlRepository()
public static function getAccessUrlRepository(): AccessUrlRepository
{
return self::$container->get(AccessUrlRepository::class);
}
/**
* @return CAnnouncementAttachmentRepository
*/
public static function getAnnouncementAttachmentRepository()
public static function getAnnouncementAttachmentRepository(): CAnnouncementAttachmentRepository
{
return self::$container->get(CAnnouncementAttachmentRepository::class);
}
/**
* @return CourseRepository
*/
public static function getCourseRepository()
public static function getCourseRepository(): CourseRepository
{
return self::$container->get(CourseRepository::class);
}
/**
* @return SessionRepository
*/
public static function getSessionRepository()
public static function getSessionRepository(): SessionRepository
{
return self::$container->get(SessionRepository::class);
}

@ -414,7 +414,7 @@ class FeatureContext extends MinkContext
}
/**
* @When /^wait for the page to be loaded$/
* @When /^(?:|I )wait for the page to be loaded$/
*/
public function waitForThePageToBeLoaded()
{

@ -14,6 +14,7 @@ Feature: Session access
Then I select "TEMP_PRIVATE (TEMPPRIVATE)" from "NoSessionCoursesList[]"
And I press "add_course"
And I press "next"
And wait the page to be loaded when ready
Then I should see "Update successful"
Then I should see "Subscribe users to this session"
Then I follow "Multiple registration"
@ -37,6 +38,7 @@ Feature: Session access
Then I select "TEMP_PRIVATE (TEMPPRIVATE)" from "NoSessionCoursesList[]"
And I press "add_course"
And I press "next"
And wait the page to be loaded when ready
Then I should see "Update successful"
Then I should see "Subscribe users to this session"
Then I follow "Multiple registration"

@ -14,6 +14,7 @@ Feature: Agenda tool
And I focus "date_range"
And I fill in "date_range" with "2017-03-07 12:15 / 2017-03-07 12:15"
And I press "Add event"
And wait the page to be loaded when ready
Then I should see "Event added"
Scenario: Create an event inside course TEMP
@ -26,6 +27,7 @@ Feature: Agenda tool
And I focus "date_range"
And I fill in "date_range" with "2017-03-07 12:15 / 2017-03-07 12:15"
And I press "Add event"
And wait the page to be loaded when ready
Then I should see "Event added"

@ -11,6 +11,7 @@ Feature: Group tool
Then I should see "Default groups"
Then I follow "Delete"
Then I confirm the popup
And wait the page to be loaded when ready
Then I should see "The category has been deleted"
Scenario: Create a group directory
@ -19,6 +20,7 @@ Feature: Group tool
When I fill in the following:
| title | Group category 1 |
And I press "group_category_submit"
And wait the page to be loaded when ready
Then I should see "Category created"
Scenario: Create 4 groups
@ -39,6 +41,7 @@ Feature: Group tool
And I fill in select bootstrap static by text "#category_3" select "Group category 1"
And I fill in select bootstrap static by text "#category_4" select "Group category 1"
And I press "submit"
And wait the page to be loaded when ready
Then I should see "group(s) has (have) been added"
Scenario: Create document folder in group
@ -52,6 +55,7 @@ Feature: Group tool
Then I fill in the following:
| dirname | My folder in group |
And I press "create_dir_form_submit"
And wait the page to be loaded when ready
Then I should see "Folder created"
Scenario: Create document inside folder in group
@ -67,6 +71,7 @@ Feature: Group tool
| title | html test |
And I fill in ckeditor field "content" with "My first HTML!!"
Then I press "create_document_submit"
And wait the page to be loaded when ready
Then I should see "Item added"
Scenario: Upload a document inside folder in group

@ -2,27 +2,29 @@ Feature: Work tool
In order to use the work tool
The teachers should be able to create works
Scenario: Create a work
Given I am a platform administrator
And I am on course "TEMP" homepage
And I am on "/main/work/work.php?action=create_dir&cid=1"
When I fill in the following:
| new_dir | Work 1 |
And I fill in ckeditor field "description" with "Work description"
And I press "submit"
Then I should see "Directory created"
# Scenario: Create a work
# Given I am a platform administrator
# And I am on course "TEMP" homepage
# And I am on "/main/work/work.php?action=create_dir&cid=1"
# When I fill in the following:
# | new_dir | Work 1 |
# And I fill in ckeditor field "description" with "Work description"
# And I press "submit"
# And I wait for the page to be loaded
# Then I should see "Directory created"
Scenario: Edit a work
Given I am a platform administrator
And I am on course "TEMP" homepage
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 description"
Then I follow "Edit"
Then I should see "Assignment name"
And wait for the page to be loaded
And I press "Validate"
And I wait for the page to be loaded
Then I should see "Update successful"
Scenario: Send work as student

Loading…
Cancel
Save