You are here

public function PhpunitCompatibilityTraitTest::testAssertStringContainsString in Drupal 8

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", []));
}