Commit cde67a83 authored by Marina Glancy's avatar Marina Glancy
Browse files

MDL-42174 behat: change word filepicker to filemanager in step definitions

parent 07622451
......@@ -49,9 +49,9 @@ use Behat\Mink\Exception\ExpectationException as ExpectationException,
class behat_files extends behat_base {
/**
* Gets the filepicker NodeElement.
* Gets the NodeElement for filepicker of filemanager moodleform element.
*
* The filepicker field label is pointing to a hidden input which is
* The filepicker/filemanager element label is pointing to a hidden input which is
* not recognized as a named selector, as it is hidden...
*
* @throws ExpectationException Thrown by behat_base::find
......@@ -77,7 +77,7 @@ class behat_files extends behat_base {
}
/**
* Performs $action on a filepicker container element (file or folder).
* Performs $action on a filemanager container element (file or folder).
*
* It works together with open_element_contextual_menu
* as this method needs the contextual menu to be opened.
......@@ -99,22 +99,22 @@ class behat_files extends behat_base {
/**
* Opens the contextual menu of a folder or a file.
*
* Works both in filepicker elements and when dealing with repository
* elements inside modal windows.
* Works both in filemanager elements and when dealing with repository
* elements inside filepicker modal window.
*
* @throws ExpectationException Thrown by behat_base::find
* @param string $name The name of the folder/file
* @param string $filepickerelement The filepicker form element locator, the repository items are in filepicker modal window if false
* @param string $filemanagerelement The filemanager form element locator, the repository items are in filepicker modal window if false
* @return void
*/
protected function open_element_contextual_menu($name, $filepickerelement = false) {
protected function open_element_contextual_menu($name, $filemanagerelement = false) {
// If a filepicker is specified we restrict the search to the filepicker descendants.
// If a filemanager is specified we restrict the search to the descendants of this particular filemanager form element.
$containernode = false;
$exceptionmsg = '"'.$name.'" element can not be found';
if ($filepickerelement) {
$containernode = $this->get_filepicker_node($filepickerelement);
$exceptionmsg = 'The "'.$filepickerelement.'" filepicker ' . $exceptionmsg;
if ($filemanagerelement) {
$containernode = $this->get_filepicker_node($filemanagerelement);
$exceptionmsg = 'The "'.$filemanagerelement.'" filemanager ' . $exceptionmsg;
$locatorprefix = "//div[@class='fp-content']";
} else {
$locatorprefix = "//div[contains(concat(' ', normalize-space(@class), ' '), ' fp-repo-items ')]//descendant::div[@class='fp-content']";
......@@ -125,7 +125,7 @@ class behat_files extends behat_base {
// Avoid quote-related problems.
$name = $this->getSession()->getSelectorsHandler()->xpathLiteral($name);
// Get a filepicker element (folder or file).
// Get a filepicker/filemanager element (folder or file).
try {
// First we look at the folder as we need to click on the contextual menu otherwise it would be opened.
......@@ -159,25 +159,25 @@ class behat_files extends behat_base {
}
/**
* Opens the 'add file' modal window and selects the repository.
* Opens the filepicker modal window and selects the repository.
*
* @throws ExpectationException Thrown by behat_base::find
* @param NodeElement $filepickernode The filepicker DOM node.
* @param NodeElement $filemanagernode The filemanager or filepicker form element DOM node.
* @param mixed $repositoryname The repo name.
* @return void
*/
protected function open_add_file_window($filepickernode, $repositoryname) {
protected function open_add_file_window($filemanagernode, $repositoryname) {
$exception = new ExpectationException('No files can be added to the specified filepicker', $this->getSession());
$exception = new ExpectationException('No files can be added to the specified filemanager', $this->getSession());
// We should deal with single-file and multiple-file filepickers,
// We should deal with single-file and multiple-file filemanagers,
// catching the exception thrown by behat_base::find() in case is not multiple
try {
// Looking for the add button inside the specified filepicker.
$add = $this->find('css', 'div.fp-btn-add a', $exception, $filepickernode);
// Looking for the add button inside the specified filemanager.
$add = $this->find('css', 'div.fp-btn-add a', $exception, $filemanagernode);
} catch (Exception $e) {
// Otherwise should be a single-file filepicker.
$add = $this->find('css', 'input.fp-btn-choose', $exception, $filepickernode);
// Otherwise should be a single-file filepicker form element.
$add = $this->find('css', 'input.fp-btn-choose', $exception, $filemanagernode);
}
$add->click();
......@@ -187,7 +187,7 @@ class behat_files extends behat_base {
// Avoid problems with both double and single quotes in the same string.
$repositoryname = $this->getSession()->getSelectorsHandler()->xpathLiteral($repositoryname);
// Here we don't need to look inside the selected filepicker because there can only be one modal window.
// Here we don't need to look inside the selected element because there can only be one modal window.
$repositorylink = $this->find(
'xpath',
"//div[contains(concat(' ', normalize-space(@class), ' '), ' fp-repo-area ')]" .
......
......@@ -137,6 +137,101 @@ class behat_deprecated extends behat_base {
);
}
/**
* Creates a folder with specified name in the current folder and in the specified filepicker field.
*
* @deprecated since 2.7
* @todo MDL-42862 This will be deleted in Moodle 2.9
* @see behat_filepicker::i_create_folder_in_filemanager()
*
* @Given /^I create "(?P<foldername_string>(?:[^"]|\\")*)" folder in "(?P<filepicker_field_string>(?:[^"]|\\")*)" filepicker$/
* @throws ExpectationException Thrown by behat_base::find
* @param string $foldername
* @param string $filepickerelement
*/
public function i_create_folder_in_filepicker($foldername, $filepickerelement) {
$alternative = 'I create "' . $this->escape($foldername) .
'" folder in "' . $this->escape($filepickerelement) . '" filemanager';
$this->deprecated_message($alternative);
return array(new Given($alternative));
}
/**
* Opens the contents of a filepicker folder. It looks for the folder in the current folder and in the path bar.
*
* @deprecated since 2.7
* @todo MDL-42862 This will be deleted in Moodle 2.9
* @see behat_filepicker::i_open_folder_from_filemanager()
*
* @Given /^I open "(?P<foldername_string>(?:[^"]|\\")*)" folder from "(?P<filepicker_field_string>(?:[^"]|\\")*)" filepicker$/
* @throws ExpectationException Thrown by behat_base::find
* @param string $foldername
* @param string $filepickerelement
*/
public function i_open_folder_from_filepicker($foldername, $filepickerelement) {
$alternative = 'I open "' . $this->escape($foldername) . '" folder from "' .
$this->escape($filepickerelement) . '" filemanager';
$this->deprecated_message($alternative);
return array(new Given($alternative));
}
/**
* Unzips the specified file from the specified filepicker field. The zip file has to be visible in the current folder.
*
* @deprecated since 2.7
* @todo MDL-42862 This will be deleted in Moodle 2.9
* @see behat_filepicker::i_unzip_file_from_filemanager()
*
* @Given /^I unzip "(?P<filename_string>(?:[^"]|\\")*)" file from "(?P<filepicker_field_string>(?:[^"]|\\")*)" filepicker$/
* @throws ExpectationException Thrown by behat_base::find
* @param string $filename
* @param string $filepickerelement
*/
public function i_unzip_file_from_filepicker($filename, $filepickerelement) {
$alternative = 'I unzip "' . $this->escape($filename) . '" file from "' .
$this->escape($filepickerelement) . '" filemanager';
$this->deprecated_message($alternative);
return array(new Given($alternative));
}
/**
* Zips the specified folder from the specified filepicker field. The folder has to be in the current folder.
*
* @deprecated since 2.7
* @todo MDL-42862 This will be deleted in Moodle 2.9
* @see behat_filepicker::i_zip_folder_from_filemanager()
*
* @Given /^I zip "(?P<filename_string>(?:[^"]|\\")*)" folder from "(?P<filepicker_field_string>(?:[^"]|\\")*)" filepicker$/
* @throws ExpectationException Thrown by behat_base::find
* @param string $foldername
* @param string $filepickerelement
*/
public function i_zip_folder_from_filepicker($foldername, $filepickerelement) {
$alternative = 'I zip "' . $this->escape($foldername) . '" folder from "' .
$this->escape($filepickerelement) . '" filemanager';
$this->deprecated_message($alternative);
return array(new Given($alternative));
}
/**
* Deletes the specified file or folder from the specified filepicker field.
*
* @deprecated since 2.7
* @todo MDL-42862 This will be deleted in Moodle 2.9
* @see behat_filepicker::i_delete_file_from_filemanager()
*
* @Given /^I delete "(?P<file_or_folder_name_string>(?:[^"]|\\")*)" from "(?P<filepicker_field_string>(?:[^"]|\\")*)" filepicker$/
* @throws ExpectationException Thrown by behat_base::find
* @param string $name
* @param string $filepickerelement
*/
public function i_delete_file_from_filepicker($name, $filepickerelement) {
$alternative = 'I delete "' . $this->escape($name) . '" from "' .
$this->escape($filepickerelement) . '" filemanager';
$this->deprecated_message($alternative);
return array(new Given($alternative));
}
/**
* Throws an exception if $CFG->behat_usedeprecated is not allowed.
*
......
......@@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Files and filepicker manipulation steps definitions.
* Filemanager and filepicker manipulation steps definitions.
*
* @package core
* @category test
......@@ -31,7 +31,7 @@ use Behat\Mink\Exception\ExpectationException as ExpectationException,
Behat\Gherkin\Node\TableNode as TableNode;
/**
* Steps definitions to deal with the filepicker.
* Steps definitions to deal with the filemanager and filepicker.
*
* Extends behat_files rather than behat_base as is file-related.
*
......@@ -43,19 +43,19 @@ use Behat\Mink\Exception\ExpectationException as ExpectationException,
class behat_filepicker extends behat_files {
/**
* Creates a folder with specified name in the current folder and in the specified filepicker field.
* Creates a folder with specified name in the current folder and in the specified filemanager field.
*
* @Given /^I create "(?P<foldername_string>(?:[^"]|\\")*)" folder in "(?P<filepicker_field_string>(?:[^"]|\\")*)" filepicker$/
* @Given /^I create "(?P<foldername_string>(?:[^"]|\\")*)" folder in "(?P<filemanager_field_string>(?:[^"]|\\")*)" filemanager$/
* @throws ExpectationException Thrown by behat_base::find
* @param string $foldername
* @param string $filepickerelement
* @param string $filemanagerelement
*/
public function i_create_folder_in_filepicker($foldername, $filepickerelement) {
public function i_create_folder_in_filemanager($foldername, $filemanagerelement) {
$fieldnode = $this->get_filepicker_node($filepickerelement);
$fieldnode = $this->get_filepicker_node($filemanagerelement);
// Looking for the create folder button inside the specified filepicker.
$exception = new ExpectationException('No folders can be created in "'.$filepickerelement.'" filepicker', $this->getSession());
// Looking for the create folder button inside the specified filemanager.
$exception = new ExpectationException('No folders can be created in "'.$filemanagerelement.'" filemanager', $this->getSession());
$newfolder = $this->find('css', 'div.fp-btn-mkdir a', $exception, $fieldnode);
$newfolder->click();
......@@ -77,19 +77,19 @@ class behat_filepicker extends behat_files {
}
/**
* Opens the contents of a filepicker folder. It looks for the folder in the current folder and in the path bar.
* Opens the contents of a filemanager folder. It looks for the folder in the current folder and in the path bar.
*
* @Given /^I open "(?P<foldername_string>(?:[^"]|\\")*)" folder from "(?P<filepicker_field_string>(?:[^"]|\\")*)" filepicker$/
* @Given /^I open "(?P<foldername_string>(?:[^"]|\\")*)" folder from "(?P<filemanager_field_string>(?:[^"]|\\")*)" filemanager$/
* @throws ExpectationException Thrown by behat_base::find
* @param string $foldername
* @param string $filepickerelement
* @param string $filemanagerelement
*/
public function i_open_folder_from_filepicker($foldername, $filepickerelement) {
public function i_open_folder_from_filemanager($foldername, $filemanagerelement) {
$fieldnode = $this->get_filepicker_node($filepickerelement);
$fieldnode = $this->get_filepicker_node($filemanagerelement);
$exception = new ExpectationException(
'The "'.$foldername.'" folder can not be found in the "'.$filepickerelement.'" filepicker',
'The "'.$foldername.'" folder can not be found in the "'.$filemanagerelement.'" filemanager',
$this->getSession()
);
......@@ -130,17 +130,17 @@ class behat_filepicker extends behat_files {
}
/**
* Unzips the specified file from the specified filepicker field. The zip file has to be visible in the current folder.
* Unzips the specified file from the specified filemanager field. The zip file has to be visible in the current folder.
*
* @Given /^I unzip "(?P<filename_string>(?:[^"]|\\")*)" file from "(?P<filepicker_field_string>(?:[^"]|\\")*)" filepicker$/
* @Given /^I unzip "(?P<filename_string>(?:[^"]|\\")*)" file from "(?P<filemanager_field_string>(?:[^"]|\\")*)" filemanager$/
* @throws ExpectationException Thrown by behat_base::find
* @param string $filename
* @param string $filepickerelement
* @param string $filemanagerelement
*/
public function i_unzip_file_from_filepicker($filename, $filepickerelement) {
public function i_unzip_file_from_filemanager($filename, $filemanagerelement) {
// Open the contextual menu of the filepicker element.
$this->open_element_contextual_menu($filename, $filepickerelement);
// Open the contextual menu of the filemanager element.
$this->open_element_contextual_menu($filename, $filemanagerelement);
// Execute the action.
$exception = new ExpectationException($filename.' element can not be unzipped', $this->getSession());
......@@ -150,22 +150,22 @@ class behat_filepicker extends behat_files {
$this->wait_until_return_to_form();
// Wait until the current folder contents are updated
$containernode = $this->get_filepicker_node($filepickerelement);
$containernode = $this->get_filepicker_node($filemanagerelement);
$this->wait_until_contents_are_updated($containernode);
}
/**
* Zips the specified folder from the specified filepicker field. The folder has to be in the current folder.
* Zips the specified folder from the specified filemanager field. The folder has to be in the current folder.
*
* @Given /^I zip "(?P<filename_string>(?:[^"]|\\")*)" folder from "(?P<filepicker_field_string>(?:[^"]|\\")*)" filepicker$/
* @Given /^I zip "(?P<filename_string>(?:[^"]|\\")*)" folder from "(?P<filemanager_field_string>(?:[^"]|\\")*)" filemanager$/
* @throws ExpectationException Thrown by behat_base::find
* @param string $foldername
* @param string $filepickerelement
* @param string $filemanagerelement
*/
public function i_zip_folder_from_filepicker($foldername, $filepickerelement) {
public function i_zip_folder_from_filemanager($foldername, $filemanagerelement) {
// Open the contextual menu of the filepicker element.
$this->open_element_contextual_menu($foldername, $filepickerelement);
// Open the contextual menu of the filemanager element.
$this->open_element_contextual_menu($foldername, $filemanagerelement);
// Execute the action.
$exception = new ExpectationException($foldername.' element can not be zipped', $this->getSession());
......@@ -175,22 +175,22 @@ class behat_filepicker extends behat_files {
$this->wait_until_return_to_form();
// Wait until the current folder contents are updated
$containernode = $this->get_filepicker_node($filepickerelement);
$containernode = $this->get_filepicker_node($filemanagerelement);
$this->wait_until_contents_are_updated($containernode);
}
/**
* Deletes the specified file or folder from the specified filepicker field.
* Deletes the specified file or folder from the specified filemanager field.
*
* @Given /^I delete "(?P<file_or_folder_name_string>(?:[^"]|\\")*)" from "(?P<filepicker_field_string>(?:[^"]|\\")*)" filepicker$/
* @Given /^I delete "(?P<file_or_folder_name_string>(?:[^"]|\\")*)" from "(?P<filemanager_field_string>(?:[^"]|\\")*)" filemanager$/
* @throws ExpectationException Thrown by behat_base::find
* @param string $foldername
* @param string $filepickerelement
* @param string $name
* @param string $filemanagerelement
*/
public function i_delete_file_from_filepicker($name, $filepickerelement) {
public function i_delete_file_from_filemanager($name, $filemanagerelement) {
// Open the contextual menu of the filepicker element.
$this->open_element_contextual_menu($name, $filepickerelement);
// Open the contextual menu of the filemanager element.
$this->open_element_contextual_menu($name, $filemanagerelement);
// Execute the action.
$exception = new ExpectationException($name.' element can not be deleted', $this->getSession());
......@@ -205,7 +205,7 @@ class behat_filepicker extends behat_files {
$this->wait_until_return_to_form();
// Wait until file manager contents are updated.
$containernode = $this->get_filepicker_node($filepickerelement);
$containernode = $this->get_filepicker_node($filemanagerelement);
$this->wait_until_contents_are_updated($containernode);
}
......
......@@ -16,11 +16,11 @@ Feature: Create folders in the file manager
And I fill the moodle form with:
| Name | Folder resource |
| Description | The description |
And I create "Folder 1" folder in "Files" filepicker
And I open "Folder 1" folder from "Files" filepicker
And I create "SubFolder 1" folder in "Files" filepicker
When I open "Files" folder from "Files" filepicker
And I create "Folder 1" folder in "Files" filemanager
And I open "Folder 1" folder from "Files" filemanager
And I create "SubFolder 1" folder in "Files" filemanager
When I open "Files" folder from "Files" filemanager
Then I should see "Folder 1"
And I open "Folder 1" folder from "Files" filepicker
And I open "Folder 1" folder from "Files" filemanager
And I should see "SubFolder 1"
And I press "Save and return to course"
......@@ -10,12 +10,12 @@ Feature: Delete files and folders from the file manager
And I expand "My profile" node
And I follow "My private files"
And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager
And I create "Delete me" folder in "Files" filepicker
And I create "Delete me" folder in "Files" filemanager
And I press "Save changes"
When I delete "empty.txt" from "Files" filepicker
When I delete "empty.txt" from "Files" filemanager
And I press "Save changes"
Then I should not see "empty.txt"
And I delete "Delete me" from "Files" filepicker
And I delete "Delete me" from "Files" filemanager
And I press "Save changes"
And I should not see "Delete me"
And I press "Cancel"
......@@ -16,15 +16,15 @@ Feature: Zip folders and unzip compressed files
And I fill the moodle form with:
| Name | Folder resource |
| Description | The description |
And I create "Folder 1" folder in "Files" filepicker
And I open "Folder 1" folder from "Files" filepicker
And I create "SubFolder 1" folder in "Files" filepicker
And I open "Files" folder from "Files" filepicker
And I zip "Folder 1" folder from "Files" filepicker
And I delete "Folder 1" from "Files" filepicker
When I unzip "Folder 1.zip" file from "Files" filepicker
And I delete "Folder 1.zip" from "Files" filepicker
And I create "Folder 1" folder in "Files" filemanager
And I open "Folder 1" folder from "Files" filemanager
And I create "SubFolder 1" folder in "Files" filemanager
And I open "Files" folder from "Files" filemanager
And I zip "Folder 1" folder from "Files" filemanager
And I delete "Folder 1" from "Files" filemanager
When I unzip "Folder 1.zip" file from "Files" filemanager
And I delete "Folder 1.zip" from "Files" filemanager
Then I should see "Folder 1"
And I open "Folder 1" folder from "Files" filepicker
And I open "Folder 1" folder from "Files" filemanager
And I should see "SubFolder 1"
And I press "Save and return to course"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment