Skip to content

Commit

Permalink
MDL-76583 external: Add unit test for deprecated test helper
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jan 19, 2023
1 parent 1dbc7b3 commit fcbad1f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/tests/externallib_test.php
Expand Up @@ -29,6 +29,33 @@
*/
class test_exernal_api extends \core_external\external_api {
public static function get_context_wrapper($params) {
debugging(
'test_exernal_api::get_context_wrapper() is deprecated. Please use Reflection instead.',
DEBUG_DEVELOPER
);
return self::get_context_from_params($params);
}
}

/**
* Test external API functions.
*
* @package core
* @subpackage phpunit
*/
class core_externallib_test extends \advanced_testcase {
/**
* Test the get_context_wrapper helper.
*
* @covers \core\test_exernal_api::get_context_wrapper
*/
public function test_get_context_wrapper(): void {
$this->assertEquals(
\context_system::instance(),
\core\test_exernal_api::get_context_wrapper(['contextid' => \context_system::instance()->id])
);
$this->assertDebuggingCalled(
'test_exernal_api::get_context_wrapper() is deprecated. Please use Reflection instead.'
);
}
}

0 comments on commit fcbad1f

Please sign in to comment.