Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
use Behat\Gherkin\Node\TableNode;
3
// This file is part of Moodle - http://moodle.org/
4
//
5
// Moodle is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// Moodle is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
17
 
18
/**
19
 * Step definitions related to blocks overrides for the Classic theme.
20
 *
21
 * @package    theme_classic
22
 * @category   test
23
 * @copyright  2019 Michael Hawkins
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 */
26
 
27
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
28
 
29
require_once(__DIR__ . '/../../../../blocks/tests/behat/behat_blocks.php');
30
 
31
/**
32
 * Blocks management step definitions for the Classic theme.
33
 *
34
 * @package    theme_classic
35
 * @category   test
36
 * @copyright  2019 Michael Hawkins
37
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38
 */
39
class behat_theme_classic_behat_blocks extends behat_blocks {
40
 
41
    /**
42
     * Adds the selected block. Editing mode must be previously enabled.
43
     *
44
     * @param string $blockname
45
     * @return void
46
     */
47
    public function i_add_the_block($blockname) {
48
        $this->execute('behat_forms::i_set_the_field_to',
49
                array("bui_addblock", $this->escape($blockname))
50
        );
51
 
52
        // If we are running without javascript we need to submit the form.
53
        if (!$this->running_javascript()) {
54
            $this->execute('behat_general::i_click_on_in_the',
55
                    array(get_string('go'), "button", "#add_block", "css_element")
56
            );
57
        }
58
    }
59
 
60
    /**
61
     * Adds the selected block to the specified region
62
     *
63
     * Editing mode must be previously enabled.
64
     *
65
     * @param string $blockname
66
     * @param string $region
67
     */
68
    public function i_add_the_block_to_the_region(string $blockname, string $region) {
69
        $this->execute('behat_blocks::i_add_the_block', [$blockname]);
70
    }
71
 
72
    /**
73
     * Adds the selected block to the specified region and fills configuration form.
74
     *
75
     * Editing mode must be previously enabled.
76
     *
77
     * @param string $blockname
78
     * @param string $region
79
     * @param TableNode $data
80
     */
81
    public function i_add_the_block_to_the_region_with(string $blockname, string $region, TableNode $data) {
82
        $this->execute('behat_blocks::i_add_the_block_to_the_region', [$blockname, $region]);
83
        $this->wait_for_pending_js();
84
        $blocktitle = $blockname === 'Text' ? '(new text block)' : $blockname;
85
        $this->execute('behat_blocks::i_configure_the_block', [$blocktitle]);
86
        $dialogname = get_string('configureblock', 'core_block', $blocktitle);
87
        $this->execute('behat_forms::i_set_the_following_fields_in_container_to_these_values',
88
            [$dialogname, "dialogue", $data]);
89
        $this->execute('behat_general::i_click_on_in_the', ["Save changes", 'button', $dialogname, 'dialogue']);
90
    }
91
 
92
    /**
93
     * Ensures that block can be added to the page, but does not add it.
94
     *
95
     * @param string $blockname
96
     * @return void
97
     */
98
    public function the_add_block_selector_should_contain_block($blockname) {
99
        $this->execute('behat_forms::the_select_box_should_contain', [get_string('addblock'), $blockname]);
100
    }
101
 
102
    /**
103
     * Ensures that block cannot be added to the page.
104
     *
105
     * @param string $blockname
106
     * @return void
107
     */
108
    public function the_add_block_selector_should_not_contain_block($blockname) {
109
        $this->execute('behat_forms::the_select_box_should_not_contain', [get_string('addblock'), $blockname]);
110
    }
111
}