1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
|
|
|
18 |
|
|
|
19 |
use Moodle\BehatExtension\Exception\SkippedException;
|
|
|
20 |
|
|
|
21 |
require_once(__DIR__ . '/../../behat/behat_base.php');
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
* Steps definitions related to MoodleNet.
|
|
|
25 |
*
|
|
|
26 |
* @package core
|
|
|
27 |
* @category test
|
|
|
28 |
* @copyright 2023 Huong Nguyen <huongnv13@gmail.com>
|
|
|
29 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
30 |
*/
|
|
|
31 |
class behat_moodlenet extends behat_base {
|
|
|
32 |
|
|
|
33 |
/**
|
|
|
34 |
* Check that the TEST_MOODLENET_MOCK_SERVER is defined, so we can connect to the mock server.
|
|
|
35 |
*
|
|
|
36 |
* @Given /^a MoodleNet mock server is configured$/
|
|
|
37 |
*/
|
|
|
38 |
public function mock_is_configured(): void {
|
|
|
39 |
if (!defined('TEST_MOODLENET_MOCK_SERVER')) {
|
|
|
40 |
throw new SkippedException(
|
|
|
41 |
'The TEST_MOODLENET_MOCK_SERVER constant must be defined to run MoodleNet tests'
|
|
|
42 |
);
|
|
|
43 |
}
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* Change the service base url to the TEST_MOODLENET_MOCK_SERVER url.
|
|
|
48 |
*
|
|
|
49 |
* @Given /^I change the MoodleNet field "(?P<field_string>(?:[^"]|\\")*)" to mock server$/
|
|
|
50 |
* @param string $field Field name
|
|
|
51 |
*/
|
|
|
52 |
public function change_service_base_url_to_mock_url(string $field): void {
|
|
|
53 |
$field = behat_field_manager::get_form_field_from_label($field, $this);
|
|
|
54 |
$field->set_value(TEST_MOODLENET_MOCK_SERVER);
|
|
|
55 |
}
|
|
|
56 |
}
|