trait AssertHelperTrait in Drupal 8
Same name in this branch
- 8 core/tests/Drupal/Tests/AssertHelperTrait.php \Drupal\Tests\AssertHelperTrait
- 8 core/modules/simpletest/src/AssertHelperTrait.php \Drupal\simpletest\AssertHelperTrait
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/AssertHelperTrait.php \Drupal\Tests\AssertHelperTrait
Provides helper methods for assertions.
Hierarchy
- trait \Drupal\Tests\AssertHelperTrait
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
File
- core/
tests/ Drupal/ Tests/ AssertHelperTrait.php, line 10
Namespace
Drupal\TestsView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AssertHelperTrait:: |
protected static | function | Casts MarkupInterface objects into strings. |