You are here

public function DefaultNameTest::testDefaultName in Video Embed Field 8.2

Same name and namespace in other branches
  1. 8 modules/video_embed_media/tests/src/Kernel/DefaultNameTest.php \Drupal\Tests\video_embed_media\Kernel\DefaultNameTest::testDefaultName()

Test the default name.

@dataProvider defaultNameTestCases

File

modules/video_embed_media/tests/src/Kernel/DefaultNameTest.php, line 63

Class

DefaultNameTest
Test the media bundle default names.

Namespace

Drupal\Tests\video_embed_media\Kernel

Code

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);
}