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 |
namespace core;
|
|
|
18 |
|
|
|
19 |
// phpcs:disable moodle.PHPUnit.TestCaseNames.Missing
|
|
|
20 |
/**
|
|
|
21 |
* Just a wrapper to access protected apis for testing.
|
|
|
22 |
*
|
|
|
23 |
* Note: This is deprecated. Please use Reflection instead.
|
|
|
24 |
*
|
|
|
25 |
* @package core
|
|
|
26 |
* @subpackage phpunit
|
|
|
27 |
* @copyright 2009 Petr Skoda {@link http://skodak.org}
|
|
|
28 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
29 |
*/
|
|
|
30 |
class test_exernal_api extends \core_external\external_api {
|
|
|
31 |
public static function get_context_wrapper($params) {
|
|
|
32 |
debugging(
|
|
|
33 |
'test_exernal_api::get_context_wrapper() is deprecated. Please use Reflection instead.',
|
|
|
34 |
DEBUG_DEVELOPER
|
|
|
35 |
);
|
|
|
36 |
return self::get_context_from_params($params);
|
|
|
37 |
}
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* Test external API functions.
|
|
|
42 |
*
|
|
|
43 |
* @package core
|
|
|
44 |
* @subpackage phpunit
|
|
|
45 |
*/
|
|
|
46 |
class core_externallib_test extends \advanced_testcase {
|
|
|
47 |
/**
|
|
|
48 |
* Test the get_context_wrapper helper.
|
|
|
49 |
*
|
|
|
50 |
* @covers \core\test_exernal_api::get_context_wrapper
|
|
|
51 |
*/
|
|
|
52 |
public function test_get_context_wrapper(): void {
|
|
|
53 |
$this->assertEquals(
|
|
|
54 |
\context_system::instance(),
|
|
|
55 |
\core\test_exernal_api::get_context_wrapper(['contextid' => \context_system::instance()->id])
|
|
|
56 |
);
|
|
|
57 |
$this->assertDebuggingCalled(
|
|
|
58 |
'test_exernal_api::get_context_wrapper() is deprecated. Please use Reflection instead.'
|
|
|
59 |
);
|
|
|
60 |
}
|
|
|
61 |
}
|