Skip to content

Commit

Permalink
Branch for Moodle 4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed Mar 25, 2024
1 parent 4cd91bc commit 6fa6d1c
Show file tree
Hide file tree
Showing 9 changed files with 219 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: plugin

Expand Down
2 changes: 2 additions & 0 deletions externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

namespace mod_questionnaire;

defined('MOODLE_INTERNAL') || die();

require_once($CFG->libdir . '/externallib.php');

use external_api;
Expand Down
4 changes: 2 additions & 2 deletions tests/behat/questionnaire_activity_completion.feature
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ Feature: View activity completion information in the questionnaire activity
Then I should see "Are you still in School?"
And I should see "Select one choice"
And I should see "Enter some text"
And I set the field with xpath "//input[@type='radio' and @id='auto-rb0001']" to "1"
And I set the field with xpath "//input[@type='radio' and @id='auto-rb0005']" to "1"
And I set the field "Yes" to "1"
And I set the field "Three" to "1"
And I press "Submit questionnaire"
Then I should see "Thank you for completing this Questionnaire."
And I press "Continue"
Expand Down
17 changes: 11 additions & 6 deletions tests/csvexport_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace mod_questionnaire;

/**
* Performance test for questionnaire module.
*
* @package mod_questionnaire
* @group mod_questionnaire
* @author Guy Thomas
* @copyright Copyright (c) 2015 Moodlerooms Inc. (http://www.moodlerooms.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace mod_questionnaire;

/**
* Unit tests for questionnaire_csvexport_test.
* @group mod_questionnaire
*/
class csvexport_test extends \advanced_testcase {

public function setUp(): void {
Expand Down Expand Up @@ -55,10 +59,9 @@ private function get_csv_text(array $rows) {
}

/**
* Test case for the csvexport method.
* Tests the CSV export.
*
* @covers ::csvexport
* @covers \questionnaire::generate_csv
*/
public function test_csvexport() {
$this->resetAfterTest();
Expand Down Expand Up @@ -90,6 +93,8 @@ public function test_csvexport() {

/**
* Tests the CSV export with identity fields and anonymous questionnaires.
*
* @covers \questionnaire::generate_csv
*/
public function test_csvexport_identity_fields() {
global $DB;
Expand Down Expand Up @@ -148,7 +153,7 @@ private function do_test_csvexport_identity_fields($course, $cm, $user, $roleid,
assign_capability('moodle/site:viewuseridentity', CAP_ALLOW, $roleid, $context);

// Generate CSV output.
$questionnaire = new questionnaire($course, $cm, $item->id);
$questionnaire = new \questionnaire($course, $cm, $item->id);
$output = $questionnaire->generate_csv(0, '', '', 0, 0, 1);

$this->assertNotNull($output);
Expand Down
15 changes: 8 additions & 7 deletions tests/custom_completion_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

namespace mod_questionnaire;

use advanced_testcase;
use cm_info;
use coding_exception;
use mod_questionnaire\completion\custom_completion;
Expand All @@ -45,7 +44,7 @@
* @copyright 2022 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class custom_completion_test extends advanced_testcase {
class custom_completion_test extends \advanced_testcase {

/**
* Data provider for get_state().
Expand All @@ -72,14 +71,15 @@ public function get_state_provider(): array {
/**
* Test for get_state().
*
* @covers \mod_questionnaire\completion\custom_completion::get_state
* @dataProvider get_state_provider
* @param string $rule The custom completion rule.
* @param int $available Whether this rule is available.
* @param bool $submitted
* @param int|null $status Expected status.
* @param string|null $exception Expected exception.
* @throws coding_exception
*
* @covers \mod_questionnaire\completion\custom_completion
*/
public function test_get_state(string $rule, int $available, ?bool $submitted, ?int $status, ?string $exception) {
if (!is_null($exception)) {
Expand Down Expand Up @@ -116,7 +116,7 @@ public function test_get_state(string $rule, int $available, ?bool $submitted, ?
/**
* Test for get_defined_custom_rules().
*
* @covers \mod_questionnaire\completion\custom_completion::get_defined_custom_rules
* @covers \mod_questionnaire\completion\custom_completion
*/
public function test_get_defined_custom_rules() {
$rules = custom_completion::get_defined_custom_rules();
Expand All @@ -127,7 +127,7 @@ public function test_get_defined_custom_rules() {
/**
* Test for get_defined_custom_rule_descriptions().
*
* @covers \mod_questionnaire\completion\custom_completion::get_custom_rule_descriptions
* @covers \mod_questionnaire\completion\custom_completion
*/
public function test_get_custom_rule_descriptions() {
// Get defined custom rules.
Expand Down Expand Up @@ -155,7 +155,7 @@ public function test_get_custom_rule_descriptions() {
/**
* Test for is_defined().
*
* @covers \mod_questionnaire\completion\custom_completion::is_defined
* @covers \mod_questionnaire\completion\custom_completion
*/
public function test_is_defined() {
// Build a mock cm_info instance.
Expand Down Expand Up @@ -191,10 +191,11 @@ public function get_available_custom_rules_provider(): array {
/**
* Test for get_available_custom_rules().
*
* @covers \mod_questionnaire\completion\custom_completion::get_available_custom_rules
* @dataProvider get_available_custom_rules_provider
* @param int $status
* @param array $expected
*
* @covers \mod_questionnaire\completion\custom_completion
*/
public function test_get_available_custom_rules(int $status, array $expected) {
$customdataval = [
Expand Down
25 changes: 19 additions & 6 deletions tests/generator_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace mod_questionnaire;

/**
* PHPUnit questionnaire generator tests
*
Expand All @@ -24,11 +22,22 @@
* @author Mike Churchward
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace mod_questionnaire;

/**
* Unit tests for questionnaire_generator_testcase.
* @group mod_questionnaire
*/
class generator_test extends \advanced_testcase {
/**
* Test case for the create_instance function.
* Test generator create_instance function.
*
* @covers \mod_questionnaire_generator::create_instance
* @return void
* @throws coding_exception
* @throws dml_exception
*
* @covers \mod_questionnaire\generator\
*/
public function test_create_instance() {
global $DB;
Expand Down Expand Up @@ -65,9 +74,13 @@ public function test_create_instance() {
}

/**
* Test case for the create_content function.
* Test generator create_content function.
*
* @return void
* @throws coding_exception
* @throws dml_exception
*
* @covers \mod_questionnaire_generator::create_content
* @covers \mod_questionnaire\generator\
*/
public function test_create_content() {
global $DB;
Expand Down
Loading

0 comments on commit 6fa6d1c

Please sign in to comment.