protected function MediaImageTest::setUp in Entity Embed 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ FunctionalJavascript/ MediaImageTest.php, line 58
Class
- MediaImageTest
- Test Media Image specific functionality.
Namespace
Drupal\Tests\entity_embed\FunctionalJavascriptCode
protected function setUp() {
parent::setUp();
// Note that media_install() grants 'view media' to all users by default.
$this->adminUser = $this
->drupalCreateUser([
'use text format full_html',
'bypass node access',
]);
$this
->createNode([
'type' => 'article',
'title' => 'Red-lipped batfish',
]);
// Create a sample media entity to be embedded.
File::create([
'uri' => $this
->getTestFiles('image')[0]->uri,
])
->save();
$this->media = Media::create([
'bundle' => 'image',
'name' => 'Screaming hairy armadillo',
'field_media_image' => [
[
'target_id' => 1,
'alt' => 'default alt',
'title' => 'default title',
],
],
]);
$this->media
->save();
// Create a sample host entity to embed media in.
$this
->drupalCreateContentType([
'type' => 'blog',
]);
$this->host = $this
->createNode([
'type' => 'blog',
'title' => 'Animals with strange names',
'body' => [
'value' => '',
'format' => 'full_html',
],
]);
$this->host
->save();
$this
->drupalLogin($this->adminUser);
}