Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | 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
 * Web interface to list and filter steps
19
 *
20
 * @package    tool_generator
21
 * @copyright  2023 Ferran Recio <ferran@moodle.com>
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
use tool_generator\local\testscenario\runner;
26
use tool_generator\form\featureimport;
27
use tool_generator\output\parsingresult;
1441 ariadna 28
use tool_generator\output\stepsinformation;
1 efrain 29
 
30
require(__DIR__ . '/../../../config.php');
31
require_once($CFG->libdir . '/adminlib.php');
32
require_once($CFG->libdir . '/behat/classes/behat_config_manager.php');
33
 
34
// Executing behat generator can take some time.
35
core_php_time_limit::raise(300);
36
 
37
admin_externalpage_setup('toolgenerator_runtestscenario');
38
 
39
$currenturl = new moodle_url('/admin/tool/generator/runtestscenario.php');
40
$runner = new runner();
41
 
42
/** @var core_renderer $output*/
43
$output = $PAGE->get_renderer('core');
44
 
45
echo $output->header();
46
echo $output->heading(get_string('testscenario', 'tool_generator'));
47
 
48
echo $output->paragraph(get_string('testscenario_description', 'tool_generator'));
49
 
50
try {
51
    $runner->init();
52
} catch (Exception $e) {
53
    echo $output->notification(get_string('testscenario_notready', 'tool_generator'), null, false);
54
    echo $output->footer();
55
    die;
56
}
57
 
1441 ariadna 58
echo $output->render(new stepsinformation($runner));
1 efrain 59
 
60
$mform = new featureimport();
61
 
62
$data = null;
63
if (!$mform->is_cancelled()) {
64
    $data = $mform->get_data();
65
}
66
 
67
if (empty($data)) {
68
    $mform->display();
69
    echo $OUTPUT->footer();
70
    die;
71
}
72
 
73
$content = $mform->get_feature_contents();
74
 
75
if (empty($content)) {
76
    echo $output->notification(get_string('testscenario_invalidfile', 'tool_generator'));
77
    echo $output->continue_button($currenturl);
78
    echo $output->footer();
79
    die;
80
}
81
 
82
try {
1441 ariadna 83
    if ($data->executecleanup) {
84
        $parsedfeature = $runner->parse_cleanup($content);
85
    } else {
86
        $parsedfeature = $runner->parse_feature($content);
87
    }
1 efrain 88
} catch (\Throwable $th) {
89
    echo $output->notification(get_string('testscenario_errorparsing', 'tool_generator', $th->getMessage()));
90
    echo $output->continue_button($currenturl);
91
 
92
    echo $output->footer();
93
    die;
94
}
95
 
96
$runner->execute($parsedfeature);
97
 
98
echo $output->render(new parsingresult($parsedfeature));
99
echo $output->continue_button($currenturl);
100
echo $output->footer();