You are here

public function EmbeddedMediaLabelTest::testEmbeddedMediaItem in Lightning Media 8

Same name and namespace in other branches
  1. 8.4 tests/src/Functional/EmbeddedMediaLabelTest.php \Drupal\Tests\lightning_media\Functional\EmbeddedMediaLabelTest::testEmbeddedMediaItem()
  2. 8.2 tests/src/Functional/EmbeddedMediaLabelTest.php \Drupal\Tests\lightning_media\Functional\EmbeddedMediaLabelTest::testEmbeddedMediaItem()
  3. 8.3 tests/src/Functional/EmbeddedMediaLabelTest.php \Drupal\Tests\lightning_media\Functional\EmbeddedMediaLabelTest::testEmbeddedMediaItem()

Tests that the label of an embedded media item does not appear in the rendered host entity.

File

tests/src/Functional/EmbeddedMediaLabelTest.php, line 42

Class

EmbeddedMediaLabelTest
@group lightning @group lightning_media

Namespace

Drupal\Tests\lightning_media\Functional

Code

public function testEmbeddedMediaItem() {
  $media = Media::create([
    'bundle' => 'tweet',
    'name' => 'Here be dragons',
    'embed_code' => 'https://twitter.com/50NerdsofGrey/status/757319527151636480',
  ]);
  $media
    ->setPublished();
  $media
    ->save();
  $node = Node::create([
    'type' => $this->nodeType,
    'body' => '<drupal-entity data-embed-button="media_browser" data-entity-embed-display="view_mode:media.embedded" data-entity-type="media" data-entity-uuid="' . $media
      ->uuid() . '"></drupal-entity>',
    'title' => $this
      ->getRandomGenerator()
      ->word(16),
  ]);
  $node
    ->setPublished();
  $node
    ->save();
  $this
    ->drupalGet($node
    ->toUrl());
  $this
    ->assertSession()
    ->pageTextNotContains($media
    ->label());
}