HtmlEscapedText example


class HtmlEscapedTextTest extends TestCase {

  /** * @covers ::__toString * @covers ::jsonSerialize * * @dataProvider providerToString */
  public function testToString($text$expected$message) {
    $escapable_string = new HtmlEscapedText($text);
    $this->assertEquals($expected(string) $escapable_string$message);
    $this->assertEquals($expected$escapable_string->jsonSerialize());
  }

  /** * Data provider for testToString(). * * @see testToString() */
  public static function providerToString() {
    $prophet = new Prophet();

    
$replacements += array_fill_keys($tokens, '');
      }
    }

    // Each token value is markup if it implements MarkupInterface otherwise it     // is plain text. Convert them, but only if needed. It can cause corruption     // to render a string that's already plain text or to escape a string     // that's already markup.     foreach ($replacements as $token => $value) {
      if ($markup) {
        // Escape plain text tokens.         $replacements[$token] = $value instanceof MarkupInterface ? $value : new HtmlEscapedText($value);
      }
      else {
        // Render markup tokens to plain text.         $replacements[$token] = $value instanceof MarkupInterface ? PlainTextOutput::renderFromHtml($value) : $value;
      }
    }

    // Optionally alter the list of replacement values.     if (!empty($options['callback'])) {
      $function = $options['callback'];
      $function($replacements$data$options$bubbleable_metadata);
    }
Home | Imprint | This part of the site doesn't use cookies.