function PhpunitCompatibilityTraitTest::testAssertStringContainsString

Tests that assert*StringContainsString* methods are available.

@covers ::assertStringContainsString @covers ::assertStringContainsStringIgnoringCase @covers ::assertStringNotContainsString @covers ::assertStringNotContainsStringIgnoringCase

File

core/tests/Drupal/Tests/PhpunitCompatibilityTraitTest.php, line 48

Class

PhpunitCompatibilityTraitTest
Tests the PHPUnit forward compatibility trait.

Namespace

Drupal\Tests

Code

public function testAssertStringContainsString() {
    $this->assertStringContainsString("bingo", "foobarbingobongo");
    $this->assertStringContainsStringIgnoringCase("bingo", "foobarBiNgObongo");
    $this->assertStringNotContainsString("buzzer", "BUZZERbingobongo");
    $this->assertStringNotContainsStringIgnoringCase("buzzer", "foobarBiNgObongo");
    // Test with stringable objects.
    $this->assertStringContainsString(new FormattableMarkup("bingo", []), new FormattableMarkup("foobarbingobongo", []));
    $this->assertStringContainsStringIgnoringCase(new FormattableMarkup("bingo", []), new FormattableMarkup("foobarBiNgObongo", []));
    $this->assertStringNotContainsString(new FormattableMarkup("buzzer", []), new FormattableMarkup("BUZZERbingobongo", []));
    $this->assertStringNotContainsStringIgnoringCase(new FormattableMarkup("buzzer", []), new FormattableMarkup("foobarBiNgObongo", []));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.