Problem/Motivation
#2831944: Implement media source plugin for remote video via oEmbed β
introduces a large new API to the Media system -- namely, support for oEmbed. This is a pretty complicated sub-API and has pretty thorough test coverage, but the tests are tricky, somewhat brittle, and hard to grok. This is because oEmbed support involves a lot of interaction with external APIs, which is hard to simulate in tests, especially functional tests.
Due to that complexity, and poor design of \Drupal\Tests\media\Traits\OEmbedTestTrait, it is all too easy to write tests which use oEmbed and only pass when they have access to the Internet. We got burned by this in
#3059022: If Vimeo is down our tests break β
. That kind of thing is not acceptable in core; our tests need to pass in complete isolation.
Proposed resolution
Simplify OEmbedTestTrait such that the oEmbed tests are totally isolated and also easy to understand.
We can do this by relegating as much background work as possible to the media_test_oembed module. It can override relevant parts of the oEmbed system's inner workings to ensure that URLs like https://vimeo.com/123456 are "translated" to local files that are accessible via HTTP.
Meanwhile, OEmbedTestTrait will gain a new method or two, intended for use by test authors, allowing them to easily link an asset URL (such as https://www.youtube.com/watch?v=abcxyz), to a locally hosted -- yet accessible over HTTP -- fixture file, like the ones in core/modules/media/tests/fixtures/oembed/*.html. Once linked, the oEmbed system will fetch data from the local filesystem, thus ensuring that properly written oEmbed tests do not ever call out to the Internet.
Remaining tasks
- Iterate on the patch until it's committable
- Verify that all Media tests can pass without an Internet connection (i.e., local testing :)
- File any relevant follow-ups and mention them in the code as needed
- Write a change record and update any relevant deprecations
- Commit it!
User interface changes
None.
API changes
Several methods of OEmbedTestTrait will be deprecated, and a couple new ones will be added.
Data model changes
None.