Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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
 * Behat commands
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
defined('MOODLE_INTERNAL') || die();
26
 
27
global $CFG;
28
require_once($CFG->libdir . '/behat/classes/behat_command.php');
29
require_once($CFG->libdir . '/behat/classes/behat_config_manager.php');
30
require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/behat/steps_definitions_form.php');
31
 
32
/**
33
 * Behat commands manager
34
 *
35
 * @package    tool_behat
36
 * @copyright  2012 David Monllaó
37
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38
 */
39
class tool_behat {
40
 
41
    /**
42
     * Lists the available steps definitions
43
     *
44
     * @param string $type
45
     * @param string $component
46
     * @param string $filter
47
     * @return array System steps or empty array if case there are no steps
48
     */
49
    public static function stepsdefinitions($type, $component, $filter) {
50
 
51
        // We don't require the test environment to be enabled to list the steps definitions
52
        // so test writers can more easily set up the environment.
53
        behat_command::behat_setup_problem();
54
 
55
        // The loaded steps depends on the component specified.
56
        behat_config_manager::update_config_file($component, false);
57
 
58
        // The Moodle\BehatExtension\Definition\Printer\ConsoleDefinitionInformationPrinter will parse this search format.
59
        if ($type) {
60
            $filter .= '&&' . $type;
61
        }
62
 
63
        if ($filter) {
64
            $filteroption = ' -d ' . escapeshellarg($filter);
65
        } else {
66
            $filteroption = ' -di';
67
        }
68
 
69
        // Get steps definitions from Behat.
70
        $options = ' --config="'.behat_config_manager::get_steps_list_config_filepath(). '" '.$filteroption;
71
        list($steps, $code) = behat_command::run($options);
72
 
73
        return $steps;
74
    }
75
 
76
}