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

@ -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);