You are here

trait AssertHelperTrait in Drupal 8

Same name in this branch
  1. 8 core/tests/Drupal/Tests/AssertHelperTrait.php \Drupal\Tests\AssertHelperTrait
  2. 8 core/modules/simpletest/src/AssertHelperTrait.php \Drupal\simpletest\AssertHelperTrait
Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/AssertHelperTrait.php \Drupal\Tests\AssertHelperTrait

Provides helper methods for assertions.

Hierarchy

9 files declare their use of AssertHelperTrait
AssertHelperTrait.php in core/modules/simpletest/src/AssertHelperTrait.php
BookUninstallValidatorTest.php in core/modules/book/tests/src/Unit/BookUninstallValidatorTest.php
FieldUninstallValidatorTest.php in core/modules/field/tests/src/Unit/FieldUninstallValidatorTest.php
FilterUninstallValidatorTest.php in core/modules/filter/tests/src/Unit/FilterUninstallValidatorTest.php
ForumUninstallValidatorTest.php in core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php

... See full list

File

core/tests/Drupal/Tests/AssertHelperTrait.php, line 10

Namespace

Drupal\Tests
View source
trait AssertHelperTrait {

  /**
   * Casts MarkupInterface objects into strings.
   *
   * @param string|array $value
   *   The value to act on.
   *
   * @return mixed
   *   The input value, with MarkupInterface objects casted to string.
   */
  protected static function castSafeStrings($value) {
    if ($value instanceof MarkupInterface) {
      $value = (string) $value;
    }
    if (is_array($value)) {
      array_walk_recursive($value, function (&$item) {
        if ($item instanceof MarkupInterface) {
          $item = (string) $item;
        }
      });
    }
    return $value;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AssertHelperTrait::castSafeStrings protected static function Casts MarkupInterface objects into strings.