function ResourceFetcherTest::testFetchResource

Same name in other branches
  1. 8.9.x core/modules/media/tests/src/Functional/ResourceFetcherTest.php \Drupal\Tests\media\Functional\ResourceFetcherTest::testFetchResource()
  2. 10 core/modules/media/tests/src/Functional/ResourceFetcherTest.php \Drupal\Tests\media\Functional\ResourceFetcherTest::testFetchResource()
  3. 11.x core/modules/media/tests/src/Functional/ResourceFetcherTest.php \Drupal\Tests\media\Functional\ResourceFetcherTest::testFetchResource()

Tests resource fetching.

@covers ::fetchResource

@dataProvider providerFetchResource

Parameters

string $resource_url: The URL of the resource to fetch, relative to the base URL.

string $provider_name: The expected name of the resource provider.

string $title: The expected title of the resource.

File

core/modules/media/tests/src/Functional/ResourceFetcherTest.php, line 67

Class

ResourceFetcherTest
Tests the oEmbed resource fetcher service.

Namespace

Drupal\Tests\media\Functional

Code

public function testFetchResource($resource_url, $provider_name, $title) {
    
    /** @var \Drupal\media\OEmbed\Resource $resource */
    $resource = $this->container
        ->get('media.oembed.resource_fetcher')
        ->fetchResource($resource_url);
    $this->assertInstanceOf(Resource::class, $resource);
    $this->assertSame($provider_name, $resource->getProvider()
        ->getName());
    $this->assertSame($title, $resource->getTitle());
}

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