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
 * 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
    /** @var db handle */
38
    private $db;
39
 
40
    /**
41
     * constructor
42
     * @param testcase $testcase test object
43
     */
44
    public function __construct($testcase) {
45
        $this->db = $testcase->getMockBuilder(\moodle_database::class)
46
            ->getMockForAbstractClass();
47
    }
48
 
49
    /**
50
     * Get db handle
51
     * @return a db handle
52
     */
53
    public function get_mock() {
54
        return $this->db;
55
    }
56
 
57
    /**
58
     * Test caller in stacktrace
59
     * @param string $sql original sql
60
     * @return string sql with comments
61
     */
62
    public function one(string $sql) {
63
        $method = new \ReflectionMethod($this->db, 'add_sql_debugging');
64
        return $method->invoke($this->db, $sql);
65
    }
66
 
67
    /**
68
     * Test caller in stacktrace
69
     * @param string $sql original sql
70
     * @return string sql with comments
71
     */
72
    public function two(string $sql) {
73
        return $this->one($sql);
74
    }
75
 
76
    /**
77
     * Test caller in stacktrace
78
     * @param string $sql original sql
79
     * @return string sql with comments
80
     */
81
    public function three(string $sql) {
82
        return $this->two($sql);
83
    }
84
 
85
    /**
86
     * Test caller in stacktrace
87
     * @param string $sql original sql
88
     * @return string sql with comments
89
     */
90
    public function four(string $sql) {
91
        return $this->three($sql);
92
    }
93
 
94
}