Merge branch '47752-28' of git://github.com/samhemelryk/moodle
[moodle.git] / admin / tool / behat / index.php
blob5e71bdff59d237689002e95f211fa9a4ef7b8ed6
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.
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/>.
17 /**
18 * Web interface to list and filter steps
20 * @package tool_behat
21 * @copyright 2012 David MonllaĆ³
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
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');
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);
35 $filter = optional_param('filter', '', PARAM_ALPHANUMEXT);
36 $type = optional_param('type', false, PARAM_ALPHAEXT);
37 $component = optional_param('component', '', PARAM_ALPHAEXT);
39 admin_externalpage_setup('toolbehat');
41 // Getting available steps definitions from behat.
42 $steps = tool_behat::stepsdefinitions($type, $component, $filter);
44 // Form.
45 $componentswithsteps = array('' => get_string('allavailablesteps', 'tool_behat'));
47 // Complete the components list with the moodle steps definitions.
48 $components = behat_config_manager::get_components_steps_definitions();
49 if ($components) {
50 foreach ($components as $component => $filepath) {
51 // TODO Use a class static attribute instead of the class name.
52 $componentswithsteps[$component] = 'Moodle ' . substr($component, 6);
55 $form = new steps_definitions_form(null, array('components' => $componentswithsteps));
57 // Output contents.
58 $renderer = $PAGE->get_renderer('tool_behat');
59 echo $renderer->render_stepsdefinitions($steps, $form);