Skip to content

Commit 505b4cc

Browse files
committed
Fix unit tests
1 parent d1aee54 commit 505b4cc

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

tests/message_providers_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function test_message_providers(): void {
8383

8484
// Verify if the message provider has been generated correctly.
8585
$messageprovider = $recipe['message_providers'][0]['name'];
86-
$this->assertStringContainsString("'".$messageprovider."' => array(", $messagesfile);
86+
$this->assertStringContainsString("'".$messageprovider."' => [", $messagesfile);
8787

8888
$capability = $recipe['message_providers'][0]['capability'];
8989
$this->assertStringContainsString("'capability' => '".$capability."'", $messagesfile);

tests/mobile_addons_test.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,15 @@ public function test_db_mobile_php(): void {
8686
$moodleinternal = "defined('MOODLE_INTERNAL') || die()";
8787
$this->assertStringContainsString($moodleinternal, $dbmobilefile);
8888

89-
$addon = "'".$recipe['mobile_addons'][0]['name']."' => array(";
89+
$addon = "'".$recipe['mobile_addons'][0]['name']."' => [";
9090
$this->assertStringContainsString($addon, $dbmobilefile);
9191

9292
$dependencieslist = $recipe['mobile_addons'][0]['dependencies'];
93-
foreach ($dependencieslist as $key => $dependency) {
94-
$dependencieslist[$key] = "'".$dependency['name']."'";
93+
foreach ($dependencieslist as $dependency) {
94+
$this->assertStringContainsString("'".$dependency['name']."'", $dbmobilefile);
9595
}
96-
$dependencies = "'dependencies' => array(".implode(', ', $dependencieslist).", )";
97-
$this->assertStringContainsString($dependencies, $dbmobilefile);
9896

99-
$addon = "'".$recipe['mobile_addons'][1]['name']."' => array(";
97+
$addon = "'".$recipe['mobile_addons'][1]['name']."' => [";
10098
$this->assertStringContainsString($addon, $dbmobilefile);
10199
}
102100
}

tests/mod_test.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public function test_view_php(): void {
262262
$requirelogin = 'require_login($course, true, $cm)';
263263
$this->assertStringContainsString($requirelogin, $viewfile);
264264

265-
$seturl = "\$PAGE->set_url('/mod/demo/view.php', array('id' => \$cm->id))";
265+
$seturl = "\$PAGE->set_url('/mod/demo/view.php', ['id' => \$cm->id])";
266266
$this->assertStringContainsString($seturl, $viewfile);
267267

268268
$header = 'echo $OUTPUT->header()';
@@ -294,13 +294,13 @@ public function test_index_php(): void {
294294
$requireconfig = "require(__DIR__.'/../../config.php')";
295295
$this->assertStringContainsString($requireconfig, $indexfile);
296296

297-
$course = "\$DB->get_record('course', array('id' => \$id), '*', MUST_EXIST)";
297+
$course = "\$DB->get_record('course', ['id' => \$id], '*', MUST_EXIST)";
298298
$this->assertStringContainsString($course, $indexfile);
299299

300300
$requirecourselogin = 'require_course_login($course)';
301301
$this->assertStringContainsString($requirecourselogin, $indexfile);
302302

303-
$seturl = "\$PAGE->set_url('/mod/demo/index.php', array('id' => \$id))";
303+
$seturl = "\$PAGE->set_url('/mod/demo/index.php', ['id' => \$id])";
304304
$this->assertStringContainsString($seturl, $indexfile);
305305

306306
$header = 'echo $OUTPUT->header()';
@@ -383,7 +383,7 @@ public function test_file_area_feature(): void {
383383
$this->assertStringContainsString($getfileinfo, $libfile);
384384

385385
$pluginfile = 'function demo_pluginfile('.
386-
'$course, $cm, $context, $filearea, $args, $forcedownload, $options = array())';
386+
'$course, $cm, $context, $filearea, $args, $forcedownload, $options = [])';
387387
$this->assertStringContainsString($pluginfile, $libfile);
388388
}
389389

tests/privacy_test.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function test_null_provider(): void {
107107

108108
$this->assertStringContainsString('Privacy API implementation for the Foo bar plugin.', $providerphp);
109109
$this->assertStringContainsString('class provider implements \core_privacy\local\metadata\null_provider {', $providerphp);
110-
$this->assertStringContainsString('public static function get_reason() : string {', $providerphp);
110+
$this->assertStringContainsString('public static function get_reason(): string {', $providerphp);
111111

112112
$langfile = $files['lang/en/local_foobar.php'];
113113

@@ -303,7 +303,7 @@ public function test_dbfields_metadata_provider(): void {
303303
$providerphp
304304
);
305305
$this->assertStringContainsString(
306-
'public static function get_metadata(collection $collection) : collection {',
306+
'public static function get_metadata(collection $collection): collection {',
307307
$providerphp
308308
);
309309
}
@@ -447,7 +447,7 @@ public function test_get_contexts_for_userid(): void {
447447

448448
$this->assertStringContainsString('use core_privacy\local\request\contextlist;', $providerphp);
449449
$this->assertStringContainsString(
450-
'public static function get_contexts_for_userid(int $userid) : contextlist {',
450+
'public static function get_contexts_for_userid(int $userid): contextlist {',
451451
$providerphp
452452
);
453453
}

tests/tiny_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ protected static function get_test(array $settings = []): array {
141141
* @param array $settings
142142
* @return array
143143
*/
144-
protected function get_recipe(array $settings = []): array {
144+
protected static function get_recipe(array $settings = []): array {
145145
$settings = array_merge([
146146
'options' => [],
147147
'buttons' => false,

0 commit comments

Comments
 (0)