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 |
/**
|
|
|
18 |
* Web interface to list and filter steps
|
|
|
19 |
*
|
|
|
20 |
* @package tool_behat
|
|
|
21 |
* @copyright 2012 David Monllaó
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
require(__DIR__ . '/../../../config.php');
|
|
|
26 |
require_once($CFG->libdir.'/adminlib.php');
|
|
|
27 |
require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/behat/locallib.php');
|
|
|
28 |
require_once($CFG->libdir . '/behat/classes/behat_config_manager.php');
|
|
|
29 |
|
|
|
30 |
// This page usually takes an exceedingly long time to load, so we need to
|
|
|
31 |
// increase the time limit. At present it takes about a minute on some
|
|
|
32 |
// systems, but let's allow room for expansion.
|
|
|
33 |
core_php_time_limit::raise(300);
|
|
|
34 |
|
|
|
35 |
$filter = optional_param('filter', '', PARAM_NOTAGS);
|
|
|
36 |
$type = optional_param('type', false, PARAM_ALPHAEXT);
|
|
|
37 |
$component = optional_param('component', '', PARAM_ALPHAEXT);
|
|
|
38 |
|
|
|
39 |
admin_externalpage_setup('toolbehat');
|
|
|
40 |
|
|
|
41 |
// Getting available steps definitions from behat.
|
|
|
42 |
$steps = tool_behat::stepsdefinitions($type, $component, $filter);
|
|
|
43 |
|
|
|
44 |
// Form.
|
|
|
45 |
$componentswithsteps = array('' => get_string('allavailablesteps', 'tool_behat'));
|
|
|
46 |
|
|
|
47 |
// Complete the components list with the moodle steps definitions.
|
|
|
48 |
$behatconfig = new behat_config_util();
|
|
|
49 |
$components = $behatconfig->get_components_contexts();
|
|
|
50 |
if ($components) {
|
|
|
51 |
foreach ($components as $component => $filepath) {
|
|
|
52 |
// TODO Use a class static attribute instead of the class name.
|
|
|
53 |
$componentswithsteps[$component] = 'Moodle ' . substr($component, 6);
|
|
|
54 |
}
|
|
|
55 |
}
|
|
|
56 |
$form = new steps_definitions_form(null, array('components' => $componentswithsteps));
|
|
|
57 |
|
|
|
58 |
// Output contents.
|
|
|
59 |
$PAGE->requires->js_call_amd('tool_behat/steps', 'init');
|
|
|
60 |
$renderer = $PAGE->get_renderer('tool_behat');
|
|
|
61 |
echo $renderer->render_stepsdefinitions($steps, $form);
|
|
|
62 |
|