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

@ -85,20 +85,20 @@ class qbehaviour_deferredcbm_type_test extends qbehaviour_walkthrough_test_base
$summarydata = $this->quba->get_summary_information(new question_display_options());
// Verify.
$this->assertContains(get_string('breakdownbycertainty', 'qbehaviour_deferredcbm'),
$this->assertStringContainsString(get_string('breakdownbycertainty', 'qbehaviour_deferredcbm'),
$summarydata['qbehaviour_cbm_judgement_heading']['content']);
$this->assertContains('100%',
$this->assertStringContainsString('100%',
$summarydata['qbehaviour_cbm_judgement3']['content']);
$this->assertContains(get_string('judgementok', 'qbehaviour_deferredcbm'),
$this->assertStringContainsString(get_string('judgementok', 'qbehaviour_deferredcbm'),
$summarydata['qbehaviour_cbm_judgement3']['content']);
$this->assertContains('50%',
$this->assertStringContainsString('50%',
$summarydata['qbehaviour_cbm_judgement2']['content']);
$this->assertContains(get_string('slightlyoverconfident', 'qbehaviour_deferredcbm'),
$this->assertStringContainsString(get_string('slightlyoverconfident', 'qbehaviour_deferredcbm'),
$summarydata['qbehaviour_cbm_judgement2']['content']);
$this->assertContains(get_string('noquestions', 'qbehaviour_deferredcbm'),
$this->assertStringContainsString(get_string('noquestions', 'qbehaviour_deferredcbm'),
$summarydata['qbehaviour_cbm_judgement1']['content']);
}
@ -121,20 +121,20 @@ class qbehaviour_deferredcbm_type_test extends qbehaviour_walkthrough_test_base
$summarydata = $this->quba->get_summary_information(new question_display_options());
// Verify.
$this->assertContains(get_string('breakdownbycertainty', 'qbehaviour_deferredcbm'),
$this->assertStringContainsString(get_string('breakdownbycertainty', 'qbehaviour_deferredcbm'),
$summarydata['qbehaviour_cbm_judgement_heading']['content']);
$this->assertContains('100%',
$this->assertStringContainsString('100%',
$summarydata['qbehaviour_cbm_judgement3']['content']);
$this->assertContains(get_string('judgementok', 'qbehaviour_deferredcbm'),
$this->assertStringContainsString(get_string('judgementok', 'qbehaviour_deferredcbm'),
$summarydata['qbehaviour_cbm_judgement3']['content']);
$this->assertContains('50%',
$this->assertStringContainsString('50%',
$summarydata['qbehaviour_cbm_judgement2']['content']);
$this->assertContains(get_string('slightlyoverconfident', 'qbehaviour_deferredcbm'),
$this->assertStringContainsString(get_string('slightlyoverconfident', 'qbehaviour_deferredcbm'),
$summarydata['qbehaviour_cbm_judgement2']['content']);
$this->assertContains(get_string('noquestions', 'qbehaviour_deferredcbm'),
$this->assertStringContainsString(get_string('noquestions', 'qbehaviour_deferredcbm'),
$summarydata['qbehaviour_cbm_judgement1']['content']);
}

View file

@ -974,13 +974,13 @@ abstract class qbehaviour_walkthrough_test_base extends question_testcase {
protected function check_output_contains($string) {
$this->render();
$this->assertContains($string, $this->currentoutput,
$this->assertStringContainsString($string, $this->currentoutput,
'Expected string ' . $string . ' not found in ' . $this->currentoutput);
}
protected function check_output_does_not_contain($string) {
$this->render();
$this->assertNotContains($string, $this->currentoutput,
$this->assertStringNotContainsString($string, $this->currentoutput,
'String ' . $string . ' unexpectedly found in ' . $this->currentoutput);
}

View file

@ -52,12 +52,12 @@ class aikenformat_test extends question_testcase {
ob_end_clean();
// Check that there were some expected errors.
$this->assertContains('Error importing question A question with too few answers', $output);
$this->assertContains('Question must have at least 2 answers on line 3', $output);
$this->assertContains('Question not started on line 5', $output);
$this->assertContains('Question not started on line 7', $output);
$this->assertContains('Error importing question A question started but not finished', $output);
$this->assertContains('Question not completed before next question start on line 18', $output);
$this->assertStringContainsString('Error importing question A question with too few answers', $output);
$this->assertStringContainsString('Question must have at least 2 answers on line 3', $output);
$this->assertStringContainsString('Question not started on line 5', $output);
$this->assertStringContainsString('Question not started on line 7', $output);
$this->assertStringContainsString('Error importing question A question started but not finished', $output);
$this->assertStringContainsString('Question not completed before next question start on line 18', $output);
// There are two expected questions.
$this->assertCount(2, $questions);

View file

@ -87,9 +87,9 @@ The capital of France is {#5}.
ob_end_clean();
// Check that there were some expected errors.
$this->assertContains('Error importing question', $output);
$this->assertContains('Invalid embedded answers (Cloze) question', $output);
$this->assertContains('This type of question requires at least 2 choices', $output);
$this->assertStringContainsString('Error importing question', $output);
$this->assertStringContainsString('Invalid embedded answers (Cloze) question', $output);
$this->assertStringContainsString('This type of question requires at least 2 choices', $output);
// No question have been imported.
$this->assertCount(0, $questions);
@ -106,9 +106,9 @@ The capital of France is {#5}.
ob_end_clean();
// Check that there were some expected errors.
$this->assertContains('Error importing question', $output);
$this->assertContains('Invalid embedded answers (Cloze) question', $output);
$this->assertContains('One of the answers should have a score of 100% so it is possible to get full marks for this question.',
$this->assertStringContainsString('Error importing question', $output);
$this->assertStringContainsString('Invalid embedded answers (Cloze) question', $output);
$this->assertStringContainsString('One of the answers should have a score of 100% so it is possible to get full marks for this question.',
$output);
// No question have been imported.
@ -126,9 +126,9 @@ The capital of France is {#5}.
ob_end_clean();
// Check that there were some expected errors.
$this->assertContains('Error importing question', $output);
$this->assertContains('Invalid embedded answers (Cloze) question', $output);
$this->assertContains('The answer must be a number, for example -1.234 or 3e8, or \'*\'.', $output);
$this->assertStringContainsString('Error importing question', $output);
$this->assertStringContainsString('Invalid embedded answers (Cloze) question', $output);
$this->assertStringContainsString('The answer must be a number, for example -1.234 or 3e8, or \'*\'.', $output);
// No question have been imported.
$this->assertCount(0, $questions);
@ -145,9 +145,9 @@ The capital of France is {#5}.
ob_end_clean();
// Check that there were some expected errors.
$this->assertContains('Error importing question', $output);
$this->assertContains('Invalid embedded answers (Cloze) question', $output);
$this->assertContains('The question text must include at least one embedded answer.', $output);
$this->assertStringContainsString('Error importing question', $output);
$this->assertStringContainsString('Invalid embedded answers (Cloze) question', $output);
$this->assertStringContainsString('The question text must include at least one embedded answer.', $output);
// No question have been imported.
$this->assertCount(0, $questions);

View file

@ -478,13 +478,13 @@ class qformat_xml_import_export_test extends advanced_testcase {
ob_end_clean();
// Check that there were some expected errors.
$this->assertContains('Error importing question', $output);
$this->assertContains('Invalid embedded answers (Cloze) question', $output);
$this->assertContains('This type of question requires at least 2 choices', $output);
$this->assertContains('The answer must be a number, for example -1.234 or 3e8, or \'*\'.', $output);
$this->assertContains('One of the answers should have a score of 100% so it is possible to get full marks for this question.',
$this->assertStringContainsString('Error importing question', $output);
$this->assertStringContainsString('Invalid embedded answers (Cloze) question', $output);
$this->assertStringContainsString('This type of question requires at least 2 choices', $output);
$this->assertStringContainsString('The answer must be a number, for example -1.234 or 3e8, or \'*\'.', $output);
$this->assertStringContainsString('One of the answers should have a score of 100% so it is possible to get full marks for this question.',
$output);
$this->assertContains('The question text must include at least one embedded answer.', $output);
$this->assertStringContainsString('The question text must include at least one embedded answer.', $output);
// No question have been imported.
$this->assertCount(0, $questions);

View file

@ -65,7 +65,7 @@ class core_question_bank_view_testcase extends advanced_testcase {
$html = ob_get_clean();
// Verify the output includes the expected question.
$this->assertContains('Example question', $html);
$this->assertStringContainsString('Example question', $html);
// Verify the question has not been loaded into the cache.
$this->assertFalse($cache->has($questiondata->id));
@ -99,6 +99,6 @@ class core_question_bank_view_testcase extends advanced_testcase {
// Mainly we are verifying that there was no fatal error.
// Verify the output includes the expected question.
$this->assertContains('Example question', $html);
$this->assertStringContainsString('Example question', $html);
}
}

View file

@ -67,8 +67,8 @@ class question_bank_column_testcase extends advanced_testcase {
$columnbase->display_header();
$output = ob_get_clean();
$this->assertContains(' title="Sort by Apple ascending">Apple</a>', $output);
$this->assertContains(' title="Sort by Banana ascending">Banana</a>', $output);
$this->assertStringContainsString(' title="Sort by Apple ascending">Apple</a>', $output);
$this->assertStringContainsString(' title="Sort by Banana ascending">Banana</a>', $output);
}
/**
@ -103,7 +103,7 @@ class question_bank_column_testcase extends advanced_testcase {
$columnbase->display_header();
$output = ob_get_clean();
$this->assertContains(' title="Sort by Apple Tooltips ascending">Apple</a>', $output);
$this->assertContains(' title="Sort by Banana Tooltips ascending">Banana</a>', $output);
$this->assertStringContainsString(' title="Sort by Apple Tooltips ascending">Apple</a>', $output);
$this->assertStringContainsString(' title="Sort by Banana Tooltips ascending">Banana</a>', $output);
}
}

View file

@ -499,7 +499,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
// Test taht no HTML comment has been added to the response.
$this->assertRegExp('/Once upon a time there was a frog called Freddy. He lived happily ever after.(?!&lt;!--)/', $this->currentoutput);
// Test for the hash of an empty file area.
$this->assertNotContains('d41d8cd98f00b204e9800998ecf8427e', $this->currentoutput);
$this->assertStringNotContainsString('d41d8cd98f00b204e9800998ecf8427e', $this->currentoutput);
}
public function test_deferred_feedback_html_editor_with_files_attempt_wrong_filetypes() {