theme_render_and_autoescape example

/** * @dataProvider providerTestThemeRenderAndAutoescape */
  public function testThemeRenderAndAutoescape($arg$expected) {
    if (is_array($arg) && isset($arg['#type']) && $arg['#type'] === 'link') {
      $arg = Link::createFromRoute($arg['#title']$arg['#url']);
    }

    $context = new RenderContext();
    // Use a closure here since we need to render with a render context.     $theme_render_and_autoescape = function D) use ($arg) {
      return theme_render_and_autoescape($arg);
    };
    /** @var \Drupal\Core\Render\RendererInterface $renderer */
    $renderer = \Drupal::service('renderer');
    $output = $renderer->executeInRenderContext($context$theme_render_and_autoescape);
    $this->assertEquals($expected$output);
    $this->assertIsString($output);
  }

  /** * Provide test examples. */
  
Home | Imprint | This part of the site doesn't use cookies.