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

@ -2480,7 +2480,7 @@ class core_course_courselib_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\course_module_created to be triggered without
other['instanceid']");
} catch (coding_exception $e) {
$this->assertContains("The 'instanceid' value must be set in other.", $e->getMessage());
$this->assertStringContainsString("The 'instanceid' value must be set in other.", $e->getMessage());
}
// Test not setting modulename.
@ -2497,7 +2497,7 @@ class core_course_courselib_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\course_module_created to be triggered without
other['modulename']");
} catch (coding_exception $e) {
$this->assertContains("The 'modulename' value must be set in other.", $e->getMessage());
$this->assertStringContainsString("The 'modulename' value must be set in other.", $e->getMessage());
}
// Test not setting name.
@ -2515,7 +2515,7 @@ class core_course_courselib_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\course_module_created to be triggered without
other['name']");
} catch (coding_exception $e) {
$this->assertContains("The 'name' value must be set in other.", $e->getMessage());
$this->assertStringContainsString("The 'name' value must be set in other.", $e->getMessage());
}
}
@ -2640,7 +2640,7 @@ class core_course_courselib_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\course_module_updated to be triggered without
other['instanceid']");
} catch (coding_exception $e) {
$this->assertContains("The 'instanceid' value must be set in other.", $e->getMessage());
$this->assertStringContainsString("The 'instanceid' value must be set in other.", $e->getMessage());
}
// Test not setting modulename.
@ -2657,7 +2657,7 @@ class core_course_courselib_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\course_module_updated to be triggered without
other['modulename']");
} catch (coding_exception $e) {
$this->assertContains("The 'modulename' value must be set in other.", $e->getMessage());
$this->assertStringContainsString("The 'modulename' value must be set in other.", $e->getMessage());
}
// Test not setting name.
@ -2675,7 +2675,7 @@ class core_course_courselib_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\course_module_updated to be triggered without
other['name']");
} catch (coding_exception $e) {
$this->assertContains("The 'name' value must be set in other.", $e->getMessage());
$this->assertStringContainsString("The 'name' value must be set in other.", $e->getMessage());
}
}
@ -2743,7 +2743,7 @@ class core_course_courselib_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\course_module_deleted to be triggered without
other['instanceid']");
} catch (coding_exception $e) {
$this->assertContains("The 'instanceid' value must be set in other.", $e->getMessage());
$this->assertStringContainsString("The 'instanceid' value must be set in other.", $e->getMessage());
}
// Test not setting modulename.
@ -2760,7 +2760,7 @@ class core_course_courselib_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\course_module_deleted to be triggered without
other['modulename']");
} catch (coding_exception $e) {
$this->assertContains("The 'modulename' value must be set in other.", $e->getMessage());
$this->assertStringContainsString("The 'modulename' value must be set in other.", $e->getMessage());
}
}

View file

@ -622,7 +622,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
$warning = reset($result['warnings']);
$this->assertEquals('errorinvalidparam', $warning['warningcode']);
$this->assertContains($expectedemptyfield, $warning['message']);
$this->assertStringContainsString($expectedemptyfield, $warning['message']);
}
/**
@ -1111,7 +1111,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
$this->assertEquals($formattedtext, $module['description']);
$this->assertEquals($forumcm->instance, $module['instance']);
$this->assertEquals(context_module::instance($forumcm->id)->id, $module['contextid']);
$this->assertContains('1 unread post', $module['afterlink']);
$this->assertStringContainsString('1 unread post', $module['afterlink']);
$this->assertFalse($module['noviewlink']);
$this->assertNotEmpty($module['description']); // Module showdescription is on.
$testexecuted = $testexecuted + 2;
@ -1126,7 +1126,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
$this->assertNotEmpty($module['description']); // Label always prints the description.
$testexecuted = $testexecuted + 1;
} else if ($module['id'] == $datacm->id and $module['modname'] == 'data') {
$this->assertContains('customcompletionrules', $module['customdata']);
$this->assertStringContainsString('customcompletionrules', $module['customdata']);
$this->assertFalse($module['noviewlink']);
$this->assertArrayNotHasKey('description', $module);
$testexecuted = $testexecuted + 1;
@ -1134,7 +1134,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
}
foreach ($sections[2]['modules'] as $module) {
if ($module['id'] == $urlcm->id and $module['modname'] == 'url') {
$this->assertContains('width=100,height=100', $module['onclick']);
$this->assertStringContainsString('width=100,height=100', $module['onclick']);
$testexecuted = $testexecuted + 1;
}
}
@ -1155,8 +1155,8 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
$this->assertEquals(2, $sections[2]['section']);
$this->assertEquals(3, $sections[3]['section']);
$this->assertEquals(4, $sections[4]['section']);
$this->assertContains('<iframe', $sections[2]['summary']);
$this->assertContains('</iframe>', $sections[2]['summary']);
$this->assertStringContainsString('<iframe', $sections[2]['summary']);
$this->assertStringContainsString('</iframe>', $sections[2]['summary']);
$this->assertNotEmpty($sections[2]['modules'][0]['availabilityinfo']);
try {
$sections = core_course_external::get_course_contents($course->id,