MDL-38814 behat: Deleting old files
authorDavid Monllao <davidm@moodle.com>
Mon, 1 Apr 2013 04:21:05 +0000 (12:21 +0800)
committerDavid Monllao <davidm@moodle.com>
Mon, 1 Apr 2013 04:22:43 +0000 (12:22 +0800)
admin/tool/behat/tests/behat/manipulate_filepicker.feature [deleted file]
lib/tests/behat/behat_filepicker.php [deleted file]

diff --git a/admin/tool/behat/tests/behat/manipulate_filepicker.feature b/admin/tool/behat/tests/behat/manipulate_filepicker.feature
deleted file mode 100644 (file)
index b5b3d94..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-@tool_behat @core_form @filepicker
-Feature: Manipulate filepicker
-  In order to provide external resources
-  As a moodle user
-  I need to upload files to moodle
-
-  Background:
-    Given the following "courses" exists:
-      | fullname | shortname | category |
-      | Course 1 | C1 | 0 |
-    And I log in as "admin"
-    And I follow "Course 1"
-    And I turn editing mode on
-    And I add a "Folder" to section "0"
-    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
-
-  @javascript
-  Scenario: Create folders and subfolders
-    When I open "Files" folder from "Files" filepicker
-    Then I should see "Folder 1"
-    And I open "Folder 1" folder from "Files" filepicker
-    And I should see "SubFolder 1"
-    And I press "Save and return to course"
-
-  @javascript
-  Scenario: Zip and unzip folders and files
-    Given 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
-    Then I should see "Folder 1"
-    And I open "Folder 1" folder from "Files" filepicker
-    And I should see "SubFolder 1"
-    And I press "Save and return to course"
diff --git a/lib/tests/behat/behat_filepicker.php b/lib/tests/behat/behat_filepicker.php
deleted file mode 100644 (file)
index 68a79b1..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Files and filepicker manipulation steps definitions.
- *
- * @package    core
- * @category   test
- * @copyright  2013 David Monllaó
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
-
-require_once(__DIR__ . '/../../behat/behat_files.php');
-
-use Behat\Mink\Exception\ExpectationException as ExpectationException;
-
-/**
- * Steps definitions to deal with the filepicker.
- *
- * Extends behat_files rather than behat_base as is file-related.
- *
- * @package    core
- * @category   test
- * @copyright  2013 David Monllaó
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class behat_filepicker extends behat_files {
-
-    /**
-     * Creates a folder with specified name in the current folder and in the specified filepicker field.
-     *
-     * @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) {
-
-        $fieldnode = $this->get_filepicker_node($filepickerelement);
-
-        // Looking for the create folder button inside the specified filepicker.
-        $exception = new ExpectationException('No folders can be created in "'.$filepickerelement.'" filepicker', $this->getSession());
-        $newfolder = $this->find('css', 'div.fp-btn-mkdir a', $exception, $fieldnode);
-        $newfolder->click();
-
-        // Setting the folder name in the modal window.
-        $exception = new ExpectationException('The dialog to enter the folder name does not appear', $this->getSession());
-        $dialoginput = $this->find('css', '.fp-mkdir-dlg-text input');
-        $dialoginput->setValue($foldername);
-
-        $this->getSession()->getPage()->pressButton('Create folder');
-
-        // Wait few seconds for the folder to be created and filepicker contents reloaded.
-        $this->getSession()->wait(4 * 1000, false);
-    }
-
-    /**
-     * Opens the contents of a filepicker 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$/
-     * @throws ExpectationException Thrown by behat_base::find
-     * @param string $foldername
-     * @param string $filepickerelement
-     */
-    public function i_open_folder_from_filepicker($foldername, $filepickerelement) {
-
-        $fieldnode = $this->get_filepicker_node($filepickerelement);
-
-        $exception = new ExpectationException(
-            'The "'.$foldername.'" folder can not be found in the "'.$filepickerelement.'" filepicker',
-            $this->getSession()
-        );
-
-        // We look both in the pathbar and in the contents.
-        try {
-
-            // In the current folder workspace.
-            $folder = $this->find(
-                'xpath',
-                "//div[contains(concat(' ', normalize-space(@class), ' '), ' fp-folder ')]
-//descendant::div[contains(concat(' ', normalize-space(.), ' '), '" . $foldername . "')]",
-                $exception,
-                $fieldnode
-            );
-        } catch (ExpectationException $e) {
-
-            // And in the pathbar.
-            $folder = $this->find(
-                'xpath',
-                "//a[contains(concat(' ', normalize-space(@class), ' '), ' fp-path-folder-name ')]
-[contains(concat(' ', normalize-space(.), ' '), '" . $foldername . "')]",
-                $exception,
-                $fieldnode
-            );
-        }
-
-        // It should be a NodeElement, otherwise an exception would have been thrown.
-        $folder->click();
-
-        // Wait few seconds for the filepicker contents to be updated.
-        $this->getSession()->wait(4 * 1000, false);
-    }
-
-    /**
-     * Unzips the specified file from the specified filepicker 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$/
-     * @throws ExpectationException Thrown by behat_base::find
-     * @param string $filename
-     * @param string $filepickerelement
-     */
-    public function i_unzip_file_from_filepicker($filename, $filepickerelement) {
-
-        // Open the contextual menu of the filepicker element.
-        $this->open_element_contextual_menu($filename, $filepickerelement);
-
-        // Execute the action.
-        $exception = new ExpectationException($filename.' element can not be unzipped', $this->getSession());
-        $this->perform_on_element('unzip', $exception);
-
-        // Wait few seconds.
-        // Here the time will depend on the zip contents and the server load, so it better to be conservative.
-        $this->getSession()->wait(8 * 1000, false);
-    }
-
-    /**
-     * Zips the specified folder from the specified filepicker field. The folder has to be in the current folder.
-     *
-     * @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) {
-
-        // Open the contextual menu of the filepicker element.
-        $this->open_element_contextual_menu($foldername, $filepickerelement);
-
-        // Execute the action.
-        $exception = new ExpectationException($foldername.' element can not be zipped', $this->getSession());
-        $this->perform_on_element('zip', $exception);
-
-        // Wait few seconds.
-        // Here the time will depend on the folder contents and the server load, so it better to be conservative.
-        $this->getSession()->wait(8 * 1000, false);
-    }
-
-    /**
-     * Deletes the specified file or folder from the specified filepicker field.
-     *
-     * @Given /^I delete "(?P<file_or_folder_name_string>(?:[^"]|\\")*)" from "(?P<filepicker_field_string>(?:[^"]|\\")*)" filepicker$/
-     * @throws ExpectationException Thrown by behat_base::find
-     * @param string $foldername
-     * @param string $filepickerelement
-     */
-    public function i_delete_file_from_filepicker($name, $filepickerelement) {
-
-        // Open the contextual menu of the filepicker element.
-        $this->open_element_contextual_menu($name, $filepickerelement);
-
-        // Execute the action.
-        $exception = new ExpectationException($name.' element can not be deleted', $this->getSession());
-        $this->perform_on_element('delete', $exception);
-
-        // Yes, we are sure.
-        // Using xpath + click instead of pressButton as 'Ok' it is a common string.
-        $okbutton = $this->find('css', 'div.fp-dlg button.fp-dlg-butconfirm');
-        $okbutton->click();
-
-        // Wait few seconds until filepicker contents are reloaded.
-        $this->getSession()->wait(4 * 1000, false);
-    }
-
-}