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

@ -304,7 +304,7 @@ class pgsql_native_recordset_testcase extends basic_testcase {
$transaction->rollback(new dml_transaction_exception('rollback please'));
$this->fail('should not get here');
} catch (dml_transaction_exception $e) {
$this->assertContains('rollback please', $e->getMessage());
$this->assertStringContainsString('rollback please', $e->getMessage());
} finally {
// Rollback should not kill our recordset.

View file

@ -464,7 +464,7 @@ class core_files_zip_packer_testcase extends advanced_testcase implements file_p
} catch (Exception $e) {
// New PHP versions print PHP Warning.
$this->assertInstanceOf('PHPUnit\Framework\Error\Warning', $e);
$this->assertContains('ZipArchive::close', $e->getMessage());
$this->assertStringContainsString('ZipArchive::close', $e->getMessage());
}
// This is crazy, but it shows how some PHP versions do return true.
try {

View file

@ -53,12 +53,12 @@ class core_form_course_testcase extends basic_testcase {
$element = new MoodleQuickForm_course('testel', null, $attributes);
$html = $element->toHtml();
$this->assertContains('data-exclude="1,2"', $html);
$this->assertContains('data-requiredcapabilities="moodle/course:update"', $html);
$this->assertContains('data-limittoenrolled="0"', $html);
$this->assertNotContains('multiple', $html);
$this->assertNotContains('data-includefrontpage', $html);
$this->assertNotContains('data-onlywithcompletion', $html);
$this->assertStringContainsString('data-exclude="1,2"', $html);
$this->assertStringContainsString('data-requiredcapabilities="moodle/course:update"', $html);
$this->assertStringContainsString('data-limittoenrolled="0"', $html);
$this->assertStringNotContainsString('multiple', $html);
$this->assertStringNotContainsString('data-includefrontpage', $html);
$this->assertStringNotContainsString('data-onlywithcompletion', $html);
// Add more attributes.
$attributes = [
@ -69,9 +69,9 @@ class core_form_course_testcase extends basic_testcase {
];
$element = new MoodleQuickForm_course('testel', null, $attributes);
$html = $element->toHtml();
$this->assertContains('multiple', $html);
$this->assertContains('data-limittoenrolled="1"', $html);
$this->assertContains('data-includefrontpage="' . SITEID . '"', $html);
$this->assertContains('data-onlywithcompletion="1"', $html);
$this->assertStringContainsString('multiple', $html);
$this->assertStringContainsString('data-limittoenrolled="1"', $html);
$this->assertStringContainsString('data-includefrontpage="' . SITEID . '"', $html);
$this->assertStringContainsString('data-onlywithcompletion="1"', $html);
}
}

View file

@ -81,9 +81,9 @@ class core_form_duration_testcase extends basic_testcase {
$mform->addElement('duration', 'testel', null, ['units' => [MINSECS, 1], 'optional' => false]);
$html = $mform->toHtml();
$html = preg_replace('~ +>~', '>', $html); // Clean HTML to avoid spurious errors.
$this->assertContains('<option value="60" selected>minutes</option>', $html);
$this->assertContains('<option value="1">seconds</option>', $html);
$this->assertNotContains('value="3600"', $html);
$this->assertStringContainsString('<option value="60" selected>minutes</option>', $html);
$this->assertStringContainsString('<option value="1">seconds</option>', $html);
$this->assertStringNotContainsString('value="3600"', $html);
}
/**

View file

@ -129,9 +129,9 @@ class filetypes_util_testcase extends advanced_testcase {
$this->assertEquals('.mudrd8mz', $desc[0]->extensions);
$this->assertEquals('Image (JPEG)', $desc[2]->description);
$this->assertContains('.jpg', $desc[2]->extensions);
$this->assertContains('.jpeg', $desc[2]->extensions);
$this->assertContains('.jpe', $desc[2]->extensions);
$this->assertStringContainsString('.jpg', $desc[2]->extensions);
$this->assertStringContainsString('.jpeg', $desc[2]->extensions);
$this->assertStringContainsString('.jpe', $desc[2]->extensions);
// Check that it can describe groups and mimetypes too.
$desc = $util->describe_file_types('audio text/plain');
@ -141,12 +141,12 @@ class filetypes_util_testcase extends advanced_testcase {
$this->assertEquals(2, count($desc));
$this->assertEquals('Audio files', $desc[0]->description);
$this->assertContains('.mp3', $desc[0]->extensions);
$this->assertContains('.wav', $desc[0]->extensions);
$this->assertContains('.ogg', $desc[0]->extensions);
$this->assertStringContainsString('.mp3', $desc[0]->extensions);
$this->assertStringContainsString('.wav', $desc[0]->extensions);
$this->assertStringContainsString('.ogg', $desc[0]->extensions);
$this->assertEquals('Text file', $desc[1]->description);
$this->assertContains('.txt', $desc[1]->extensions);
$this->assertStringContainsString('.txt', $desc[1]->extensions);
// Empty.
$desc = $util->describe_file_types('');

View file

@ -69,7 +69,7 @@ class core_form_privacy_provider_testcase extends \core_privacy\tests\provider_t
$this->assertNotEmpty($prefs->filemanager_recentviewmode->value);
$this->assertNotEmpty($prefs->filemanager_recentviewmode->description);
$this->assertEquals($val, $prefs->filemanager_recentviewmode->value);
$this->assertContains($desc, $prefs->filemanager_recentviewmode->description);
$this->assertStringContainsString($desc, $prefs->filemanager_recentviewmode->description);
}
/**

View file

@ -235,9 +235,9 @@ class core_phpunit_advanced_testcase extends advanced_testcase {
self::resetAllData(true);
} catch (Exception $e) {
$this->assertInstanceOf('PHPUnit\Framework\Error\Warning', $e);
$this->assertContains('xx', $e->getMessage());
$this->assertContains('admin', $e->getMessage());
$this->assertContains('rolesactive', $e->getMessage());
$this->assertStringContainsString('xx', $e->getMessage());
$this->assertStringContainsString('admin', $e->getMessage());
$this->assertStringContainsString('rolesactive', $e->getMessage());
}
$this->assertFalse(isset($CFG->xx));
$this->assertTrue(isset($CFG->admin));

View file

@ -97,7 +97,7 @@ class core_antivirus_testcase extends advanced_testcase {
$this->assertNotEmpty($exception);
$result = $sink->get_messages();
$this->assertCount(1, $result);
$this->assertContains('fake@example.com', $result[0]->to);
$this->assertStringContainsString('fake@example.com', $result[0]->to);
$sink->close();
}
@ -174,7 +174,7 @@ class core_antivirus_testcase extends advanced_testcase {
$this->assertNotEmpty($exception);
$result = $sink->get_messages();
$this->assertCount(1, $result);
$this->assertContains('fake@example.com', $result[0]->to);
$this->assertStringContainsString('fake@example.com', $result[0]->to);
$sink->close();
}

View file

@ -457,7 +457,7 @@ class core_authlib_testcase extends advanced_testcase {
];
$errors = signup_validate_data($formdata, []);
$this->assertContains('This email address is already registered.', $errors['email']);
$this->assertStringContainsString('This email address is already registered.', $errors['email']);
// Emails are accent-sensitive though so if we change a -> á in the u1's email, it should pass.
// Please note that Moodle does not normally support such emails yet. We test the DB search sensitivity here.

View file

@ -1001,7 +1001,7 @@ class core_completionlib_testcase extends advanced_testcase {
$this->assertEquals($this->user->id, $message->useridto);
$this->assertEquals('coursecompleted', $message->eventtype);
$this->assertEquals(get_string('coursecompleted', 'completion'), $message->subject);
$this->assertContains($this->course->fullname, $message->fullmessage);
$this->assertStringContainsString($this->course->fullname, $message->fullmessage);
}
/**

View file

@ -150,14 +150,14 @@ class core_media_player_native_testcase extends advanced_testcase {
$content = $player->embed($urls, $title, 0, 0, []);
// Test sources present.
$this->assertContains('<source src="http://example.org/some_filename.mp4" />', $content);
$this->assertContains('<source src="http://example.org/some_filename_hires.mp4" />', $content);
$this->assertStringContainsString('<source src="http://example.org/some_filename.mp4" />', $content);
$this->assertStringContainsString('<source src="http://example.org/some_filename_hires.mp4" />', $content);
// Change sources.
$newsource = '<source src="http://example.org/new_filename.mp4" />';
$content = media_test_native_plugin::replace_sources($content, $newsource);
$this->assertContains($newsource, $content);
$this->assertNotContains('<source src="http://example.org/some_filename.mp4" />', $content);
$this->assertNotContains('<source src="http://example.org/some_filename_hires.mp4" />', $content);
$this->assertStringContainsString($newsource, $content);
$this->assertStringNotContainsString('<source src="http://example.org/some_filename.mp4" />', $content);
$this->assertStringNotContainsString('<source src="http://example.org/some_filename_hires.mp4" />', $content);
}
}

View file

@ -453,10 +453,10 @@ class core_renderer_template_exploit_testcase extends advanced_testcase {
if ($include) {
// Confirm that the JS was added to the page.
$this->assertContains($js, $page->requires->get_end_code());
$this->assertStringContainsString($js, $page->requires->get_end_code());
} else {
// Confirm that the JS wasn't added to the page.
$this->assertNotContains($js, $page->requires->get_end_code());
$this->assertStringNotContainsString($js, $page->requires->get_end_code());
}
}
}

View file

@ -80,7 +80,7 @@ class core_event_course_module_viewed_testcase extends advanced_testcase {
'courseid' => 2,
'objectid' => 3 ));
} catch (coding_exception $e) {
$this->assertContains("course_module_viewed event must define objectid and object table.", $e->getMessage());
$this->assertStringContainsString("course_module_viewed event must define objectid and object table.", $e->getMessage());
}
try {
@ -89,7 +89,7 @@ class core_event_course_module_viewed_testcase extends advanced_testcase {
'courseid' => 2,
));
} catch (coding_exception $e) {
$this->assertContains("course_module_viewed event must define objectid and object table.", $e->getMessage());
$this->assertStringContainsString("course_module_viewed event must define objectid and object table.", $e->getMessage());
}
}
}

View file

@ -273,7 +273,7 @@ class core_externallib_testcase extends advanced_testcase {
$cleanedvalue = external_api::clean_returnvalue($returndesc, $testdata);
} catch (moodle_exception $e) {
$this->assertInstanceOf('invalid_response_exception', $e);
$this->assertContains('of PHP type "NULL"', $e->debuginfo);
$this->assertStringContainsString('of PHP type "NULL"', $e->debuginfo);
}
}

View file

@ -1113,7 +1113,7 @@ EOF;
// Do the rewrite.
$finaltext = file_rewrite_pluginfile_urls($originaltext, 'pluginfile.php', $syscontext->id, 'user', 'private', 0);
$this->assertContains("pluginfile.php", $finaltext);
$this->assertStringContainsString("pluginfile.php", $finaltext);
// Now undo.
$options = array('reverse' => true);

View file

@ -64,8 +64,8 @@ class core_filetypes_testcase extends advanced_testcase {
core_filetypes::add_type('frog', 'application/x-frog', 'document');
$this->fail();
} catch (coding_exception $e) {
$this->assertContains('already exists', $e->getMessage());
$this->assertContains('frog', $e->getMessage());
$this->assertStringContainsString('already exists', $e->getMessage());
$this->assertStringContainsString('frog', $e->getMessage());
}
// Test bogus extension causes exception.
@ -73,14 +73,14 @@ class core_filetypes_testcase extends advanced_testcase {
core_filetypes::add_type('.frog', 'application/x-frog', 'document');
$this->fail();
} catch (coding_exception $e) {
$this->assertContains('Invalid extension', $e->getMessage());
$this->assertContains('..frog', $e->getMessage());
$this->assertStringContainsString('Invalid extension', $e->getMessage());
$this->assertStringContainsString('..frog', $e->getMessage());
}
try {
core_filetypes::add_type('', 'application/x-frog', 'document');
$this->fail();
} catch (coding_exception $e) {
$this->assertContains('Invalid extension', $e->getMessage());
$this->assertStringContainsString('Invalid extension', $e->getMessage());
}
// Test there is an exception if you add something with defaulticon when
@ -90,8 +90,8 @@ class core_filetypes_testcase extends advanced_testcase {
array(), '', '', true);
$this->fail();
} catch (coding_exception $e) {
$this->assertContains('default icon set', $e->getMessage());
$this->assertContains('text/plain', $e->getMessage());
$this->assertStringContainsString('default icon set', $e->getMessage());
$this->assertStringContainsString('text/plain', $e->getMessage());
}
}
@ -122,8 +122,8 @@ class core_filetypes_testcase extends advanced_testcase {
core_filetypes::update_type('doc', 'doc', 'application/x-frog', 'document');
$this->fail();
} catch (coding_exception $e) {
$this->assertContains('not found', $e->getMessage());
$this->assertContains('doc', $e->getMessage());
$this->assertStringContainsString('not found', $e->getMessage());
$this->assertStringContainsString('doc', $e->getMessage());
}
// Test bogus extension causes exception.
@ -131,14 +131,14 @@ class core_filetypes_testcase extends advanced_testcase {
core_filetypes::update_type('docccc', '.frog', 'application/x-frog', 'document');
$this->fail();
} catch (coding_exception $e) {
$this->assertContains('Invalid extension', $e->getMessage());
$this->assertContains('.frog', $e->getMessage());
$this->assertStringContainsString('Invalid extension', $e->getMessage());
$this->assertStringContainsString('.frog', $e->getMessage());
}
try {
core_filetypes::update_type('docccc', '', 'application/x-frog', 'document');
$this->fail();
} catch (coding_exception $e) {
$this->assertContains('Invalid extension', $e->getMessage());
$this->assertStringContainsString('Invalid extension', $e->getMessage());
}
// Test defaulticon changes.
@ -147,8 +147,8 @@ class core_filetypes_testcase extends advanced_testcase {
array(), '', '', true);
$this->fail();
} catch (coding_exception $e) {
$this->assertContains('default icon set', $e->getMessage());
$this->assertContains('text/plain', $e->getMessage());
$this->assertStringContainsString('default icon set', $e->getMessage());
$this->assertStringContainsString('text/plain', $e->getMessage());
}
}
@ -169,8 +169,8 @@ class core_filetypes_testcase extends advanced_testcase {
core_filetypes::delete_type('doc');
$this->fail();
} catch (coding_exception $e) {
$this->assertContains('not found', $e->getMessage());
$this->assertContains('doc', $e->getMessage());
$this->assertStringContainsString('not found', $e->getMessage());
$this->assertStringContainsString('doc', $e->getMessage());
}
// Try a custom type (slightly different).
@ -204,8 +204,8 @@ class core_filetypes_testcase extends advanced_testcase {
core_filetypes::revert_type_to_default('frog');
$this->fail();
} catch (coding_exception $e) {
$this->assertContains('not a default type', $e->getMessage());
$this->assertContains('frog', $e->getMessage());
$this->assertStringContainsString('not a default type', $e->getMessage());
$this->assertStringContainsString('frog', $e->getMessage());
}
}

View file

@ -994,29 +994,29 @@ class core_grouplib_testcase extends advanced_testcase {
// Now user can access one of the group. We can't assert an exact match here because of random ids generated by yui. So do
// partial match to see if all groups are listed or not.
$html = groups_allgroups_course_menu($course, 'someurl.php');
$this->assertContains(format_string($group1->name), $html);
$this->assertNotContains(format_string($group2->name), $html);
$this->assertStringContainsString(format_string($group1->name), $html);
$this->assertStringNotContainsString(format_string($group2->name), $html);
$this->setAdminUser();
// Now user can access everything.
$html = groups_allgroups_course_menu($course, 'someurl.php');
$this->assertContains(format_string($group1->name), $html);
$this->assertContains(format_string($group2->name), $html);
$this->assertStringContainsString(format_string($group1->name), $html);
$this->assertStringContainsString(format_string($group2->name), $html);
// Make sure separate groups mode, doesn't change anything.
$course->groupmode = SEPARATEGROUPS;
update_course($course);
$html = groups_allgroups_course_menu($course, 'someurl.php');
$this->assertContains(format_string($group1->name), $html);
$this->assertContains(format_string($group2->name), $html);
$this->assertStringContainsString(format_string($group1->name), $html);
$this->assertStringContainsString(format_string($group2->name), $html);
// Make sure Visible groups mode, doesn't change anything.
$course->groupmode = VISIBLEGROUPS;
update_course($course);
$html = groups_allgroups_course_menu($course, 'someurl.php');
$this->assertContains(format_string($group1->name), $html);
$this->assertContains(format_string($group2->name), $html);
$this->assertStringContainsString(format_string($group1->name), $html);
$this->assertStringContainsString(format_string($group2->name), $html);
// Let us test activegroup changes now.
$this->setUser($user);

View file

@ -215,7 +215,7 @@ class core_medialib_testcase extends advanced_testcase {
\core\plugininfo\media::set_enabled_plugins('');
$manager = core_media_manager::instance();
$t = $manager->embed_url($url);
$this->assertContains($link, $t);
$this->assertStringContainsString($link, $t);
// Enable media players that can play the same media formats. (ie. test & html5audio for mp3 files, etc.)
\core\plugininfo\media::set_enabled_plugins('test,html5video,html5audio,swf');
@ -231,31 +231,31 @@ class core_medialib_testcase extends advanced_testcase {
switch ($format) {
case 'mp3':
$this->assertContains($test, $textwithlink);
$this->assertNotContains($html5video, $textwithlink);
$this->assertContains($html5audio, $textwithlink);
$this->assertNotContains($swf, $textwithlink);
$this->assertContains($link, $textwithlink);
$this->assertStringContainsString($test, $textwithlink);
$this->assertStringNotContainsString($html5video, $textwithlink);
$this->assertStringContainsString($html5audio, $textwithlink);
$this->assertStringNotContainsString($swf, $textwithlink);
$this->assertStringContainsString($link, $textwithlink);
$this->assertContains($test, $textwithoutlink);
$this->assertNotContains($html5video, $textwithoutlink);
$this->assertContains($html5audio, $textwithoutlink);
$this->assertNotContains($swf, $textwithoutlink);
$this->assertNotContains($link, $textwithoutlink);
$this->assertStringContainsString($test, $textwithoutlink);
$this->assertStringNotContainsString($html5video, $textwithoutlink);
$this->assertStringContainsString($html5audio, $textwithoutlink);
$this->assertStringNotContainsString($swf, $textwithoutlink);
$this->assertStringNotContainsString($link, $textwithoutlink);
break;
case 'mp4':
$this->assertContains($test, $textwithlink);
$this->assertContains($html5video, $textwithlink);
$this->assertNotContains($html5audio, $textwithlink);
$this->assertNotContains($swf, $textwithlink);
$this->assertContains($link, $textwithlink);
$this->assertStringContainsString($test, $textwithlink);
$this->assertStringContainsString($html5video, $textwithlink);
$this->assertStringNotContainsString($html5audio, $textwithlink);
$this->assertStringNotContainsString($swf, $textwithlink);
$this->assertStringContainsString($link, $textwithlink);
$this->assertContains($test, $textwithoutlink);
$this->assertContains($html5video, $textwithoutlink);
$this->assertNotContains($html5audio, $textwithoutlink);
$this->assertNotContains($swf, $textwithoutlink);
$this->assertNotContains($link, $textwithoutlink);
$this->assertStringContainsString($test, $textwithoutlink);
$this->assertStringContainsString($html5video, $textwithoutlink);
$this->assertStringNotContainsString($html5audio, $textwithoutlink);
$this->assertStringNotContainsString($swf, $textwithoutlink);
$this->assertStringNotContainsString($link, $textwithoutlink);
break;
default:
@ -275,12 +275,12 @@ class core_medialib_testcase extends advanced_testcase {
// Without any options...
$url = new moodle_url('http://example.org/test.swf');
$t = $manager->embed_url($url);
$this->assertNotContains('</object>', $t);
$this->assertStringNotContainsString('</object>', $t);
// ...and with the 'no it's safe, I checked it' option.
$url = new moodle_url('http://example.org/test.swf');
$t = $manager->embed_url($url, '', 0, 0, array(core_media_manager::OPTION_TRUSTED => true));
$this->assertContains('</object>', $t);
$this->assertStringContainsString('</object>', $t);
}
/**
@ -299,7 +299,7 @@ class core_medialib_testcase extends advanced_testcase {
// Format: mp3.
$url = new moodle_url('http://example.org/pluginfile.php?file=x/y/z/test.mp3');
$t = $manager->embed_url($url);
$this->assertContains('</audio>', $t);
$this->assertStringContainsString('</audio>', $t);
}
/**
@ -316,8 +316,8 @@ class core_medialib_testcase extends advanced_testcase {
// Embed that does match something should still include the link too.
$url = new moodle_url('http://example.org/test.ogg');
$t = $manager->embed_url($url, '', 0, 0, $options);
$this->assertContains('</audio>', $t);
$this->assertContains('mediafallbacklink', $t);
$this->assertStringContainsString('</audio>', $t);
$this->assertStringContainsString('mediafallbacklink', $t);
// Embed that doesn't match something should be totally blank.
$url = new moodle_url('http://example.org/test.mp4');
@ -343,19 +343,19 @@ class core_medialib_testcase extends advanced_testcase {
// HTML5 default size - specifies core width and does not specify height.
$t = $manager->embed_url($url);
$this->assertContains('width="' . $CFG->media_default_width . '"', $t);
$this->assertNotContains('height', $t);
$this->assertStringContainsString('width="' . $CFG->media_default_width . '"', $t);
$this->assertStringNotContainsString('height', $t);
// HTML5 specified size - specifies both.
$t = $manager->embed_url($url, '', '666', '101');
$this->assertContains('width="666"', $t);
$this->assertContains('height="101"', $t);
$this->assertStringContainsString('width="666"', $t);
$this->assertStringContainsString('height="101"', $t);
// HTML5 size specified in url, overrides call.
$url = new moodle_url('http://example.org/test.mp4?d=123x456');
$t = $manager->embed_url($url, '', '666', '101');
$this->assertContains('width="123"', $t);
$this->assertContains('height="456"', $t);
$this->assertStringContainsString('width="123"', $t);
$this->assertStringContainsString('height="456"', $t);
}
/**
@ -372,11 +372,11 @@ class core_medialib_testcase extends advanced_testcase {
// HTML5 default name - use filename.
$t = $manager->embed_url($url);
$this->assertContains('title="test.mp4"', $t);
$this->assertStringContainsString('title="test.mp4"', $t);
// HTML5 specified name - check escaping.
$t = $manager->embed_url($url, 'frog & toad');
$this->assertContains('title="frog &amp; toad"', $t);
$this->assertStringContainsString('title="frog &amp; toad"', $t);
}
/**
@ -439,10 +439,10 @@ class core_medialib_testcase extends advanced_testcase {
$t = $manager->embed_alternatives($urls);
// HTML5 sources - mp4, but not ogv, flv or webm (not supported in Safari).
$this->assertContains('<source src="http://example.org/test.mp4"', $t);
$this->assertNotContains('<source src="http://example.org/test.ogv"', $t);
$this->assertNotContains('<source src="http://example.org/test.webm"', $t);
$this->assertNotContains('<source src="http://example.org/test.flv"', $t);
$this->assertStringContainsString('<source src="http://example.org/test.mp4"', $t);
$this->assertStringNotContainsString('<source src="http://example.org/test.ogv"', $t);
$this->assertStringNotContainsString('<source src="http://example.org/test.webm"', $t);
$this->assertStringNotContainsString('<source src="http://example.org/test.flv"', $t);
// FLV is before the video tag (indicating html5 is used as fallback to flv
// and not vice versa).
@ -453,10 +453,10 @@ class core_medialib_testcase extends advanced_testcase {
$t = $manager->embed_alternatives($urls);
// HTML5 sources - mp4, ogv and webm, but not flv.
$this->assertContains('<source src="http://example.org/test.mp4"', $t);
$this->assertContains('<source src="http://example.org/test.ogv"', $t);
$this->assertContains('<source src="http://example.org/test.webm"', $t);
$this->assertNotContains('<source src="http://example.org/test.flv"', $t);
$this->assertStringContainsString('<source src="http://example.org/test.mp4"', $t);
$this->assertStringContainsString('<source src="http://example.org/test.ogv"', $t);
$this->assertStringContainsString('<source src="http://example.org/test.webm"', $t);
$this->assertStringNotContainsString('<source src="http://example.org/test.flv"', $t);
}
/**

View file

@ -220,7 +220,7 @@ class core_messagelib_testcase extends advanced_testcase {
$this->assertEquals($message->smallmessage, $savedmessage->smallmessage);
$this->assertEquals($message->notification, $savedmessage->notification);
$this->assertEquals($message->customdata, $savedmessage->customdata);
$this->assertContains('datakey', $savedmessage->customdata);
$this->assertStringContainsString('datakey', $savedmessage->customdata);
// Check it was a unserialisable json.
$customdata = json_decode($savedmessage->customdata);
$this->assertEquals('data', $customdata->datakey);

View file

@ -87,7 +87,7 @@ function hm()
$js = "function hm{}";
$result = core_minify::js($js);
$this->assertContains($js, $result);
$this->assertStringContainsString($js, $result);
}
public function test_js_files() {

View file

@ -806,7 +806,7 @@ class core_modinfolib_testcase extends advanced_testcase {
get_course_and_cm_from_cmid($page->cmid, 'pigs can fly');
$this->fail();
} catch (coding_exception $e) {
$this->assertContains('Invalid modulename parameter', $e->getMessage());
$this->assertStringContainsString('Invalid modulename parameter', $e->getMessage());
}
// Doesn't exist.
@ -895,7 +895,7 @@ class core_modinfolib_testcase extends advanced_testcase {
get_course_and_cm_from_cmid($page->cmid, '1337 h4x0ring');
$this->fail();
} catch (coding_exception $e) {
$this->assertContains('Invalid modulename parameter', $e->getMessage());
$this->assertStringContainsString('Invalid modulename parameter', $e->getMessage());
}
// Create a second hidden activity.

View file

@ -3239,8 +3239,8 @@ class core_moodlelib_testcase extends advanced_testcase {
$emails = $sink->get_messages();
$this->assertCount(1, $emails);
$email = reset($emails);
$this->assertContains('X-Custom-Header: foo', $email->header);
$this->assertContains("X-Fixed-Header: bar", $email->header);
$this->assertStringContainsString('X-Custom-Header: foo', $email->header);
$this->assertStringContainsString("X-Fixed-Header: bar", $email->header);
$sink->clear();
}
@ -3381,13 +3381,13 @@ class core_moodlelib_testcase extends advanced_testcase {
$this->assertSame($messagetext, trim($result[0]->body));
$this->assertSame($user1->email, $result[0]->to);
$this->assertSame($user2->email, $result[0]->from);
$this->assertContains('Content-Type: text/plain', $result[0]->header);
$this->assertStringContainsString('Content-Type: text/plain', $result[0]->header);
$this->assertSame($subject2, $result[1]->subject);
$this->assertContains($messagetext2, quoted_printable_decode($result[1]->body));
$this->assertStringContainsString($messagetext2, quoted_printable_decode($result[1]->body));
$this->assertSame($user2->email, $result[1]->to);
$this->assertSame($user1->email, $result[1]->from);
$this->assertNotContains('Content-Type: text/plain', $result[1]->header);
$this->assertStringNotContainsString('Content-Type: text/plain', $result[1]->header);
email_to_user($user1, $user2, $subject, $messagetext);
$this->assertDebuggingCalled('Unit tests must not send real emails! Use $this->redirectEmails()');
@ -3426,8 +3426,8 @@ class core_moodlelib_testcase extends advanced_testcase {
$this->assertSame(1, $sink->count());
$result = $sink->get_messages();
$this->assertCount(1, $result);
$this->assertContains('error.txt', $result[0]->body);
$this->assertContains('Error in attachment. User attempted to attach a filename with a unsafe name.', $result[0]->body);
$this->assertStringContainsString('error.txt', $result[0]->body);
$this->assertStringContainsString('Error in attachment. User attempted to attach a filename with a unsafe name.', $result[0]->body);
$sink->close();
}
@ -3483,8 +3483,8 @@ class core_moodlelib_testcase extends advanced_testcase {
// Verify attachment in message body (attachment is in MIME format, but we can detect some Content fields).
$messagebody = reset($messages)->body;
$this->assertContains('Content-Type: text/plain; name="' . $filename . '"', $messagebody);
$this->assertContains('Content-Disposition: attachment; filename=' . $filename, $messagebody);
$this->assertStringContainsString('Content-Type: text/plain; name="' . $filename . '"', $messagebody);
$this->assertStringContainsString('Content-Disposition: attachment; filename=' . $filename, $messagebody);
// Cleanup.
unlink($filepath);
@ -3511,8 +3511,8 @@ class core_moodlelib_testcase extends advanced_testcase {
// Verify attachment not in message body (attachment is in MIME format, but we can detect some Content fields).
$messagebody = reset($messages)->body;
$this->assertNotContains('Content-Type: text/plain; name="' . $filename . '"', $messagebody);
$this->assertNotContains('Content-Disposition: attachment; filename=' . $filename, $messagebody);
$this->assertStringNotContainsString('Content-Type: text/plain; name="' . $filename . '"', $messagebody);
$this->assertStringNotContainsString('Content-Disposition: attachment; filename=' . $filename, $messagebody);
}
/**
@ -3651,7 +3651,7 @@ class core_moodlelib_testcase extends advanced_testcase {
$message = array_shift($messages);
$messagebody = quoted_printable_decode($message->body);
$this->assertContains($expected, $messagebody);
$this->assertStringContainsString($expected, $messagebody);
}
/**
@ -3683,7 +3683,7 @@ class core_moodlelib_testcase extends advanced_testcase {
$messagebody = quoted_printable_decode($message->body);
$sink->close();
$this->assertContains($expected, $messagebody);
$this->assertStringContainsString($expected, $messagebody);
$CFG->admin = $admin;
}
@ -4650,7 +4650,7 @@ class core_moodlelib_testcase extends advanced_testcase {
$result = $sink->get_messages();
$sink->close();
$this->assertContains('passwords cannot be reset on this site', quoted_printable_decode($result[0]->body));
$this->assertStringContainsString('passwords cannot be reset on this site', quoted_printable_decode($result[0]->body));
}
/**

View file

@ -469,10 +469,10 @@ EOF;
$renderer = $page->get_renderer('core');
$reason = 'An icon with no alt text is hidden from screenreaders.';
$this->assertContains('aria-hidden="true"', $renderer->pix_icon('t/print', ''), $reason);
$this->assertStringContainsString('aria-hidden="true"', $renderer->pix_icon('t/print', ''), $reason);
$reason = 'An icon with alt text is not hidden from screenreaders.';
$this->assertNotContains('aria-hidden="true"', $renderer->pix_icon('t/print', 'Print'), $reason);
$this->assertStringNotContainsString('aria-hidden="true"', $renderer->pix_icon('t/print', 'Print'), $reason);
// Test another theme with a different icon system.
set_config('theme', 'classic');
@ -481,10 +481,10 @@ EOF;
$renderer = $page->get_renderer('core');
$reason = 'An icon with no alt text is hidden from screenreaders.';
$this->assertContains('aria-hidden="true"', $renderer->pix_icon('t/print', ''), $reason);
$this->assertStringContainsString('aria-hidden="true"', $renderer->pix_icon('t/print', ''), $reason);
$reason = 'An icon with alt text is not hidden from screenreaders.';
$this->assertNotContains('aria-hidden="true"', $renderer->pix_icon('t/print', 'Print'), $reason);
$this->assertStringNotContainsString('aria-hidden="true"', $renderer->pix_icon('t/print', 'Print'), $reason);
}
/**

View file

@ -126,12 +126,12 @@ class core_outputrequirementslib_testcase extends advanced_testcase {
$html = $page->requires->get_end_code();
$modname = 'theme_foobar/lightbox';
$this->assertContains("M.util.js_pending('{$modname}'); require(['{$modname}'], function(amd) {M.util.js_complete('{$modname}');});", $html);
$this->assertStringContainsString("M.util.js_pending('{$modname}'); require(['{$modname}'], function(amd) {M.util.js_complete('{$modname}');});", $html);
$modname = 'theme_foobar/demo_one';
$this->assertContains("M.util.js_pending('{$modname}'); require(['{$modname}'], function(amd) {amd.init(); M.util.js_complete('{$modname}');});", $html);
$this->assertStringContainsString("M.util.js_pending('{$modname}'); require(['{$modname}'], function(amd) {amd.init(); M.util.js_complete('{$modname}');});", $html);
$modname = 'theme_foobar/demo_two';
$this->assertContains("M.util.js_pending('{$modname}'); require(['{$modname}'], function(amd) {amd.init(\"foo\", \"baz\", [42,\"xyz\"]); M.util.js_complete('{$modname}');});", $html);
$this->assertStringContainsString("M.util.js_pending('{$modname}'); require(['{$modname}'], function(amd) {amd.init(\"foo\", \"baz\", [42,\"xyz\"]); M.util.js_complete('{$modname}');});", $html);
}
}

View file

@ -42,9 +42,9 @@ class progress_display_test extends \advanced_testcase {
$this->assertEquals(1, $progress->get_direction());
$this->assertTimeCurrent($progress->get_last_wibble());
$output = ob_get_clean();
$this->assertContains('wibbler', $output);
$this->assertContains('wibble state0', $output);
$this->assertContains('wibble state1', $output);
$this->assertStringContainsString('wibbler', $output);
$this->assertStringContainsString('wibble state0', $output);
$this->assertStringContainsString('wibble state1', $output);
}
/**
@ -70,9 +70,9 @@ class progress_display_test extends \advanced_testcase {
$this->assertEquals(1, $progress->get_current_state());
$this->assertEquals(1, $progress->get_direction());
$output = ob_get_clean();
$this->assertContains('wibbler', $output);
$this->assertContains('wibble state0', $output);
$this->assertContains('wibble state13', $output);
$this->assertStringContainsString('wibbler', $output);
$this->assertStringContainsString('wibble state0', $output);
$this->assertStringContainsString('wibble state13', $output);
}

View file

@ -48,7 +48,7 @@ class core_qrcode_testcase extends basic_testcase {
$svgdata = $qrcode->getBarcodeSVGcode(1, 1);
// Just check the SVG was generated.
$this->assertContains('<desc>' . $text . '</desc>', $svgdata);
$this->assertContains('fill="' . $color . '"', $svgdata);
$this->assertStringContainsString('<desc>' . $text . '</desc>', $svgdata);
$this->assertStringContainsString('fill="' . $color . '"', $svgdata);
}
}

View file

@ -73,7 +73,7 @@ class core_requirejs_testcase extends advanced_testcase {
if (strpos($component, '_') === false) {
$this->assertEquals('core', $component);
}
$this->assertNotContains('.min', $path);
$this->assertStringNotContainsString('.min', $path);
}
// Find all modules - debugging.
@ -88,7 +88,7 @@ class core_requirejs_testcase extends advanced_testcase {
$this->assertEquals('core', $component);
}
$this->assertContains('.min', $path);
$this->assertStringContainsString('.min', $path);
}
}

View file

@ -145,7 +145,7 @@ class core_scheduled_task_testcase extends advanced_testcase {
// Should be displayed in user timezone.
// I used http://www.timeanddate.com/worldclock/fixedtime.html?msg=Moodle+Test&iso=20160502T01&p1=113
// setting my location to Kathmandu to verify this time.
$this->assertContains('2:15 AM', core_text::strtoupper($userdate));
$this->assertStringContainsString('2:15 AM', core_text::strtoupper($userdate));
}
public function test_reset_scheduled_tasks_for_component_customised(): void {

View file

@ -141,8 +141,8 @@ class core_session_redis_testcase extends advanced_testcase {
$sessblocked->handler_read('sess1');
$this->fail('Session lock must fail to be obtained.');
} catch (\core\session\exception $e) {
$this->assertContains("Unable to obtain session lock", $e->getMessage());
$this->assertContains('Cannot obtain session lock for sid: sess1', file_get_contents($errorlog));
$this->assertStringContainsString("Unable to obtain session lock", $e->getMessage());
$this->assertStringContainsString('Cannot obtain session lock for sid: sess1', file_get_contents($errorlog));
}
$this->assertTrue($sessblocked->handler_close());
@ -302,7 +302,7 @@ class core_session_redis_testcase extends advanced_testcase {
$expected = 'Failed to connect (try 5 out of 5) to redis at ' . TEST_SESSION_REDIS_HOST . ':111111';
$this->assertDebuggingCalledCount(5);
$this->assertContains($expected, $actual);
$this->assertStringContainsString($expected, $actual);
}
/**

View file

@ -92,8 +92,8 @@ class core_setuplib_testcase extends advanced_testcase {
$exception = new moodle_exception('generalexceptionmessage', 'error', '', $fixture, $fixture);
$exceptioninfo = get_exception_info($exception);
$this->assertContains($expected, $exceptioninfo->message, 'Exception message does not contain system paths');
$this->assertContains($expected, $exceptioninfo->debuginfo, 'Exception debug info does not contain system paths');
$this->assertStringContainsString($expected, $exceptioninfo->message, 'Exception message does not contain system paths');
$this->assertStringContainsString($expected, $exceptioninfo->debuginfo, 'Exception debug info does not contain system paths');
}
public function test_localcachedir() {

View file

@ -198,7 +198,7 @@ class core_tablelib_testcase extends advanced_testcase {
);
$output = ob_get_contents();
ob_end_clean();
$this->assertNotContains(get_string('hide'), $output);
$this->assertStringNotContainsString(get_string('hide'), $output);
}
public function test_has_sort() {
@ -243,7 +243,7 @@ class core_tablelib_testcase extends advanced_testcase {
);
$output = ob_get_contents();
ob_end_clean();
$this->assertNotContains(get_string('sortby'), $output);
$this->assertStringNotContainsString(get_string('sortby'), $output);
}
public function test_has_not_next_pagination() {
@ -268,7 +268,7 @@ class core_tablelib_testcase extends advanced_testcase {
$output = ob_get_contents();
ob_end_clean();
$this->assertNotContains(get_string('next'), $output);
$this->assertStringNotContainsString(get_string('next'), $output);
}
public function test_1_col() {
@ -382,7 +382,7 @@ class core_tablelib_testcase extends advanced_testcase {
$user = $this->getDataGenerator()->create_user();
$table = $this->create_and_setup_table(['fullname'], [], true, false, [], []);
$this->assertContains(fullname($user, true), $table->format_row($user)['fullname']);
$this->assertStringContainsString(fullname($user, true), $table->format_row($user)['fullname']);
}
/**
@ -410,7 +410,7 @@ class core_tablelib_testcase extends advanced_testcase {
$user = $this->getDataGenerator()->create_user();
$table = $this->create_and_setup_table(['fullname'], [], true, false, [], []);
$this->assertContains(fullname($user, false), $table->format_row($user)['fullname']);
$this->assertStringContainsString(fullname($user, false), $table->format_row($user)['fullname']);
}
public function test_get_row_html() {