DefaultNameTest.php in Video Embed Field 8.2
File
modules/video_embed_media/tests/src/Kernel/DefaultNameTest.php
View source
<?php
namespace Drupal\Tests\video_embed_media\Kernel;
use Drupal\media\Entity\Media;
use Drupal\Tests\media\Kernel\MediaKernelTestBase;
class DefaultNameTest extends MediaKernelTestBase {
protected $plugin;
protected $entityType;
public static $modules = [
'video_embed_field',
'video_embed_media',
'media',
'file',
'views',
];
public function defaultNameTestCases() {
return [
'YouTube' => [
'https://www.youtube.com/watch?v=gnERPdAiuSo',
'YouTube Video (gnERPdAiuSo)',
],
'Vimeo' => [
'https://vimeo.com/21681203',
'Drupal Commerce at DrupalCon Chicago',
],
];
}
public function testDefaultName($input, $expected) {
$field_name = $this->plugin
->getSourceFieldDefinition($this->entityType)
->getName();
$entity = Media::create([
'bundle' => $this->entityType
->id(),
$field_name => [
[
'value' => $input,
],
],
]);
$actual = $this->plugin
->getMetadata($entity, 'default_name');
$this
->assertEquals($expected, $actual);
}
public function setUp() {
parent::setUp();
$this
->installConfig([
'video_embed_field',
'video_embed_media',
]);
$this->entityType = $this
->createMediaType('video_embed_field');
$this->plugin = $this->entityType
->getSource();
}
}