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
 * Steps definitions related with the database activity.
19
 *
20
 * @package    mod_data
21
 * @category   test
22
 * @copyright  2014 David Monllaó
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
27
 
28
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');
29
 
30
use Behat\Gherkin\Node\TableNode as TableNode;
31
/**
32
 * Database-related steps definitions.
33
 *
34
 * @package    mod_data
35
 * @category   test
36
 * @copyright  2014 David Monllaó
37
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38
 */
39
class behat_mod_data extends behat_base {
40
 
41
    /**
42
     * Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'.
43
     *
44
     * Recognised page names are:
45
     * | pagetype  | name meaning  | description                  |
46
     * | Add entry | Database name | Add an entry page (view.php) |
47
     *
48
     * @param string $type identifies which type of page this is, e.g. 'Add entry'.
49
     * @param string $identifier identifies the particular page, e.g. 'My database name'.
50
     * @return moodle_url the corresponding URL.
51
     * @throws Exception with a meaningful error message if the specified page cannot be found.
52
     */
53
    protected function resolve_page_instance_url(string $type, string $identifier): moodle_url {
54
        global $DB;
55
 
56
        switch (strtolower($type)) {
57
            case 'add entry':
58
                return new moodle_url('/mod/data/edit.php', [
59
                    'd' => $this->get_cm_by_activity_name('data', $identifier)->instance,
60
                ]);
61
 
62
            default:
63
                throw new Exception("Unrecognised page type '{$type}'");
64
        }
65
    }
66
}