MDL-37046 behat: Adding steps definitions list filters
[moodle.git] / admin / tool / behat / renderer.php
CommitLineData
d46340eb
DM
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 tool renderer
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
25if (!defined('MOODLE_INTERNAL')) {
26 die('Direct access to this script is forbidden.');
27}
28
29/**
30 * Renderer for behat tool web features
31 *
32 * @package tool_behat
33 * @copyright 2012 David MonllaĆ³
34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35 */
36class tool_behat_renderer extends plugin_renderer_base {
37
38 /**
39 * Renders the list of available steps according to the submitted filters
40 *
41 * @param string $stepsdefinitions HTML from behat with the available steps
42 * @param moodleform $form
43 * @return string HTML code
44 */
45 public function render_stepsdefinitions($stepsdefinitions, $form) {
46
47 $title = get_string('pluginname', 'tool_behat');
48
49 // Header.
50 $html = $this->output->header();
51 $html .= $this->output->heading($title);
52
53 // Info.
54 $installurl = tool_behat::$docsurl . '#Installation';
55 $installlink = html_writer::tag('a', $installurl, array('href' => $installurl, 'target' => '_blank'));
56 $writetestsurl = tool_behat::$docsurl . '#Writting_features';
57 $writetestslink = html_writer::tag('a', $writetestsurl, array('href' => $writetestsurl, 'target' => '_blank'));
58 $writestepsurl = tool_behat::$docsurl . '#Adding_steps_definitions';
59 $writestepslink = html_writer::tag('a', $writestepsurl, array('href' => $writestepsurl, 'target' => '_blank'));
60 $infos = array(
61 'Read ' . $installlink . ' ' . get_string('installinfo', 'tool_behat'),
62 'Read ' . $writetestslink . ' ' . get_string('newtestsinfo', 'tool_behat'),
63 'Read ' . $writestepslink . ' ' . get_string('newstepsinfo', 'tool_behat')
64 );
65 $html .= $this->output->box_start();
66 $html .= html_writer::tag('h1', 'Info');
67 $html .= html_writer::tag('div', '<ul><li>' . implode('</li><li>', $infos) . '</li></ul>');
68 $html .= $this->output->box_end();
69
70 // Form.
71 ob_start();
72 $form->display();
73 $html .= ob_get_contents();
74 ob_end_clean();
75
76 // Steps definitions.
77 $html .= html_writer::tag('div', $stepsdefinitions, array('id' => 'steps-definitions'));
78
79 $html .= $this->output->footer();
80
81 return $html;
82 }
83}