Merge branch 'MDL-73483-master' of https://github.com/dmitriim/moodle
[moodle.git] / lib / tests / externallib_test.php
blob8f32b7a94ec42366d215f50d81bd7dca735d6d20
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.
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/>.
17 namespace core;
19 // phpcs:disable moodle.PHPUnit.TestCaseNames.Missing
20 /**
21 * Just a wrapper to access protected apis for testing.
23 * Note: This is deprecated. Please use Reflection instead.
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
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
36 return self::get_context_from_params($params);
40 /**
41 * Test external API functions.
43 * @package core
44 * @subpackage phpunit
46 class core_externallib_test extends \advanced_testcase {
47 /**
48 * Test the get_context_wrapper helper.
50 * @covers \core\test_exernal_api::get_context_wrapper
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])
57 $this->assertDebuggingCalled(
58 'test_exernal_api::get_context_wrapper() is deprecated. Please use Reflection instead.'