From 07622451a3f43fd19ade39091755c4fed1f7eb8d Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Thu, 5 Dec 2013 13:49:18 +1100 Subject: [PATCH] MDL-42174 behat: deprecate upload file to filepicker step in favour of filemanager --- admin/tests/behat/upload_users.feature | 2 +- .../uploadcourse/tests/behat/create.feature | 4 ++-- .../uploadcourse/tests/behat/update.feature | 2 +- badges/tests/behat/add_badge.feature | 2 +- badges/tests/behat/award_badge.feature | 10 ++++----- .../tests/behat/upload_cohort_users.feature | 2 +- group/tests/behat/groups_import.feature | 6 +++--- lib/tests/behat/behat_deprecated.php | 21 +++++++++++++++++++ .../tests/behat/file_submission.feature | 4 ++-- mod/scorm/tests/behat/add_scorm.feature | 2 +- .../recent/tests/behat/add_recent.feature | 4 ++-- .../tests/behat/cancel_add_file.feature | 4 ++-- repository/tests/behat/delete_files.feature | 2 +- .../tests/behat/behat_repository_upload.php | 12 ----------- 14 files changed, 43 insertions(+), 34 deletions(-) diff --git a/admin/tests/behat/upload_users.feature b/admin/tests/behat/upload_users.feature index ae9d83beed0..16aef6dc396 100644 --- a/admin/tests/behat/upload_users.feature +++ b/admin/tests/behat/upload_users.feature @@ -19,7 +19,7 @@ Feature: Upload users And I expand "Users" node And I expand "Accounts" node And I follow "Upload users" - When I upload "lib/tests/fixtures/upload_users.csv" file to "File" filepicker + When I upload "lib/tests/fixtures/upload_users.csv" file to "File" filemanager And I press "Upload users" Then I should see "Upload users preview" And I should see "Tom" diff --git a/admin/tool/uploadcourse/tests/behat/create.feature b/admin/tool/uploadcourse/tests/behat/create.feature index ee95ca1f525..ce2c98b8dfa 100644 --- a/admin/tool/uploadcourse/tests/behat/create.feature +++ b/admin/tool/uploadcourse/tests/behat/create.feature @@ -15,7 +15,7 @@ Feature: An admin can create courses using a CSV file @javascript Scenario: Creation of unexisting courses - Given I upload "admin/tool/uploadcourse/tests/fixtures/courses.csv" file to "File" filepicker + Given I upload "admin/tool/uploadcourse/tests/fixtures/courses.csv" file to "File" filemanager And I click on "Preview" "button" When I click on "Upload courses" "button" Then I should see "The course exists and update is not allowed" @@ -29,7 +29,7 @@ Feature: An admin can create courses using a CSV file @javascript Scenario: Creation of existing courses - Given I upload "admin/tool/uploadcourse/tests/fixtures/courses.csv" file to "File" filepicker + Given I upload "admin/tool/uploadcourse/tests/fixtures/courses.csv" file to "File" filemanager And I select "Create all, increment shortname if needed" from "Upload mode" And I click on "Preview" "button" When I click on "Upload courses" "button" diff --git a/admin/tool/uploadcourse/tests/behat/update.feature b/admin/tool/uploadcourse/tests/behat/update.feature index 3a06d163c2e..457f07d2007 100644 --- a/admin/tool/uploadcourse/tests/behat/update.feature +++ b/admin/tool/uploadcourse/tests/behat/update.feature @@ -15,7 +15,7 @@ Feature: An admin can update courses using a CSV file @javascript Scenario: Updating a course fullname - Given I upload "admin/tool/uploadcourse/tests/fixtures/courses.csv" file to "File" filepicker + Given I upload "admin/tool/uploadcourse/tests/fixtures/courses.csv" file to "File" filemanager And I select "Only update existing courses" from "Upload mode" And I select "Update with CSV data only" from "Update mode" And I click on "Preview" "button" diff --git a/badges/tests/behat/add_badge.feature b/badges/tests/behat/add_badge.feature index 9d4b5faf244..64bf70431a2 100644 --- a/badges/tests/behat/add_badge.feature +++ b/badges/tests/behat/add_badge.feature @@ -36,7 +36,7 @@ Feature: Add badges to the system | Description | Test badge description | | issuername | Test Badge Site | | issuercontact | testuser@test-badge-site.com | - And I upload "badges/tests/behat/badge.png" file to "Image" filepicker + And I upload "badges/tests/behat/badge.png" file to "Image" filemanager When I press "Create badge" Then I should see "Edit details" And I should see "Test Badge" diff --git a/badges/tests/behat/award_badge.feature b/badges/tests/behat/award_badge.feature index d34d36e5201..c738acf92b8 100644 --- a/badges/tests/behat/award_badge.feature +++ b/badges/tests/behat/award_badge.feature @@ -18,7 +18,7 @@ Feature: Award badges | Description | Test badge description | | issuername | Test Badge Site | | issuercontact | testuser@test-badge-site.com | - And I upload "badges/tests/behat/badge.png" file to "Image" filepicker + And I upload "badges/tests/behat/badge.png" file to "Image" filemanager And I press "Create badge" And I select "Profile completion" from "type" And I check "First name" @@ -53,7 +53,7 @@ Feature: Award badges | Name | Site Badge | | Description | Site badge description | | issuername | Tester of site badge | - And I upload "badges/tests/behat/badge.png" file to "Image" filepicker + And I upload "badges/tests/behat/badge.png" file to "Image" filemanager And I press "Create badge" And I select "Manual issue by role" from "type" And I check "Teacher" @@ -98,7 +98,7 @@ Feature: Award badges | Name | Course Badge | | Description | Course badge description | | issuername | Tester of course badge | - And I upload "badges/tests/behat/badge.png" file to "Image" filepicker + And I upload "badges/tests/behat/badge.png" file to "Image" filemanager And I press "Create badge" And I select "Manual issue by role" from "type" And I check "Teacher" @@ -156,7 +156,7 @@ Feature: Award badges | Name | Course Badge | | Description | Course badge description | | issuername | Tester of course badge | - And I upload "badges/tests/behat/badge.png" file to "Image" filepicker + And I upload "badges/tests/behat/badge.png" file to "Image" filemanager And I press "Create badge" And I select "Activity completion" from "type" And I check "Test assignment name" @@ -219,7 +219,7 @@ Feature: Award badges | Name | Course Badge | | Description | Course badge description | | issuername | Tester of course badge | - And I upload "badges/tests/behat/badge.png" file to "Image" filepicker + And I upload "badges/tests/behat/badge.png" file to "Image" filemanager And I press "Create badge" And I select "Course completion" from "type" And I fill the moodle form with: diff --git a/cohort/tests/behat/upload_cohort_users.feature b/cohort/tests/behat/upload_cohort_users.feature index 5e6a5ad7ab8..eb0ea178c60 100644 --- a/cohort/tests/behat/upload_cohort_users.feature +++ b/cohort/tests/behat/upload_cohort_users.feature @@ -27,7 +27,7 @@ Feature: Upload users to a cohort And I expand "Users" node And I expand "Accounts" node When I follow "Upload users" - And I upload "lib/tests/fixtures/upload_users_cohorts.csv" file to "File" filepicker + And I upload "lib/tests/fixtures/upload_users_cohorts.csv" file to "File" filemanager And I press "Upload users" And I press "Upload users" And I press "Continue" diff --git a/group/tests/behat/groups_import.feature b/group/tests/behat/groups_import.feature index 57aca33119d..83322aa558d 100644 --- a/group/tests/behat/groups_import.feature +++ b/group/tests/behat/groups_import.feature @@ -22,7 +22,7 @@ Feature: Importing of groups and groupings And I expand "Users" node And I follow "Groups" And I press "Import groups" - When I upload "group/tests/fixtures/groups_import.csv" file to "Import" filepicker + When I upload "group/tests/fixtures/groups_import.csv" file to "Import" filemanager And I press "Import groups" And I press "Continue" Then I should see "group-id-1" @@ -47,7 +47,7 @@ Feature: Importing of groups and groupings And I expand "Users" node And I follow "Groups" And I press "Import groups" - When I upload "group/tests/fixtures/groups_import.csv" file to "Import" filepicker + When I upload "group/tests/fixtures/groups_import.csv" file to "Import" filemanager And I press "Import groups" Then I should see "Group group-id-1 added successfully" And I should see "Group group-id-2 added successfully" @@ -91,7 +91,7 @@ Feature: Importing of groups and groupings And I expand "Users" node And I follow "Groups" And I press "Import groups" - When I upload "group/tests/fixtures/groups_import.csv" file to "Import" filepicker + When I upload "group/tests/fixtures/groups_import.csv" file to "Import" filemanager And I press "Import groups" And I press "Continue" Then I select "group-id-1" from "groups" diff --git a/lib/tests/behat/behat_deprecated.php b/lib/tests/behat/behat_deprecated.php index 431d0536a90..b42af118049 100644 --- a/lib/tests/behat/behat_deprecated.php +++ b/lib/tests/behat/behat_deprecated.php @@ -116,6 +116,27 @@ class behat_deprecated extends behat_base { ); } + /** + * Uploads a file to the specified filemanager leaving other fields in upload form default. The paths should be relative to moodle codebase. + * + * @deprecated since 2.7 + * @todo MDL-42862 This will be deleted in Moodle 2.9 + * @see behat_repository_upload::i_upload_file_to_filemanager() + * + * @When /^I upload "(?P(?:[^"]|\\")*)" file to "(?P(?:[^"]|\\")*)" filepicker$/ + * @throws ExpectationException Thrown by behat_base::find + * @param string $filepath + * @param string $filepickerelement + */ + public function i_upload_file_to_filepicker($filepath, $filepickerelement) { + $alternative = 'I upload "' . $this->escape($filepath) . '" file to "' . + $this->escape($filepickerelement) . '" filemanager'; + $this->deprecated_message($alternative); + return array( + new Given($alternative) + ); + } + /** * Throws an exception if $CFG->behat_usedeprecated is not allowed. * diff --git a/mod/assign/tests/behat/file_submission.feature b/mod/assign/tests/behat/file_submission.feature index 7bc5380e88b..4e33ee93589 100644 --- a/mod/assign/tests/behat/file_submission.feature +++ b/mod/assign/tests/behat/file_submission.feature @@ -31,13 +31,13 @@ Feature: In an assignment, students can upload files for assessment And I follow "Course 1" And I follow "Test assignment name" When I press "Add submission" - And I upload "lib/tests/fixtures/empty.txt" file to "File submissions" filepicker + And I upload "lib/tests/fixtures/empty.txt" file to "File submissions" filemanager And I press "Save changes" Then I should see "Submitted for grading" And I should see "empty.txt" And I should see "Not graded" And I press "Edit submission" - And I upload "lib/tests/fixtures/upload_users.csv" file to "File submissions" filepicker + And I upload "lib/tests/fixtures/upload_users.csv" file to "File submissions" filemanager And ".ffilemanager .fm-maxfiles .fp-btn-add" "css_element" should exists And I press "Save changes" And I should see "Submitted for grading" diff --git a/mod/scorm/tests/behat/add_scorm.feature b/mod/scorm/tests/behat/add_scorm.feature index 8aa26a9565f..feb613df53c 100644 --- a/mod/scorm/tests/behat/add_scorm.feature +++ b/mod/scorm/tests/behat/add_scorm.feature @@ -21,7 +21,7 @@ Feature: Add scorm activity And I follow "Course 1" And I turn editing mode on And I add a "SCORM package" to section "1" - And I upload "mod/scorm/tests/packages/singlescobasic.zip" file to "Package file" filepicker + And I upload "mod/scorm/tests/packages/singlescobasic.zip" file to "Package file" filemanager And I fill the moodle form with: | Name | Awesome SCORM package | | Description | Description | diff --git a/repository/recent/tests/behat/add_recent.feature b/repository/recent/tests/behat/add_recent.feature index 4168b0dd358..0e245d03d3e 100644 --- a/repository/recent/tests/behat/add_recent.feature +++ b/repository/recent/tests/behat/add_recent.feature @@ -12,8 +12,8 @@ Feature: Recent files repository lists the recently used files And I log in as "admin" And I expand "My profile" node And I follow "My private files" - And I upload "lib/tests/fixtures/empty.txt" file to "Files" filepicker - And I upload "lib/tests/fixtures/upload_users.csv" file to "Files" filepicker + And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager + And I upload "lib/tests/fixtures/upload_users.csv" file to "Files" filemanager And I press "Save changes" And I am on homepage And I follow "Course 1" diff --git a/repository/tests/behat/cancel_add_file.feature b/repository/tests/behat/cancel_add_file.feature index 32d05c76852..eae9f54559b 100644 --- a/repository/tests/behat/cancel_add_file.feature +++ b/repository/tests/behat/cancel_add_file.feature @@ -12,7 +12,7 @@ Feature: A selected file can be cancelled And I log in as "admin" And I expand "My profile" node And I follow "My private files" - And I upload "lib/tests/fixtures/empty.txt" file to "Files" filepicker + And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager And I press "Save changes" And I am on homepage And I follow "Course 1" @@ -21,7 +21,7 @@ Feature: A selected file can be cancelled And I fill the moodle form with: | Name | Folder name | | Description | Folder description | - And I upload "lib/tests/fixtures/upload_users.csv" file to "Files" filepicker + And I upload "lib/tests/fixtures/upload_users.csv" file to "Files" filemanager And I click on "#fitem_id_files .fp-btn-add a" "css_element" And I click on "Recent files" "link" in the ".fp-repo-area" "css_element" And I click on "//a[contains(concat(' ', normalize-space(@class), ' '), ' fp-file ')][normalize-space(.)='empty.txt']" "xpath_element" diff --git a/repository/tests/behat/delete_files.feature b/repository/tests/behat/delete_files.feature index c6bb5ff5be6..ab170a66928 100644 --- a/repository/tests/behat/delete_files.feature +++ b/repository/tests/behat/delete_files.feature @@ -9,7 +9,7 @@ Feature: Delete files and folders from the file manager Given I log in as "admin" And I expand "My profile" node And I follow "My private files" - And I upload "lib/tests/fixtures/empty.txt" file to "Files" filepicker + And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager And I create "Delete me" folder in "Files" filepicker And I press "Save changes" When I delete "empty.txt" from "Files" filepicker diff --git a/repository/upload/tests/behat/behat_repository_upload.php b/repository/upload/tests/behat/behat_repository_upload.php index fd4cf501f5e..9fa490e287e 100644 --- a/repository/upload/tests/behat/behat_repository_upload.php +++ b/repository/upload/tests/behat/behat_repository_upload.php @@ -42,18 +42,6 @@ use Behat\Mink\Exception\ExpectationException as ExpectationException, */ class behat_repository_upload extends behat_files { - /** - * Uploads a file to the specified filemanager leaving other fields in upload form default. The paths should be relative to moodle codebase. - * - * @When /^I upload "(?P(?:[^"]|\\")*)" file to "(?P(?:[^"]|\\")*)" filepicker$/ - * @throws ExpectationException Thrown by behat_base::find - * @param string $filepath - * @param string $filepickerelement - */ - public function i_upload_file_to_filepicker($filepath, $filepickerelement) { - $this->upload_file_to_filemanager($filepath, $filepickerelement, new TableNode(), false); - } - /** * Uploads a file to the specified filemanager leaving other fields in upload form default. The paths should be relative to moodle codebase. *