trait AssertHelperTrait

Same name and namespace in other branches
  1. 8.9.x core/modules/simpletest/src/AssertHelperTrait.php \Drupal\simpletest\AssertHelperTrait
  2. 8.9.x core/tests/Drupal/Tests/AssertHelperTrait.php \Drupal\Tests\AssertHelperTrait

Provides helper methods for assertions.

Hierarchy

Deprecated

in drupal:9.2.0 and is removed from drupal:10.0.0. There is no replacement.

See also

https://www.drupal.org/node/3123638

File

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

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.
     *
     * @deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. There is no
     *   replacement, just use assertEquals in tests.
     *
     * @see https://www.drupal.org/node/3123638
     */
    protected static function castSafeStrings($value) {
        @trigger_error('AssertHelperTrait::castSafeStrings() is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. There is no replacement; assertEquals() will automatically cast MarkupInterface to strings when needed. See https://www.drupal.org/node/3123638', E_USER_DEPRECATED);
        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

Title Sort descending Deprecated Modifiers Object type Summary
AssertHelperTrait::castSafeStrings Deprecated protected static function Casts MarkupInterface objects into strings.

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