From 6e9f189cdba529e41c345abfd26ffecaede65c4b Mon Sep 17 00:00:00 2001 From: Jean-Michel Vedrine Date: Tue, 2 Jan 2018 20:06:16 +0100 Subject: First behat tests --- .travis.yml | 34 +++++++++++++++++++--------------- lang/en/qtype_algebra.php | 2 +- tests/behat/add.feature | 36 ++++++++++++++++++++++++++++++++++++ tests/behat/import.feature | 30 ++++++++++++++++++++++++++++++ xmlrpc-utils.php | 2 +- 5 files changed, 87 insertions(+), 17 deletions(-) create mode 100644 tests/behat/add.feature create mode 100644 tests/behat/import.feature diff --git a/.travis.yml b/.travis.yml index 8c7fc69..39c517b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,41 +1,45 @@ language: php -sudo: false +sudo: required + +addons: + firefox: "47.0.1" + postgresql: "9.3" + apt: + packages: + - oracle-java8-installer + - oracle-java8-set-default cache: directories: - $HOME/.composer/cache + - $HOME/.npm -php: -# - 5.6 +php: - 7.0 - 7.1 -addons: - firefox: "47.0.1" - postgresql: "9.3" - env: - MOODLE_BRANCH=MOODLE_32_STABLE DB=pgsql IGNORE_PATHS=mobile_src before_install: - phpenv config-rm xdebug.ini + - nvm install 8.9 + - nvm use 8.9 - cd ../.. - - composer selfupdate - - composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^1 + - composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^2 - export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH" install: - moodle-plugin-ci install + script: - moodle-plugin-ci phplint - - moodle-plugin-ci csslint -# - moodle-plugin-ci stylelint - - moodle-plugin-ci jshint - - moodle-plugin-ci phpcpd - moodle-plugin-ci phpmd - moodle-plugin-ci codechecker -# - moodle-plugin-ci shifter - moodle-plugin-ci validate + - moodle-plugin-ci savepoints + - moodle-plugin-ci mustache + - moodle-plugin-ci grunt - moodle-plugin-ci phpunit - - moodle-plugin-ci behat \ No newline at end of file + - moodle-plugin-ci behat diff --git a/lang/en/qtype_algebra.php b/lang/en/qtype_algebra.php index 7a5729f..b754965 100644 --- a/lang/en/qtype_algebra.php +++ b/lang/en/qtype_algebra.php @@ -133,7 +133,7 @@ $string['pluginnameadding'] = 'Adding an algebra question'; $string['pluginnameediting'] = 'Editing an algebra question'; $string['pluginname_link'] = 'question/type/algebra'; $string['pluginname_help'] = 'Student enter a formula as response that include one or more variables. Correctness is evaluted using one of 3 differents methods'; -$string['pluginname'] = 'algebra'; +$string['pluginname'] = 'Algebra'; $string['pluginnamesummary'] = 'Student enter a formula that can include one or more variables. Correctness is evaluted using one of 3 differents methods.'; $string['host'] = 'Host url of SAGE server'; $string['port'] = 'Port of SAGE server'; diff --git a/tests/behat/add.feature b/tests/behat/add.feature new file mode 100644 index 0000000..4b7319f --- /dev/null +++ b/tests/behat/add.feature @@ -0,0 +1,36 @@ +@qtype @qtype_algebra +Feature: Test creating an Algebra question + As a teacher + In order to test my students + I need to be able to create an Algebra question + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to "Question bank" node in "Course administration" + + Scenario: Create an Algebra question + When I add a "Algebra" question filling the form with: + | Question name | algebra-001 | + | Question text | What is the derivative of f(x) = x^2 ? | + | General feedback | The correct answer is 2*x | + | Default mark | 1 | + | id_variable_0 | x | + | id_varmin_0 | -5 | + | id_varmax_0 | 5 | + | id_answer_0 | 2*x | + | id_fraction_0 | 100% | + | id_feedback_0 | Well done. 2*x is correct. | + | id_answer_1 | * | + | id_fraction_1 | None | + | id_feedback_1 | Your answer is incorrect. | + Then I should see "algebra-001" diff --git a/tests/behat/import.feature b/tests/behat/import.feature new file mode 100644 index 0000000..8e43aff --- /dev/null +++ b/tests/behat/import.feature @@ -0,0 +1,30 @@ +@qtype @qtype_algebra +Feature: Test importing Algebra questions + As a teacher + In order to reuse Algebra questions + I need to import them + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | T1 | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I am on "Course 1" course homepage + + @javascript @_file_upload + Scenario: import Algebra question. + When I navigate to "Import" node in "Course administration > Question bank" + And I set the field "id_format_xml" to "1" + And I upload "question/type/algebra/tests/fixtures/qtype_sample_algebra.xml" file to "Import" filemanager + And I press "id_submitbutton" + Then I should see "Parsing questions from import file." + And I should see "Importing 1 questions from file" + And I should see "1. What is the derivative of the function \(f(x) = x^2\) ?" + And I press "Continue" + And I should see "Derive" diff --git a/xmlrpc-utils.php b/xmlrpc-utils.php index a324a74..a9ca71c 100644 --- a/xmlrpc-utils.php +++ b/xmlrpc-utils.php @@ -23,7 +23,7 @@ // xml-encoded function calls. // Author: Dan Libby (dan@libby.com) // Epinions.com may be contacted at feedback@epinions-inc.com -// It was adapted to Moodle standards and coding style +// It was adapted to Moodle standards and coding style. // Copyright 2001 Epinions, Inc. -- cgit v1.2.3