From a0d916bc8689acffe8a305f36b24e6d58e6a339d Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Tue, 20 Sep 2022 18:45:47 +0200 Subject: [PATCH] MDL-76055 libraries: Autoload phpxmlrpc and verify it works Also, we can now safely remove Autoloader.php, because Moodle PSR-4 autoloader has taken control, so document and test it too. --- lib/classes/component.php | 1 + lib/phpxmlrpc/Autoloader.php | 36 --------------------- lib/phpxmlrpc/readme_moodle.txt | 2 ++ lib/tests/phpxmlrpc_test.php | 57 +++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 36 deletions(-) delete mode 100644 lib/phpxmlrpc/Autoloader.php create mode 100644 lib/tests/phpxmlrpc_test.php diff --git a/lib/classes/component.php b/lib/classes/component.php index dece4396550..a7e8a6ce9a9 100644 --- a/lib/classes/component.php +++ b/lib/classes/component.php @@ -108,6 +108,7 @@ class core_component { 'ZipStream' => 'lib/zipstream/src/', 'MyCLabs\\Enum' => 'lib/php-enum/src', 'Psr\\Http\\Message' => 'lib/http-message/src', + 'PhpXmlRpc' => 'lib/phpxmlrpc', ); /** diff --git a/lib/phpxmlrpc/Autoloader.php b/lib/phpxmlrpc/Autoloader.php deleted file mode 100644 index 40ec2190c23..00000000000 --- a/lib/phpxmlrpc/Autoloader.php +++ /dev/null @@ -1,36 +0,0 @@ -. + +namespace core; + +use PhpXmlRpc\Client; +use PhpXmlRpc\Request; +use PhpXmlRpc\Response; +use PhpXmlRpc\Server; +use PhpXmlRpc\Value; + +/** + * phpxmlrpc library unit tests. + * + * @package core + * @category test + * @copyright 2022 onwards Eloy Lafuente (stronk7) {@link https://stronk7.com} + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class phpxmlrpc_test extends \basic_testcase { + + /** + * Ensure PhpXmlRpc availability. + * + * This may seem silly, sure it is. But it's a good way to verify + * that the Moodle PSR-4 autoloader is working ok. + * + * @coversNothing + */ + public function test_phpxmlrpc_availability() { + // All these classes need to be at hand. + $this->assertInstanceOf(\PhpXmlRpc\Client::class, new Client('https://example.com')); + $this->assertInstanceOf(\PhpXmlRpc\Request::class, new Request('')); + $this->assertInstanceOf(\PhpXmlRpc\Response::class, new Response('')); + $this->assertInstanceOf(\PhpXmlRpc\Server::class, new Server()); + $this->assertInstanceOf(\PhpXmlRpc\Value::class, new Value()); + + // Worth checking that we have removed this. + $this->assertFileDoesNotExist(__DIR__ . '/../phpxmlrpc/Autoloader.php'); + + // We cannnot live without our beloved readme. + $this->assertFileExists(__DIR__ . '/../phpxmlrpc/readme_moodle.txt'); + } +}