// Mock the resource fetcher so that it will return our fake resource.
$resource_fetcher =
$this->
prophesize(ResourceFetcherInterface::
class);
$resource_fetcher->
fetchResource(Argument::
any()) ->
willReturn($resource);
$this->container->
set('media.oembed.resource_fetcher',
$resource_fetcher->
reveal());
// The source plugin will try to fetch the remote thumbnail, so mock the
// HTTP client to ensure that request returns a response with some valid
// image data.
$data = Utils::
tryFopen($this->
getDrupalRoot() . '/core/misc/druplicon.png', 'r'
);
$response =
new Response(200,
$thumbnail_headers, Utils::
streamFor($data));
$handler =
new MockHandler([$response]);
$client =
new Client([ 'handler' =>
new HandlerStack($handler),
]);
$this->container->
set('http_client',
$client);
$media_type =
$this->
createMediaType('oembed:video'
);
$source =
$media_type->
getSource();
// Add some HTML to the global site slogan, and use the site:slogan token in
// the thumbnail path, in order to prove that the final thumbnail path is
// stripped of HTML tags, and XML entities are decoded.