From 5ee0a5f7607b7458bf618d89d798ed5906d518c3 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 4 Oct 2023 20:27:14 +0800 Subject: [PATCH] MDL-79581 core_communication: Linting fixes --- .../provider/matrix/tests/local/command_test.php | 8 ++++---- .../provider/matrix/tests/matrix_client_test.php | 14 +++++++------- .../matrix/tests/matrix_client_test_trait.php | 8 ++++---- .../matrix/tests/matrix_user_manager_test.php | 11 +++++------ communication/tests/api_test.php | 5 ++--- communication/tests/processor_test.php | 5 ++--- 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/communication/provider/matrix/tests/local/command_test.php b/communication/provider/matrix/tests/local/command_test.php index c2a2329a36f..c255f26ed63 100644 --- a/communication/provider/matrix/tests/local/command_test.php +++ b/communication/provider/matrix/tests/local/command_test.php @@ -102,7 +102,7 @@ class command_test extends \advanced_testcase { * * @return array */ - public function url_parsing_provider(): array { + public static function url_parsing_provider(): array { return [ [ 'example/:id/endpoint', @@ -194,7 +194,7 @@ class command_test extends \advanced_testcase { * * @return array */ - public function parameter_and_option_provider(): array { + public static function parameter_and_option_provider(): array { $command = [ 'method' => 'PUT', 'endpoint' => 'example/:id/endpoint', @@ -289,7 +289,7 @@ class command_test extends \advanced_testcase { * Data provider for query parameter tests. * @return array */ - public function query_provider(): array { + public static function query_provider(): array { return [ 'no query' => [ 'query' => [], @@ -350,7 +350,7 @@ class command_test extends \advanced_testcase { * * @return array */ - public function sendasjson_provider(): array { + public static function sendasjson_provider(): array { return [ 'As JSON' => [ 'sendasjon' => true, diff --git a/communication/provider/matrix/tests/matrix_client_test.php b/communication/provider/matrix/tests/matrix_client_test.php index 44072ba9018..00680e242ad 100644 --- a/communication/provider/matrix/tests/matrix_client_test.php +++ b/communication/provider/matrix/tests/matrix_client_test.php @@ -47,7 +47,7 @@ class matrix_client_test extends \advanced_testcase { * Data provider for valid calls to ::instance. * @return array */ - public function instance_provider(): array { + public static function instance_provider(): array { $testcases = [ 'Standard versions' => [ null, @@ -56,7 +56,7 @@ class matrix_client_test extends \advanced_testcase { ]; // Remove a couple of versions. - $versions = $this->get_current_versions(); + $versions = self::get_current_versions(); array_pop($versions); array_pop($versions); @@ -251,7 +251,7 @@ class matrix_client_test extends \advanced_testcase { * * @return array */ - public function implements_feature_provider(): array { + public static function implements_feature_provider(): array { return [ 'Basic supported feature' => [ 'v1.7', @@ -299,12 +299,12 @@ class matrix_client_test extends \advanced_testcase { * * @return array */ - public function require_features_provider(): array { + public static function require_features_provider(): array { // We'll just add to the standard testcases. $testcases = array_map(static function (array $testcase): array { $testcase[1] = [$testcase[1]]; return $testcase; - }, $this->implements_feature_provider()); + }, self::implements_feature_provider()); $testcases['Require many supported features'] = [ 'v1.6', @@ -361,7 +361,7 @@ class matrix_client_test extends \advanced_testcase { * * @return array */ - public function get_version_provider(): array { + public static function get_version_provider(): array { return [ ['v1.1', '1.1'], ['v1.7', '1.7'], @@ -415,7 +415,7 @@ class matrix_client_test extends \advanced_testcase { * * @return array */ - public function meets_version_provider(): array { + public static function meets_version_provider(): array { return [ 'Same version' => ['v1.1', '1.1', true], 'Same version latest' => ['v1.7', '1.7', true], diff --git a/communication/provider/matrix/tests/matrix_client_test_trait.php b/communication/provider/matrix/tests/matrix_client_test_trait.php index 21e6bc0f296..02d33f337c2 100644 --- a/communication/provider/matrix/tests/matrix_client_test_trait.php +++ b/communication/provider/matrix/tests/matrix_client_test_trait.php @@ -102,8 +102,8 @@ trait matrix_client_test_trait { array $unstablefeatures = null, ): Response { $data = (object) [ - "versions" => array_values($this->get_current_versions()), - "unstable_features" => $this->get_current_unstable_features(), + "versions" => array_values(self::get_current_versions()), + "unstable_features" => self::get_current_unstable_features(), ]; if ($versions) { @@ -122,7 +122,7 @@ trait matrix_client_test_trait { * * @return array */ - protected function get_current_versions(): array { + protected static function get_current_versions(): array { return [ v1p1::class => "v1.1", v1p2::class => "v1.2", @@ -138,7 +138,7 @@ trait matrix_client_test_trait { * A helper to get the current unstable features returned by synapse. * @return array */ - protected function get_current_unstable_features(): array { + protected static function get_current_unstable_features(): array { return [ "org.matrix.label_based_filtering" => true, "org.matrix.e2e_cross_signing" => true, diff --git a/communication/provider/matrix/tests/matrix_user_manager_test.php b/communication/provider/matrix/tests/matrix_user_manager_test.php index d96abc8751b..860fb10cf5e 100644 --- a/communication/provider/matrix/tests/matrix_user_manager_test.php +++ b/communication/provider/matrix/tests/matrix_user_manager_test.php @@ -16,7 +16,6 @@ namespace communication_matrix; -use core_communication\processor; use moodle_exception; /** @@ -105,7 +104,7 @@ class matrix_user_manager_test extends \advanced_testcase { * * @return array */ - public function get_formatted_matrix_userid_provider(): array { + public static function get_formatted_matrix_userid_provider(): array { return [ 'alphanumeric' => [ 'https://matrix.example.org', @@ -135,12 +134,12 @@ class matrix_user_manager_test extends \advanced_testcase { * * @return array */ - public function set_matrix_userid_in_moodle_provider(): array { + public static function set_matrix_userid_in_moodle_provider(): array { return array_combine( - array_keys($this->get_formatted_matrix_userid_provider()), + array_keys(self::get_formatted_matrix_userid_provider()), array_map( fn($value) => [$value[2]], - $this->get_formatted_matrix_userid_provider(), + self::get_formatted_matrix_userid_provider(), ), ); } @@ -196,7 +195,7 @@ class matrix_user_manager_test extends \advanced_testcase { * * @return array */ - public function get_formatted_matrix_home_server_provider(): array { + public static function get_formatted_matrix_home_server_provider(): array { return [ 'www is removed' => [ 'https://www.example.org', diff --git a/communication/tests/api_test.php b/communication/tests/api_test.php index 3bcf4c7d3e9..8f976d6a77f 100644 --- a/communication/tests/api_test.php +++ b/communication/tests/api_test.php @@ -16,13 +16,13 @@ namespace core_communication; +use communication_matrix\matrix_test_helper_trait; + defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/../provider/matrix/tests/matrix_test_helper_trait.php'); require_once(__DIR__ . '/communication_test_helper_trait.php'); -use \communication_matrix\matrix_test_helper_trait; - /** * Class api_test to test the communication public api and its associated methods. * @@ -33,7 +33,6 @@ use \communication_matrix\matrix_test_helper_trait; * @covers \core_communication\api */ class api_test extends \advanced_testcase { - use matrix_test_helper_trait; use communication_test_helper_trait; diff --git a/communication/tests/processor_test.php b/communication/tests/processor_test.php index a4719935c1d..fd427eb680c 100644 --- a/communication/tests/processor_test.php +++ b/communication/tests/processor_test.php @@ -16,13 +16,13 @@ namespace core_communication; +use communication_matrix\matrix_test_helper_trait; + defined('MOODLE_INTERNAL') || die(); require_once(__DIR__ . '/../provider/matrix/tests/matrix_test_helper_trait.php'); require_once(__DIR__ . '/communication_test_helper_trait.php'); -use \communication_matrix\matrix_test_helper_trait; - /** * Class processor_test to test the communication internal api and its associated methods. * @@ -33,7 +33,6 @@ use \communication_matrix\matrix_test_helper_trait; * @coversDefaultClass \core_communication\processor */ class processor_test extends \advanced_testcase { - use matrix_test_helper_trait; use communication_test_helper_trait;