public function EntityEmbedTwigTest::testEntityEmbedTwigFunction in Entity Embed 8
Tests that the Twig extension's filter produces expected output.
File
- tests/
src/ Functional/ EntityEmbedTwigTest.php, line 34
Class
- EntityEmbedTwigTest
- Tests Twig extension provided by entity_embed.
Namespace
Drupal\Tests\entity_embed\FunctionalCode
public function testEntityEmbedTwigFunction() {
// Test embedding a node using entity ID.
$this
->drupalGet('entity_embed_twig_test/id');
$this
->assertText($this->node->body->value, 'Embedded node exists in page');
// Test 'Label' Entity Embed Display plugin.
$this
->drupalGet('entity_embed_twig_test/label_plugin');
$this
->assertText($this->node->title->value, 'Title of the embedded node exists in page.');
$this
->assertNoText($this->node->body->value, 'Body of embedded node does not exists in page when "Label" plugin is used.');
$this
->assertLinkByHref('node/' . $this->node
->id(), 0, 'Link to the embedded node exists when "Label" plugin is used.');
// Test 'Label' Entity Embed Display plugin without linking to the node.
$this
->drupalGet('entity_embed_twig_test/label_plugin_no_link');
$this
->assertText($this->node->title->value, 'Title of the embedded node exists in page.');
$this
->assertNoText($this->node->body->value, 'Body of embedded node does not exists in page when "Label" plugin is used.');
$this
->assertNoLinkByHref('node/' . $this->node
->id(), 0, 'Link to the embedded node does not exists.');
}