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

@ -126,7 +126,7 @@ class core_calendar_events_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\calendar_event_created to be triggered without
other['repeatid']");
} catch (coding_exception $e) {
$this->assertContains('The \'repeatid\' value must be set in other.', $e->getMessage());
$this->assertStringContainsString('The \'repeatid\' value must be set in other.', $e->getMessage());
}
// Test not setting other['name'].
@ -142,7 +142,7 @@ class core_calendar_events_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\calendar_event_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());
}
// Test not setting other['timestart'].
@ -158,7 +158,7 @@ class core_calendar_events_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\calendar_event_deleted to be triggered without
other['timestart']");
} catch (coding_exception $e) {
$this->assertContains('The \'timestart\' value must be set in other.', $e->getMessage());
$this->assertStringContainsString('The \'timestart\' value must be set in other.', $e->getMessage());
}
}
@ -274,7 +274,7 @@ class core_calendar_events_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\calendar_event_updated to be triggered without
other['repeatid']");
} catch (coding_exception $e) {
$this->assertContains('The \'repeatid\' value must be set in other.', $e->getMessage());
$this->assertStringContainsString('The \'repeatid\' value must be set in other.', $e->getMessage());
}
// Test not setting other['name'].
@ -290,7 +290,7 @@ class core_calendar_events_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\calendar_event_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());
}
// Test not setting other['timestart'].
@ -306,7 +306,7 @@ class core_calendar_events_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\calendar_event_deleted to be triggered without
other['timestart']");
} catch (coding_exception $e) {
$this->assertContains('The \'timestart\' value must be set in other.', $e->getMessage());
$this->assertStringContainsString('The \'timestart\' value must be set in other.', $e->getMessage());
}
}
@ -386,7 +386,7 @@ class core_calendar_events_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\calendar_event_deleted to be triggered without
other['repeatid']");
} catch (coding_exception $e) {
$this->assertContains('The \'repeatid\' value must be set in other.', $e->getMessage());
$this->assertStringContainsString('The \'repeatid\' value must be set in other.', $e->getMessage());
}
// Test not setting other['name'].
@ -402,7 +402,7 @@ class core_calendar_events_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\calendar_event_deleted 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());
}
// Test not setting other['timestart'].
@ -418,7 +418,7 @@ class core_calendar_events_testcase extends advanced_testcase {
$this->fail("Event validation should not allow \\core\\event\\calendar_event_deleted to be triggered without
other['timestart']");
} catch (coding_exception $e) {
$this->assertContains('The \'timestart\' value must be set in other.', $e->getMessage());
$this->assertStringContainsString('The \'timestart\' value must be set in other.', $e->getMessage());
}
}

View file

@ -374,7 +374,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
foreach ($events['events'] as $event) {
if (!empty($event['description'])) {
$withdescription++;
$this->assertContains($expectedurl, $event['description']);
$this->assertStringContainsString($expectedurl, $event['description']);
}
}
$this->assertEquals(2, $withdescription);