3 namespace Drupal\Tests\media\Functional;
5 use Drupal\media\OEmbed\Resource;
6 use Drupal\Tests\media\Traits\OEmbedTestTrait;
9 * Tests the oEmbed resource fetcher service.
11 * @coversDefaultClass \Drupal\media\OEmbed\ResourceFetcher
15 class ResourceFetcherTest extends MediaFunctionalTestBase {
22 protected function setUp() {
24 $this->useFixtureProviders();
25 $this->lockHttpClientToFixtures();
29 * Data provider for testFetchResource().
33 public function providerFetchResource() {
38 'Drupal Rap Video - Schipulcon09',
41 'video_collegehumor.xml',
43 "Let's Not Get a Drink Sometime",
49 * Tests resource fetching.
51 * @param string $resource_url
52 * The URL of the resource to fetch, relative to the base URL.
53 * @param string $provider_name
54 * The expected name of the resource provider.
55 * @param string $title
56 * The expected title of the resource.
58 * @covers ::fetchResource
60 * @dataProvider providerFetchResource
62 public function testFetchResource($resource_url, $provider_name, $title) {
63 /** @var \Drupal\media\OEmbed\Resource $resource */
64 $resource = $this->container->get('media.oembed.resource_fetcher')
65 ->fetchResource($resource_url);
67 $this->assertInstanceOf(Resource::class, $resource);
68 $this->assertSame($provider_name, $resource->getProvider()->getName());
69 $this->assertSame($title, $resource->getTitle());