class ResourceFetcherTest in Drupal 10
Same name in this branch
- 10 core/modules/media/tests/src/Functional/ResourceFetcherTest.php \Drupal\Tests\media\Functional\ResourceFetcherTest
- 10 core/modules/media/tests/src/Unit/ResourceFetcherTest.php \Drupal\Tests\media\Unit\ResourceFetcherTest
Same name and namespace in other branches
- 8 core/modules/media/tests/src/Functional/ResourceFetcherTest.php \Drupal\Tests\media\Functional\ResourceFetcherTest
- 9 core/modules/media/tests/src/Functional/ResourceFetcherTest.php \Drupal\Tests\media\Functional\ResourceFetcherTest
Tests the oEmbed resource fetcher service.
@coversDefaultClass \Drupal\media\OEmbed\ResourceFetcher
@group media
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, FunctionalTestSetupTrait, TestSetupTrait, BlockCreationTrait, ConfigTestTrait, ExtensionListTestTrait, ContentTypeCreationTrait, NodeCreationTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\Tests\media\Functional\MediaFunctionalTestBase uses MediaFunctionalTestTrait, MediaTypeCreationTrait
- class \Drupal\Tests\media\Functional\ResourceFetcherTest uses OEmbedTestTrait
- class \Drupal\Tests\media\Functional\MediaFunctionalTestBase uses MediaFunctionalTestTrait, MediaTypeCreationTrait
Expanded class hierarchy of ResourceFetcherTest
File
- core/
modules/ media/ tests/ src/ Functional/ ResourceFetcherTest.php, line 15
Namespace
Drupal\Tests\media\FunctionalView source
class ResourceFetcherTest extends MediaFunctionalTestBase {
use OEmbedTestTrait;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this
->useFixtureProviders();
$this
->lockHttpClientToFixtures();
}
/**
* Data provider for testFetchResource().
*
* @return array
*/
public function providerFetchResource() {
return [
'JSON resource' => [
'video_vimeo.json',
'Vimeo',
'Drupal Rap Video - Schipulcon09',
],
'XML resource' => [
'video_collegehumor.xml',
'CollegeHumor',
"Let's Not Get a Drink Sometime",
],
];
}
/**
* Tests resource fetching.
*
* @param string $resource_url
* The URL of the resource to fetch, relative to the base URL.
* @param string $provider_name
* The expected name of the resource provider.
* @param string $title
* The expected title of the resource.
*
* @covers ::fetchResource
*
* @dataProvider providerFetchResource
*/
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());
}
}