Created
April 24, 2018 02:20
-
-
Save suresh-kumara-gist/af860c64dff68fe9b7ca45f39c9ed7bd to your computer and use it in GitHub Desktop.
Rendarable array to html string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$entity = EntityTest::create(); | |
$entity->field_datasheet->target_id = $this->file->id(); | |
$entity->save(); | |
$output = $this->renderTestEntity($entity->id()); | |
$expected_link = Link::fromTextAndUrl($this->field_label, Url::fromUri(file_create_url($this->file->getFileUri()))); | |
$expected_link = $expected_link->toRenderable(); | |
$expected_link['#attributes'] = [ | |
'target' => '_blank', | |
]; | |
$expected_link = \Drupal::service('renderer')->renderRoot($expected_link); | |
$this->assertContains($expected_link->__toString(), $output); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment