function MediaTestBase::assertSourceAttributeSame

Same name in other branches
  1. 11.x core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTestBase.php \Drupal\Tests\ckeditor5\FunctionalJavascript\MediaTestBase::assertSourceAttributeSame()

Verifies value of an attribute on the downcast <drupal-media> element.

Assumes CKEditor is in source mode.

@internal

Parameters

string $attribute: The attribute to check.

string|null $value: Either a string value or if NULL, asserts that <drupal-media> element doesn't have the attribute.

3 calls to MediaTestBase::assertSourceAttributeSame()
MediaTest::testAlt in core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php
Tests the CKEditor 5 media plugin can override image media's alt attribute.
MediaTest::testAltDisabled in core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php
Tests that the image media source's alt_field being disabled is respected.
MediaTest::testMediaArbitraryHtml in core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php
Tests that arbitrary attributes are allowed via GHS.

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTestBase.php, line 240

Class

MediaTestBase
Base class for CKEditor 5 Media integration tests.

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

protected function assertSourceAttributeSame(string $attribute, ?string $value) : void {
    $dom = $this->getEditorDataAsDom();
    $drupal_media = (new \DOMXPath($dom))->query('//drupal-media');
    $this->assertNotEmpty($drupal_media);
    if ($value === NULL) {
        $this->assertFalse($drupal_media[0]->hasAttribute($attribute));
    }
    else {
        $this->assertSame($value, $drupal_media[0]->getAttribute($attribute));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.