BundleTest.php in Video Embed Field 8.2
File
modules/video_embed_media/tests/src/Functional/BundleTest.php
View source
<?php
namespace Drupal\Tests\video_embed_media\Functional;
use Drupal\Tests\media\Functional\MediaFunctionalTestBase;
use Drupal\Tests\video_embed_field\Functional\AdminUserTrait;
class BundleTest extends MediaFunctionalTestBase {
use AdminUserTrait;
protected $defaultTheme = 'stark';
public static $modules = [
'video_embed_field',
'video_embed_media',
];
public function testMediaBundleCreation() {
$this
->drupalLogin($this->adminUser);
$media_type = $this
->createMediaType('video_embed_field', [
'id' => 'video_bundle',
]);
$source = $media_type
->getSource();
$source_field = $source
->getSourceFieldDefinition($media_type);
if ($source_field
->isDisplayConfigurable('form')) {
$component = \Drupal::service('plugin.manager.field.widget')
->prepareConfiguration('video_embed_field', []);
$this->container
->get('entity_display.repository')
->getFormDisplay('media', $media_type
->id(), 'default')
->setComponent($source_field
->getName(), $component)
->save();
}
$this
->drupalGet('admin/structure/media/manage/video_bundle/fields');
$this
->assertSession()
->pageTextContains('field_media_video_embed_field');
$this
->assertSession()
->pageTextContains('Video URL');
$this
->drupalGet('media/add/video_bundle');
$this
->submitForm([
'name[0][value]' => 'Drupal video!',
'field_media_video_embed_field[0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ',
], 'Save');
$this
->assertContains('video_thumbnails/XgYu7-DQjDQ.jpg', $this
->getSession()
->getPage()
->getHtml());
}
}
Classes
Name |
Description |
BundleTest |
Test the video_embed_field media integration. |