From 35bc26b51641c0a8a54e206a8c521dcdf5a4fee1 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Tue, 1 Sep 2020 00:44:13 +0200 Subject: [PATCH] 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\(' --- admin/tool/behat/tests/manager_util_test.php | 28 ++--- admin/tool/dataprivacy/tests/api_test.php | 4 +- .../tests/privacy_provider_test.php | 4 +- .../httpsreplace/tests/httpsreplace_test.php | 24 ++-- admin/tool/mobile/tests/api_test.php | 6 +- admin/tool/mobile/tests/externallib_test.php | 6 +- .../monitor/tests/eventobservers_test.php | 20 ++-- .../tests/externallib_test.php | 2 +- admin/tool/uploadcourse/tests/course_test.php | 2 +- .../usertours/tests/privacy_provider_test.php | 2 +- analytics/tests/dataset_manager_test.php | 18 +-- auth/oauth2/tests/auth_test.php | 4 +- .../completion/tests/condition_test.php | 8 +- .../condition/date/tests/condition_test.php | 8 +- .../condition/grade/tests/condition_test.php | 8 +- .../condition/group/tests/condition_test.php | 2 +- .../grouping/tests/condition_test.php | 8 +- .../profile/tests/condition_test.php | 18 +-- availability/tests/info_test.php | 4 +- availability/tests/tree_test.php | 28 ++--- blocks/rss_client/tests/cron_test.php | 4 +- blog/tests/events_test.php | 10 +- cache/tests/cache_test.php | 2 +- calendar/tests/events_test.php | 18 +-- calendar/tests/externallib_test.php | 2 +- cohort/tests/externallib_test.php | 4 +- competency/tests/event_test.php | 10 +- competency/tests/external_test.php | 2 +- competency/tests/lib_test.php | 2 +- .../h5p/tests/contenttype_h5p_test.php | 6 +- contentbank/tests/contentbank_test.php | 2 +- contentbank/tests/contenttype_test.php | 4 +- course/tests/courselib_test.php | 16 +-- course/tests/externallib_test.php | 12 +- enrol/lti/tests/helper_test.php | 12 +- enrol/lti/tests/sync_members_test.php | 8 +- enrol/lti/tests/tool_provider_test.php | 10 +- enrol/manual/tests/lib_test.php | 48 ++++---- enrol/self/tests/self_test.php | 50 ++++----- filter/mediaplugin/tests/filter_test.php | 2 +- grade/tests/importlib_test.php | 2 +- grade/tests/report_graderlib_test.php | 8 +- h5p/tests/h5p_file_storage_test.php | 2 +- h5p/tests/helper_test.php | 2 +- lib/dml/tests/pgsql_native_recordset_test.php | 2 +- lib/filestorage/tests/zip_packer_test.php | 2 +- lib/form/tests/course_test.php | 20 ++-- lib/form/tests/duration_test.php | 6 +- lib/form/tests/filetypes_util_test.php | 14 +-- lib/form/tests/privacy_provider_test.php | 2 +- lib/phpunit/tests/advanced_test.php | 6 +- lib/tests/antivirus_test.php | 4 +- lib/tests/authlib_test.php | 2 +- lib/tests/completionlib_test.php | 2 +- lib/tests/core_media_player_native.php | 10 +- .../core_renderer_template_exploit_test.php | 4 +- lib/tests/event_course_module_viewed.php | 4 +- lib/tests/externallib_test.php | 2 +- lib/tests/filelib_test.php | 2 +- lib/tests/filetypes_test.php | 36 +++--- lib/tests/grouplib_test.php | 16 +-- lib/tests/medialib_test.php | 84 +++++++------- lib/tests/messagelib_test.php | 2 +- lib/tests/minify_test.php | 2 +- lib/tests/modinfolib_test.php | 4 +- lib/tests/moodlelib_test.php | 28 ++--- lib/tests/outputcomponents_test.php | 8 +- lib/tests/outputrequirementslib_test.php | 6 +- lib/tests/progress_display_test.php | 12 +- lib/tests/qrcode_test.php | 4 +- lib/tests/requirejs_test.php | 4 +- lib/tests/scheduled_task_test.php | 2 +- lib/tests/session_redis_test.php | 6 +- lib/tests/setuplib_test.php | 4 +- lib/tests/tablelib_test.php | 10 +- media/player/videojs/tests/player_test.php | 24 ++-- media/player/youtube/tests/player_test.php | 34 +++--- .../email/tests/send_email_task_test.php | 4 +- message/tests/api_test.php | 54 ++++----- message/tests/externallib_test.php | 22 ++-- .../feedback/comments/tests/privacy_test.php | 4 +- .../feedback/editpdf/tests/editpdf_test.php | 4 +- .../comments/tests/privacy_test.php | 4 +- mod/assign/tests/externallib_test.php | 2 +- mod/assign/tests/locallib_test.php | 106 +++++++++--------- mod/assign/tests/privacy_test.php | 10 +- mod/data/tests/lib_test.php | 62 +++++----- mod/feedback/tests/events_test.php | 8 +- mod/forum/tests/externallib_test.php | 6 +- mod/forum/tests/mail_test.php | 6 +- mod/forum/tests/maildigest_test.php | 8 +- mod/glossary/tests/external_test.php | 4 +- .../seb/tests/quiz_settings_test.php | 70 ++++++------ mod/quiz/accessrule/seb/tests/rule_test.php | 68 +++++------ .../report/overview/tests/report_test.php | 8 +- .../tests/quiz_question_bank_view_test.php | 2 +- mod/wiki/tests/wikiparser_test.php | 2 +- .../manual/tests/privacy_provider_test.php | 2 +- mod/workshop/tests/cron_task_test.php | 2 +- notes/tests/generator_test.php | 4 +- .../deferredcbm/tests/behaviourtype_test.php | 24 ++-- question/engine/tests/helpers.php | 4 +- .../format/aiken/tests/aikenformat_test.php | 12 +- .../tests/multianswerformat_test.php | 24 ++-- .../tests/qformat_xml_import_export_test.php | 12 +- question/tests/bank_view_test.php | 4 +- question/tests/question_bank_column_test.php | 8 +- .../type/essay/tests/walkthrough_test.php | 2 +- search/engine/solr/tests/engine_test.php | 6 +- search/tests/external_test.php | 2 +- search/tests/manager_test.php | 58 +++++----- user/tests/externallib_test.php | 8 +- user/tests/userroleseditable_test.php | 4 +- 113 files changed, 720 insertions(+), 720 deletions(-) diff --git a/admin/tool/behat/tests/manager_util_test.php b/admin/tool/behat/tests/manager_util_test.php index 71629550155..71b4b94575a 100644 --- a/admin/tool/behat/tests/manager_util_test.php +++ b/admin/tool/behat/tests/manager_util_test.php @@ -165,7 +165,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } @@ -219,7 +219,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } @@ -264,7 +264,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } @@ -295,7 +295,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } // Check contexts. @@ -324,7 +324,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } // Check contexts. @@ -368,7 +368,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } // Check contexts. @@ -399,7 +399,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } // Check contexts. @@ -428,7 +428,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } // Check contexts. @@ -532,7 +532,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } // Check contexts. @@ -611,7 +611,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } // Check contexts. @@ -646,7 +646,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } @@ -662,7 +662,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } @@ -678,7 +678,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } @@ -693,7 +693,7 @@ class tool_behat_manager_util_testcase extends advanced_testcase { $this->assertCount(count($paths), $suites[$themename]['paths']); foreach ($paths as $key => $feature) { - $this->assertContains($feature, $suites[$themename]['paths'][$key]); + $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]); } } } diff --git a/admin/tool/dataprivacy/tests/api_test.php b/admin/tool/dataprivacy/tests/api_test.php index 7bf94cc9420..4cb34501382 100644 --- a/admin/tool/dataprivacy/tests/api_test.php +++ b/admin/tool/dataprivacy/tests/api_test.php @@ -997,8 +997,8 @@ class tool_dataprivacy_api_testcase extends advanced_testcase { $this->assertEquals($subject, $message->subject); $this->assertEquals('tool_dataprivacy', $message->component); $this->assertEquals('contactdataprotectionofficer', $message->eventtype); - $this->assertContains(fullname($dpo), $message->fullmessage); - $this->assertContains(fullname($user1), $message->fullmessage); + $this->assertStringContainsString(fullname($dpo), $message->fullmessage); + $this->assertStringContainsString(fullname($user1), $message->fullmessage); } /** diff --git a/admin/tool/dataprivacy/tests/privacy_provider_test.php b/admin/tool/dataprivacy/tests/privacy_provider_test.php index e671fa73796..cfbaac3ce24 100644 --- a/admin/tool/dataprivacy/tests/privacy_provider_test.php +++ b/admin/tool/dataprivacy/tests/privacy_provider_test.php @@ -142,7 +142,7 @@ class tool_dataprivacy_privacy_provider_testcase extends provider_testcase { $this->assertEquals($strs->statusrejected, $data[1]->status); $this->assertEquals($strs->creationmanual, $data[1]->creationmethod); $this->assertEmpty($data[1]->comments); - $this->assertContains('Nope', $data[1]->dpocomment); + $this->assertStringContainsString('Nope', $data[1]->dpocomment); $this->assertNotEmpty($data[1]->timecreated); } @@ -184,4 +184,4 @@ class tool_dataprivacy_privacy_provider_testcase extends provider_testcase { $this->assertEquals(6, $preferences[helper::PREF_REQUEST_PERPAGE]->value); } -} \ No newline at end of file +} diff --git a/admin/tool/httpsreplace/tests/httpsreplace_test.php b/admin/tool/httpsreplace/tests/httpsreplace_test.php index e3599c63cb9..fb60090e7e1 100644 --- a/admin/tool/httpsreplace/tests/httpsreplace_test.php +++ b/admin/tool/httpsreplace/tests/httpsreplace_test.php @@ -155,7 +155,7 @@ class httpsreplace_test extends \advanced_testcase { $finder->upgrade_http_links(); $summary = $DB->get_field('course', 'summary', ['id' => $course->id]); - $this->assertContains($expectedcontent, $summary); + $this->assertStringContainsString($expectedcontent, $summary); } /** @@ -253,10 +253,10 @@ class httpsreplace_test extends \advanced_testcase { $this->assertCount(0, $results); $summary = $DB->get_field('course', 'summary', ['id' => $course->id]); - $this->assertContains('http://intentionally.unavailable/page.php', $summary); - $this->assertContains('http://other.unavailable/page.php', $summary); - $this->assertNotContains('https://intentionally.unavailable', $summary); - $this->assertNotContains('https://other.unavailable', $summary); + $this->assertStringContainsString('http://intentionally.unavailable/page.php', $summary); + $this->assertStringContainsString('http://other.unavailable/page.php', $summary); + $this->assertStringNotContainsString('https://intentionally.unavailable', $summary); + $this->assertStringNotContainsString('https://other.unavailable', $summary); } /** @@ -281,7 +281,7 @@ class httpsreplace_test extends \advanced_testcase { $finder->upgrade_http_links(); $summary = $DB->get_field('course', 'summary', ['id' => $course->id]); - $this->assertContains($CFG->wwwroot, $summary); + $this->assertStringContainsString($CFG->wwwroot, $summary); } /** @@ -298,10 +298,10 @@ class httpsreplace_test extends \advanced_testcase { $output = ob_get_contents(); ob_end_clean(); $this->assertTrue($results); - $this->assertNotContains('https://somesite', $output); + $this->assertStringNotContainsString('https://somesite', $output); $testconf = get_config('core', 'test_upgrade_http_links'); - $this->assertContains('http://somesite', $testconf); - $this->assertNotContains('https://somesite', $testconf); + $this->assertStringContainsString('http://somesite', $testconf); + $this->assertStringNotContainsString('https://somesite', $testconf); } /** @@ -331,8 +331,8 @@ class httpsreplace_test extends \advanced_testcase { $finder->upgrade_http_links(); $summary = $DB->get_field('course', 'summary', ['id' => $course->id]); - $this->assertContains('https://secure.example.com', $summary); - $this->assertNotContains('http://example.com', $summary); + $this->assertStringContainsString('https://secure.example.com', $summary); + $this->assertStringNotContainsString('http://example.com', $summary); $this->assertEquals('