EmbeddedMediaLabelTest.php in Lightning Media 8.2
File
tests/src/Functional/EmbeddedMediaLabelTest.php
View source
<?php
namespace Drupal\Tests\lightning_media\Functional;
use Drupal\media\Entity\Media;
use Drupal\node\Entity\Node;
use Drupal\Tests\BrowserTestBase;
class EmbeddedMediaLabelTest extends BrowserTestBase {
protected static $modules = [
'lightning_media_twitter',
'node',
];
protected $nodeType;
protected function setUp() {
parent::setUp();
$this->nodeType = $this
->drupalCreateContentType()
->id();
}
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());
}
}