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
 * Test SQL debugging fixture
19
 *
20
 * @package    core
21
 * @category   dml
22
 * @copyright  2020 Brendan Heywood <brendan@catalyst-au.net>
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
defined('MOODLE_INTERNAL') || die();
27
 
28
/**
29
 * Test SQL debugging fixture
30
 *
31
 * @package    core
32
 * @category   dml
33
 * @copyright  2020 Brendan Heywood <brendan@catalyst-au.net>
34
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
 */
36
class test_dml_sql_debugging_fixture {
37
    /**
1441 ariadna 38
     * Constructor
39
     * @param \moodle_database $db The database handle to use for this fixture
1 efrain 40
     */
1441 ariadna 41
    public function __construct(
42
        /** @var \moodle_database The database handle to use for this fixture */
43
        private \moodle_database $db,
44
    ) {
1 efrain 45
    }
46
 
47
    /**
48
     * Get db handle
49
     * @return a db handle
50
     */
51
    public function get_mock() {
52
        return $this->db;
53
    }
54
 
55
    /**
56
     * Test caller in stacktrace
57
     * @param string $sql original sql
58
     * @return string sql with comments
59
     */
60
    public function one(string $sql) {
61
        $method = new \ReflectionMethod($this->db, 'add_sql_debugging');
62
        return $method->invoke($this->db, $sql);
63
    }
64
 
65
    /**
66
     * Test caller in stacktrace
67
     * @param string $sql original sql
68
     * @return string sql with comments
69
     */
70
    public function two(string $sql) {
71
        return $this->one($sql);
72
    }
73
 
74
    /**
75
     * Test caller in stacktrace
76
     * @param string $sql original sql
77
     * @return string sql with comments
78
     */
79
    public function three(string $sql) {
80
        return $this->two($sql);
81
    }
82
 
83
    /**
84
     * Test caller in stacktrace
85
     * @param string $sql original sql
86
     * @return string sql with comments
87
     */
88
    public function four(string $sql) {
89
        return $this->three($sql);
90
    }
91
 
92
}