function CKEditorIntegrationTest::testEmbedPreviewAccess
Tests preview route access.
@dataProvider previewAccessProvider
Parameters
bool $media_embed_enabled: Whether to test with media_embed filter enabled on the text format.
bool $can_use_format: Whether the logged in user is allowed to use the text format.
File
-
core/
modules/ media/ tests/ src/ FunctionalJavascript/ CKEditorIntegrationTest.php, line 1028
Class
- CKEditorIntegrationTest
- @coversDefaultClass \Drupal\media\Plugin\CKEditorPlugin\DrupalMedia @group media
Namespace
Drupal\Tests\media\FunctionalJavascriptCode
public function testEmbedPreviewAccess($media_embed_enabled, $can_use_format) {
// Reconfigure the host entity's text format to suit our needs.
/** @var \Drupal\filter\FilterFormatInterface $format */
$format = FilterFormat::load($this->host->body->format);
$format->set('filters', [
'filter_align' => [
'status' => TRUE,
],
'filter_caption' => [
'status' => TRUE,
],
'media_embed' => [
'status' => $media_embed_enabled,
],
]);
$format->save();
$permissions = [
'bypass node access',
];
if ($can_use_format) {
$permissions[] = $format->getPermissionName();
}
$this->drupalLogin($this->drupalCreateUser($permissions));
$this->drupalGet($this->host
->toUrl('edit-form'));
$assert_session = $this->assertSession();
if ($can_use_format) {
$this->waitForEditor();
$this->assignNameToCkeditorIframe();
$this->getSession()
->switchToIFrame('ckeditor');
if ($media_embed_enabled) {
$this->assertNotEmpty($assert_session->waitForElementVisible('css', 'article.media'));
}
else {
$assert_session->assertWaitOnAjaxRequest();
$assert_session->elementNotExists('css', 'article.media');
}
}
else {
$assert_session->pageTextContains('This field has been disabled because you do not have sufficient permissions to edit it.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.