Merge branch 'MDL-59698-master' of git://github.com/damyon/moodle

This commit is contained in:
Andrew Nicols 2017-08-07 12:43:42 +08:00
commit a41ef5ece5
4 changed files with 0 additions and 216 deletions

View File

@ -1,48 +0,0 @@
@core_form
Feature: There is a form element allowing to select filetypes
In order to test the filetypes field
As an admin
I need a test form that makes use of the filetypes field
Background:
Given the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| label | L1 | <a href="../lib/form/tests/fixtures/filetypes.php">FixtureLink</a> | C1 | label1 |
And I log in as "admin"
And I am on "Course 1" course homepage
And I follow "FixtureLink"
Scenario: File types can be provided via direct input with JavaScript disabled
Given I set the field "Choose from all file types" to ".png .gif .jpg"
When I press "Save changes"
Then the field "Choose from all file types" matches value ".png .gif .jpg"
@javascript
Scenario: File types can be provided via direct input with JavaScript enabled
Given I set the field "Choose from all file types" to ".png .gif .jpg"
When I press "Save changes"
Then the field "Choose from all file types" matches value ".png .gif .jpg"
Scenario: File types are validated to be known, unless the field allows unknown be provided
Given I set the field "Choose from all file types" to ".pdf .doesnoexist"
And I set the field "Choose from a limited set" to "doc docx pdf rtf"
And I set the field "Unknown file types are allowed here" to ".neverminditdoesnotexist"
When I press "Save changes"
Then I should see "Unknown file types: .doesnoexist"
And I should see "These file types are not allowed here: .doc, .docx, .rtf"
And I should see "It is not allowed to select 'All file types' here"
And I should not see "Unknown file types: .neverminditdoesnotexist"
@javascript @_file_upload
Scenario: File manager element implicitly validates submitted files
# We can't directly upload the invalid file here as the upload repository would throw an exception.
# So instead we try to trick the filemanager, to be finally stopped by the implicit validation.
And I upload "lib/tests/fixtures/empty.txt" file to "Picky file manager" filemanager
And I follow "empty.txt"
And I set the field "Name" to "renamed.exe"
And I press "Update"
When I press "Save changes"
Then I should see "Some files (renamed.exe) cannot be uploaded. Only file types .txt are allowed."

View File

@ -1,24 +0,0 @@
@core_form @javascript @_bug_phantomjs
Feature: Forms with a multi select field dependency
In order to test multi select field dependency
As an admin
I need forms field which depends on multiple select options
Scenario: Field should be enabled only when all select options are selected
# Get to the fixture page.
Given the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| label | L1 | <a href="../lib/form/tests/fixtures/multi_select_dependencies.php">FixtureLink</a> | C1 | label1 |
And I log in as "admin"
And I am on "Course 1" course homepage
When I follow "FixtureLink"
Then the "Enter your name" "field" should be disabled
And I set the field "Choose one or more directions" to "South,West"
Then the "Enter your name" "field" should be enabled
And I set the field "Choose one or more directions" to "West"
Then the "Enter your name" "field" should be disabled
And I set the field "Choose one or more directions" to "North,West"
Then the "Enter your name" "field" should be disabled

View File

@ -1,76 +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/>.
/**
* Fixture script for Behat test for testing the filetypes element.
*
* @package core_form
* @category test
* @copyright 2017 David Mudrák <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// No login check is expected here as this is for Behat tests only.
// @codingStandardsIgnoreLine
require(__DIR__.'/../../../../config.php');
require_once($CFG->libdir.'/formslib.php');
// Behat test fixture only.
defined('BEHAT_SITE_RUNNING') || die('Only available on Behat test server');
/**
* Defines a test form to be used in automatic tests.
*
* @copyright 2017 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class test_form extends moodleform {
/**
* Defines the form fields.
*/
public function definition() {
$mform = $this->_form;
$mform->addElement('filetypes', 'filetypes0', 'Choose from all file types');
$mform->setDefault('filetypes0', '.pdf');
$mform->addElement('filetypes', 'filetypes1', 'Choose from a limited set',
['onlytypes' => array('.pdf', 'web_image', 'image')]);
$mform->addElement('filetypes', 'filetypes2', 'Choose without "all"',
['allowall' => false]);
$mform->addElement('filetypes', 'filetypes3', 'Unknown file types are allowed here',
['allowunknown' => true]);
$mform->addElement('filemanager', 'fileman1', 'Picky file manager', null, ['accepted_types' => '.txt']);
$this->add_action_buttons(false);
}
}
$PAGE->set_context(context_system::instance());
$PAGE->set_url('/lib/form/tests/fixtures/filetypes.php');
$PAGE->set_title('Filetypes element test page');
$form = new test_form($PAGE->url);
$formdata = $form->get_data();
echo $OUTPUT->header();
echo $OUTPUT->heading($PAGE->title);
$form->display();
echo $OUTPUT->footer();

View File

@ -1,68 +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/>.
/**
* Fixture for Behat test for testing multiple select dependencies.
*
* @package core_form
* @copyright 2016 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require(__DIR__ . '/../../../../config.php');
require_once($CFG->libdir . '/formslib.php');
// Behat test fixture only.
defined('BEHAT_SITE_RUNNING') || die('Only available on Behat test server');
/**
* Form for testing multiple select dependencies.
*
* @package core_form
* @copyright 2016 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class test_form extends moodleform {
/**
* Form definition.
*/
public function definition() {
$mform = $this->_form;
$labels = array('North', 'Est', 'South', 'West');
$select = $mform->addElement('select', 'mselect_name', 'Choose one or more directions', $labels);
$select->setMultiple(true);
$mform->addElement('text', 'text_name', 'Enter your name');
$mform->setType('text_name', PARAM_RAW);
$mform->disabledIf('text_name', 'mselect_name[]', 'neq', array(2, 3));
$this->add_action_buttons($cancel = true, $submitlabel = null);
}
}
$PAGE->set_context(context_system::instance());
$PAGE->set_url('/lib/form/tests/fixtures/multi_select_dependencies.php');
$PAGE->set_title('multi_select_dependencies');
$mform = new test_form(new moodle_url('/lib/form/tests/fixtures/multi_select_dependencies.php'));
echo $OUTPUT->header();
$mform->display();
echo $OUTPUT->footer();