You are here

protected function YamlFormTestTrait::assertContains in YAML Form 8

Passes if the substring is contained within text, fails otherwise.

3 calls to YamlFormTestTrait::assertContains()
YamlFormElementFormatTest::testElementFormat in src/Tests/YamlFormElementFormatTest.php
Tests element format.
YamlFormHandlerEmailAdvancedTest::testAdvancedEmailHandler in src/Tests/YamlFormHandlerEmailAdvancedTest.php
Test advanced email handler.
YamlFormHandlerEmailBasicTest::testBasicEmailHandler in src/Tests/YamlFormHandlerEmailBasicTest.php
Test basic email handler.

File

src/Tests/YamlFormTestTrait.php, line 434

Class

YamlFormTestTrait
Defines form test trait.

Namespace

Drupal\yamlform\Tests

Code

protected function assertContains($haystack, $needle, $message = '', $group = 'Other') {
  if (!$message) {
    $t_args = [
      '@haystack' => Unicode::truncate($haystack, 150, TRUE, TRUE),
      '@needle' => $needle,
    ];
    $message = new FormattableMarkup('"@needle" found', $t_args);
  }
  $result = strpos($haystack, $needle) !== FALSE;
  if (!$result) {
    $this
      ->verbose($haystack);
  }
  return $this
    ->assert($result, $message, $group);
}