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
 * User tour related steps definitions.
19
 *
20
 * @package    tool_usertours
21
 * @category   test
22
 * @copyright  2016 Andrew Nicols <andrew@nicols.co.uk>
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
require_once(__DIR__ . '/../../../../../lib/behat/behat_base.php');
27
 
28
use Behat\Gherkin\Node\TableNode;
29
/**
30
 * User tour related steps definitions.
31
 *
32
 * @package    tool_usertours
33
 * @category   test
34
 * @copyright  2016 Andrew Nicols <andrew@nicols.co.uk>
35
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36
 */
37
class behat_tool_usertours extends behat_base {
38
    /**
39
     * Add a new user tour.
40
     *
41
     * @Given /^I add a new user tour with:$/
42
     * @param TableNode $table
43
     */
44
    public function i_add_a_new_user_tour_with(TableNode $table) {
45
        $this->execute('behat_tool_usertours::i_open_the_user_tour_settings_page');
46
        $this->execute('behat_general::click_link', get_string('newtour', 'tool_usertours'));
47
 
48
        // Fill form and post.
49
        $this->execute('behat_forms::i_set_the_following_fields_to_these_values', $table);
50
        $this->execute('behat_forms::press_button', get_string('savechanges', 'moodle'));
51
        $this->execute('behat_general::i_wait_to_be_redirected');
52
    }
53
 
54
    /**
55
     * Add new steps to a user tour.
56
     *
57
     * @Given /^I add steps to the "(?P<tour_name_string>(?:[^"]|\\")*)" tour:$/
58
     * @param   string      $tourname   The name of the tour to add steps to.
59
     * @param   TableNode   $table
60
     */
61
    public function i_add_steps_to_the_named_tour($tourname, TableNode $table) {
62
        $this->execute('behat_tool_usertours::i_open_the_user_tour_settings_page');
63
        $this->execute('behat_general::click_link', $this->escape($tourname));
64
        $this->execute('behat_tool_usertours::i_add_steps_to_the_tour', $table);
65
    }
66
 
67
    /**
68
     * Add new steps to the current user tour.
69
     *
70
     * @Given /^I add steps to the tour:$/
71
     * @param   TableNode   $table
72
     */
73
    public function i_add_steps_to_the_tour(TableNode $table) {
74
        foreach ($table->getHash() as $step) {
75
            $this->execute('behat_general::click_link', get_string('newstep', 'tool_usertours'));
76
 
77
            foreach ($step as $locator => $value) {
78
                $this->execute('behat_forms::i_set_the_field_to', [$this->escape($locator), $this->escape($value)]);
79
            }
80
 
81
            $this->execute('behat_forms::press_button', get_string('savechanges', 'moodle'));
82
            $this->execute('behat_general::i_wait_to_be_redirected');
83
        }
84
    }
85
 
86
    /**
87
     * Navigate to the user tour settings page.
88
     *
89
     * @Given /^I open the User tour settings page$/
90
     */
91
    public function i_open_the_user_tour_settings_page() {
92
        $this->execute(
93
            'behat_navigation::i_navigate_to_in_site_administration',
94
            get_string('appearance', 'admin') . ' > ' .
95
                get_string('usertours', 'tool_usertours')
96
        );
97
    }
98
}