Skip to content

Commit

Permalink
Improve the way of setting jobehost during behat testing by moving th…
Browse files Browse the repository at this point in the history
…e special case hack to ajax.php so that the test-sandbox-config file is always used.
  • Loading branch information
trampgeek committed Mar 5, 2024
1 parent 7031350 commit 4fb41f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
7 changes: 6 additions & 1 deletion ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@
*/

define('AJAX_SCRIPT', true);

require_once(__DIR__ . '/../../../config.php');

// Hack to prevent AJAX calls from overwriting the test-sandbox-config during behat testing
if ($CFG->prefix === $CFG->behat_prefix) {
require_once('/var/www/html/moodle/question/type/coderunner/tests/fixtures/test-sandbox-config.php');
}

require_once($CFG->dirroot . '/question/engine/lib.php');
require_once($CFG->dirroot . '/question/type/coderunner/questiontype.php');

Expand Down
9 changes: 1 addition & 8 deletions classes/jobesandbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,7 @@ class qtype_coderunner_jobesandbox extends qtype_coderunner_sandbox {
public function __construct() {
global $CFG;
qtype_coderunner_sandbox::__construct();

// Hack to force use of a local jobe host when behat testing.
if ($CFG->prefix == "bht_") {
$this->jobeserver = "localhost";
} else {
$this->jobeserver = get_config('qtype_coderunner', 'jobe_host');
}

$this->jobeserver = get_config('qtype_coderunner', 'jobe_host');
$this->apikey = get_config('qtype_coderunner', 'jobe_apikey');
$this->languages = null;
}
Expand Down

0 comments on commit 4fb41f9

Please sign in to comment.