function OEmbedSourceTest::testGetMetadata

Same name and namespace in other branches
  1. 9 core/modules/media/tests/src/Kernel/OEmbedSourceTest.php \Drupal\Tests\media\Kernel\OEmbedSourceTest::testGetMetadata()
  2. 8.9.x core/modules/media/tests/src/Kernel/OEmbedSourceTest.php \Drupal\Tests\media\Kernel\OEmbedSourceTest::testGetMetadata()
  3. 10 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 37

Class

OEmbedSourceTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21media%21src%21Plugin%21media%21Source%21OEmbed.php/class/OEmbed/11.x" title="Provides a media source plugin for oEmbed resources." class="local">\Drupal\media\Plugin\media\Source\OEmbed</a>

Namespace

Drupal\Tests\media\Kernel

Code

public function testGetMetadata() : void {
    $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'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.