MDL-67673 phpunit: Remove deprecated assertContains() uses on strings

Both assertContains() and assertNotContains() are deprecated in PHPUnit 8
for operations on strings. Also the optional case parameter is. All uses
must be changed to one of:

- assertStringContainsString()
- assertStringContainsStringIgnoringCase()
- assertStringNotContainsString()
- assertStringNotContainsStringIgnoringCase()

More info: https://github.com/sebastianbergmann/phpunit/issues/3422

Regexp to find all uses:

ag 'assert(Not)?Contains\('
This commit is contained in:
Eloy Lafuente (stronk7) 2020-09-01 00:44:13 +02:00
parent 106c64ac24
commit 35bc26b516
113 changed files with 720 additions and 720 deletions

View file

@ -351,7 +351,7 @@ class enrol_lti_helper_testcase extends advanced_testcase {
$tool1 = $generator->create_lti_tool($data);
$description = \enrol_lti\helper::get_description($tool1);
$this->assertContains('Test course 1 Lorem ipsum dolor sit amet', $description);
$this->assertStringContainsString('Test course 1 Lorem ipsum dolor sit amet', $description);
$module1 = $generator->create_module('assign', array(
'course' => $course1->id
@ -360,7 +360,7 @@ class enrol_lti_helper_testcase extends advanced_testcase {
$data->cmid = $module1->cmid;
$tool2 = $generator->create_lti_tool($data);
$description = \enrol_lti\helper::get_description($tool2);
$this->assertContains('Test assign 1', $description);
$this->assertStringContainsString('Test assign 1', $description);
}
/**
@ -377,7 +377,7 @@ class enrol_lti_helper_testcase extends advanced_testcase {
$icon = \enrol_lti\helper::get_icon($tool);
$icon = $icon->out();
// Only local icons are supported by the LTI framework.
$this->assertContains($CFG->wwwroot, $icon);
$this->assertStringContainsString($CFG->wwwroot, $icon);
}
@ -532,8 +532,8 @@ class enrol_lti_helper_testcase extends advanced_testcase {
$tool1 = $this->getDataGenerator()->create_lti_tool($data);
$cartridge = \enrol_lti\helper::create_cartridge($tool1->id);
$this->assertContains('<blti:title>Test LTI</blti:title>', $cartridge);
$this->assertContains("<blti:icon>$CFG->wwwroot/theme/image.php/_s/boost/theme/1/favicon</blti:icon>", $cartridge);
$this->assertContains("<blti:launch_url>$CFG->wwwroot/enrol/lti/tool.php?id=$tool1->id</blti:launch_url>", $cartridge);
$this->assertStringContainsString('<blti:title>Test LTI</blti:title>', $cartridge);
$this->assertStringContainsString("<blti:icon>$CFG->wwwroot/theme/image.php/_s/boost/theme/1/favicon</blti:icon>", $cartridge);
$this->assertStringContainsString("<blti:launch_url>$CFG->wwwroot/enrol/lti/tool.php?id=$tool1->id</blti:launch_url>", $cartridge);
}
}

View file

@ -136,7 +136,7 @@ class sync_members_testcase extends advanced_testcase {
$this->task->execute();
$output = ob_get_clean();
$message = 'Skipping task - ' . get_string('pluginnotenabled', 'auth', get_string('pluginname', 'auth_lti'));
$this->assertContains($message, $output);
$this->assertStringContainsString($message, $output);
}
/**
@ -150,7 +150,7 @@ class sync_members_testcase extends advanced_testcase {
$this->task->execute();
$output = ob_get_clean();
$message = 'Skipping task - ' . get_string('enrolisdisabled', 'enrol_lti');
$this->assertContains($message, $output);
$this->assertStringContainsString($message, $output);
}
/**
@ -168,10 +168,10 @@ class sync_members_testcase extends advanced_testcase {
$output = ob_get_clean();
$membersyncmessage = "Completed - Synced members for tool '{$this->tool->id}' in the course '{$this->tool->courseid}'";
$this->assertContains($membersyncmessage, $output);
$this->assertStringContainsString($membersyncmessage, $output);
$imagesyncmessage = "Completed - Synced 0 profile images.";
$this->assertContains($imagesyncmessage, $output);
$this->assertStringContainsString($imagesyncmessage, $output);
}
/**

View file

@ -148,7 +148,7 @@ class tool_provider_testcase extends advanced_testcase {
$tp->message = $message;
$tp->onError();
$errormessage = get_string('failedrequest', 'enrol_lti', ['reason' => $message]);
$this->assertContains($errormessage, $tp->get_error_output());
$this->assertStringContainsString($errormessage, $tp->get_error_output());
}
/**
@ -256,8 +256,8 @@ class tool_provider_testcase extends advanced_testcase {
$successmessage = get_string('successfulregistration', 'enrol_lti');
// Check output contents. Confirm that it has the success message and return URL.
$this->assertContains($successmessage, $output);
$this->assertContains($tp->returnUrl, $output);
$this->assertStringContainsString($successmessage, $output);
$this->assertStringContainsString($tp->returnUrl, $output);
// The OK flag will be true on successful registration.
$this->assertTrue($tp->ok);
@ -285,7 +285,7 @@ class tool_provider_testcase extends advanced_testcase {
@$tp->onLaunch();
$output = ob_get_clean();
$this->assertContains(get_string('frameembeddingnotenabled', 'enrol_lti'), $output);
$this->assertStringContainsString(get_string('frameembeddingnotenabled', 'enrol_lti'), $output);
}
/**
@ -373,7 +373,7 @@ class tool_provider_testcase extends advanced_testcase {
$this->assertTrue($tp->ok);
$this->assertEquals(get_string('success'), $tp->message);
$this->assertContains(get_string('frameembeddingnotenabled', 'enrol_lti'), $output);
$this->assertStringContainsString(get_string('frameembeddingnotenabled', 'enrol_lti'), $output);
}
/**

View file

@ -431,49 +431,49 @@ class enrol_manual_lib_testcase extends advanced_testcase {
// First individual notifications from course1.
$this->assertEquals($user3->id, $messages[0]->useridto);
$this->assertEquals($user8->id, $messages[0]->useridfrom);
$this->assertContains('xcourse1', $messages[0]->fullmessagehtml);
$this->assertStringContainsString('xcourse1', $messages[0]->fullmessagehtml);
$this->assertEquals($user4->id, $messages[1]->useridto);
$this->assertEquals($user8->id, $messages[1]->useridfrom);
$this->assertContains('xcourse1', $messages[1]->fullmessagehtml);
$this->assertStringContainsString('xcourse1', $messages[1]->fullmessagehtml);
// Then summary for course1.
$this->assertEquals($user8->id, $messages[2]->useridto);
$this->assertEquals($admin->id, $messages[2]->useridfrom);
$this->assertContains('xcourse1', $messages[2]->fullmessagehtml);
$this->assertNotContains('xuser1', $messages[2]->fullmessagehtml);
$this->assertNotContains('xuser2', $messages[2]->fullmessagehtml);
$this->assertContains('xuser3', $messages[2]->fullmessagehtml);
$this->assertContains('xuser4', $messages[2]->fullmessagehtml);
$this->assertContains('xuser5', $messages[2]->fullmessagehtml);
$this->assertNotContains('xuser6', $messages[2]->fullmessagehtml);
$this->assertStringContainsString('xcourse1', $messages[2]->fullmessagehtml);
$this->assertStringNotContainsString('xuser1', $messages[2]->fullmessagehtml);
$this->assertStringNotContainsString('xuser2', $messages[2]->fullmessagehtml);
$this->assertStringContainsString('xuser3', $messages[2]->fullmessagehtml);
$this->assertStringContainsString('xuser4', $messages[2]->fullmessagehtml);
$this->assertStringContainsString('xuser5', $messages[2]->fullmessagehtml);
$this->assertStringNotContainsString('xuser6', $messages[2]->fullmessagehtml);
// First individual notifications from course2.
$this->assertEquals($user3->id, $messages[3]->useridto);
$this->assertEquals($admin->id, $messages[3]->useridfrom);
$this->assertContains('xcourse2', $messages[3]->fullmessagehtml);
$this->assertStringContainsString('xcourse2', $messages[3]->fullmessagehtml);
// Then summary for course2.
$this->assertEquals($admin->id, $messages[4]->useridto);
$this->assertEquals($admin->id, $messages[4]->useridfrom);
$this->assertContains('xcourse2', $messages[4]->fullmessagehtml);
$this->assertNotContains('xuser1', $messages[4]->fullmessagehtml);
$this->assertNotContains('xuser2', $messages[4]->fullmessagehtml);
$this->assertContains('xuser3', $messages[4]->fullmessagehtml);
$this->assertNotContains('xuser4', $messages[4]->fullmessagehtml);
$this->assertNotContains('xuser5', $messages[4]->fullmessagehtml);
$this->assertNotContains('xuser6', $messages[4]->fullmessagehtml);
$this->assertStringContainsString('xcourse2', $messages[4]->fullmessagehtml);
$this->assertStringNotContainsString('xuser1', $messages[4]->fullmessagehtml);
$this->assertStringNotContainsString('xuser2', $messages[4]->fullmessagehtml);
$this->assertStringContainsString('xuser3', $messages[4]->fullmessagehtml);
$this->assertStringNotContainsString('xuser4', $messages[4]->fullmessagehtml);
$this->assertStringNotContainsString('xuser5', $messages[4]->fullmessagehtml);
$this->assertStringNotContainsString('xuser6', $messages[4]->fullmessagehtml);
// Only summary in course3.
$this->assertEquals($user1->id, $messages[5]->useridto);
$this->assertEquals($admin->id, $messages[5]->useridfrom);
$this->assertContains('xcourse3', $messages[5]->fullmessagehtml);
$this->assertNotContains('xuser1', $messages[5]->fullmessagehtml);
$this->assertNotContains('xuser2', $messages[5]->fullmessagehtml);
$this->assertContains('xuser3', $messages[5]->fullmessagehtml);
$this->assertNotContains('xuser4', $messages[5]->fullmessagehtml);
$this->assertNotContains('xuser5', $messages[5]->fullmessagehtml);
$this->assertNotContains('xuser6', $messages[5]->fullmessagehtml);
$this->assertStringContainsString('xcourse3', $messages[5]->fullmessagehtml);
$this->assertStringNotContainsString('xuser1', $messages[5]->fullmessagehtml);
$this->assertStringNotContainsString('xuser2', $messages[5]->fullmessagehtml);
$this->assertStringContainsString('xuser3', $messages[5]->fullmessagehtml);
$this->assertStringNotContainsString('xuser4', $messages[5]->fullmessagehtml);
$this->assertStringNotContainsString('xuser5', $messages[5]->fullmessagehtml);
$this->assertStringNotContainsString('xuser6', $messages[5]->fullmessagehtml);
// Make sure that notifications are not repeated.

View file

@ -394,49 +394,49 @@ class enrol_self_testcase extends advanced_testcase {
// First individual notifications from course1.
$this->assertEquals($user3->id, $messages[0]->useridto);
$this->assertEquals($user8->id, $messages[0]->useridfrom);
$this->assertContains('xcourse1', $messages[0]->fullmessagehtml);
$this->assertStringContainsString('xcourse1', $messages[0]->fullmessagehtml);
$this->assertEquals($user4->id, $messages[1]->useridto);
$this->assertEquals($user8->id, $messages[1]->useridfrom);
$this->assertContains('xcourse1', $messages[1]->fullmessagehtml);
$this->assertStringContainsString('xcourse1', $messages[1]->fullmessagehtml);
// Then summary for course1.
$this->assertEquals($user8->id, $messages[2]->useridto);
$this->assertEquals($admin->id, $messages[2]->useridfrom);
$this->assertContains('xcourse1', $messages[2]->fullmessagehtml);
$this->assertNotContains('xuser1', $messages[2]->fullmessagehtml);
$this->assertNotContains('xuser2', $messages[2]->fullmessagehtml);
$this->assertContains('xuser3', $messages[2]->fullmessagehtml);
$this->assertContains('xuser4', $messages[2]->fullmessagehtml);
$this->assertContains('xuser5', $messages[2]->fullmessagehtml);
$this->assertNotContains('xuser6', $messages[2]->fullmessagehtml);
$this->assertStringContainsString('xcourse1', $messages[2]->fullmessagehtml);
$this->assertStringNotContainsString('xuser1', $messages[2]->fullmessagehtml);
$this->assertStringNotContainsString('xuser2', $messages[2]->fullmessagehtml);
$this->assertStringContainsString('xuser3', $messages[2]->fullmessagehtml);
$this->assertStringContainsString('xuser4', $messages[2]->fullmessagehtml);
$this->assertStringContainsString('xuser5', $messages[2]->fullmessagehtml);
$this->assertStringNotContainsString('xuser6', $messages[2]->fullmessagehtml);
// First individual notifications from course2.
$this->assertEquals($user3->id, $messages[3]->useridto);
$this->assertEquals($admin->id, $messages[3]->useridfrom);
$this->assertContains('xcourse2', $messages[3]->fullmessagehtml);
$this->assertStringContainsString('xcourse2', $messages[3]->fullmessagehtml);
// Then summary for course2.
$this->assertEquals($admin->id, $messages[4]->useridto);
$this->assertEquals($admin->id, $messages[4]->useridfrom);
$this->assertContains('xcourse2', $messages[4]->fullmessagehtml);
$this->assertNotContains('xuser1', $messages[4]->fullmessagehtml);
$this->assertNotContains('xuser2', $messages[4]->fullmessagehtml);
$this->assertContains('xuser3', $messages[4]->fullmessagehtml);
$this->assertNotContains('xuser4', $messages[4]->fullmessagehtml);
$this->assertNotContains('xuser5', $messages[4]->fullmessagehtml);
$this->assertNotContains('xuser6', $messages[4]->fullmessagehtml);
$this->assertStringContainsString('xcourse2', $messages[4]->fullmessagehtml);
$this->assertStringNotContainsString('xuser1', $messages[4]->fullmessagehtml);
$this->assertStringNotContainsString('xuser2', $messages[4]->fullmessagehtml);
$this->assertStringContainsString('xuser3', $messages[4]->fullmessagehtml);
$this->assertStringNotContainsString('xuser4', $messages[4]->fullmessagehtml);
$this->assertStringNotContainsString('xuser5', $messages[4]->fullmessagehtml);
$this->assertStringNotContainsString('xuser6', $messages[4]->fullmessagehtml);
// Only summary in course3.
$this->assertEquals($user1->id, $messages[5]->useridto);
$this->assertEquals($admin->id, $messages[5]->useridfrom);
$this->assertContains('xcourse3', $messages[5]->fullmessagehtml);
$this->assertNotContains('xuser1', $messages[5]->fullmessagehtml);
$this->assertNotContains('xuser2', $messages[5]->fullmessagehtml);
$this->assertContains('xuser3', $messages[5]->fullmessagehtml);
$this->assertNotContains('xuser4', $messages[5]->fullmessagehtml);
$this->assertNotContains('xuser5', $messages[5]->fullmessagehtml);
$this->assertNotContains('xuser6', $messages[5]->fullmessagehtml);
$this->assertStringContainsString('xcourse3', $messages[5]->fullmessagehtml);
$this->assertStringNotContainsString('xuser1', $messages[5]->fullmessagehtml);
$this->assertStringNotContainsString('xuser2', $messages[5]->fullmessagehtml);
$this->assertStringContainsString('xuser3', $messages[5]->fullmessagehtml);
$this->assertStringNotContainsString('xuser4', $messages[5]->fullmessagehtml);
$this->assertStringNotContainsString('xuser5', $messages[5]->fullmessagehtml);
$this->assertStringNotContainsString('xuser6', $messages[5]->fullmessagehtml);
// Make sure that notifications are not repeated.
@ -616,7 +616,7 @@ class enrol_self_testcase extends advanced_testcase {
$selfplugin->enrol_user($instance1, $user2->id, $editingteacherrole->id);
$this->setUser($guest);
$this->assertContains(get_string('noguestaccess', 'enrol'),
$this->assertStringContainsString(get_string('noguestaccess', 'enrol'),
$selfplugin->can_self_enrol($instance1, true));
$this->setUser($user1);