You are here

public function OEmbedSourceTest::testGetMetadata in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media/tests/src/Kernel/OEmbedSourceTest.php \Drupal\Tests\media\Kernel\OEmbedSourceTest::testGetMetadata()
  2. 9 core/modules/media/tests/src/Kernel/OEmbedSourceTest.php \Drupal\Tests\media\Kernel\OEmbedSourceTest::testGetMetadata()

@covers ::getMetadata

File

core/modules/media/tests/src/Kernel/OEmbedSourceTest.php, line 33

Class

OEmbedSourceTest
@coversDefaultClass \Drupal\media\Plugin\media\Source\OEmbed

Namespace

Drupal\Tests\media\Kernel

Code

public function testGetMetadata() {
  $configuration = [
    'source_field' => 'field_test_oembed',
  ];
  $plugin = OEmbed::create($this->container, $configuration, 'oembed', []);

  // Test that NULL is returned for a media item with no source value.
  $media = $this
    ->prophesize('\\Drupal\\media\\MediaInterface');
  $field_items = $this
    ->prophesize('\\Drupal\\Core\\Field\\FieldItemListInterface');
  $field_items
    ->isEmpty()
    ->willReturn(TRUE);
  $media
    ->get($configuration['source_field'])
    ->willReturn($field_items
    ->reveal());
  $this
    ->assertNull($plugin
    ->getMetadata($media
    ->reveal(), 'type'));
}