MDL-79581 core_communication: Linting fixes

This commit is contained in:
Andrew Nicols 2023-10-04 20:27:14 +08:00
parent 166d137407
commit 5ee0a5f760
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14
6 changed files with 24 additions and 27 deletions

View File

@ -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,

View File

@ -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],

View File

@ -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,

View File

@ -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',

View File

@ -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;

View File

@ -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;