public function MediaBrowserTest::testEmbedCodeBasedMediaCreation in Lightning Media 8.3
Tests creating embed code-based media in the media browser.
File
- tests/
src/ Functional/ MediaBrowserTest.php, line 131
Class
- MediaBrowserTest
- Tests the functionality of the media browser.
Namespace
Drupal\Tests\lightning_media\FunctionalCode
public function testEmbedCodeBasedMediaCreation() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$account = $this
->drupalCreateUser([
'access media_browser entity browser pages',
'access media overview',
'create media',
]);
$this
->drupalLogin($account);
// This could be done with the data provider pattern, but it's not really
// needed, and this is significantly faster.
$embed_codes = [
'https://www.youtube.com/watch?v=zQ1_IbFFbzA',
'https://vimeo.com/25585320',
'https://twitter.com/webchick/status/672110599497617408',
'https://www.instagram.com/p/jAH6MNINJG',
];
foreach ($embed_codes as $embed_code) {
$this
->drupalGet('/entity-browser/modal/media_browser');
$title = $this
->randomString();
$page
->pressButton('Create embed');
$page
->fillField('input', $embed_code);
$page
->pressButton('Update');
$page
->fillField('Name', $title);
$page
->pressButton('Place');
$this
->drupalGet('/admin/content/media');
$page
->clickLink('Table');
$assert_session
->linkExists($title);
}
}