function MediaTest::assertSourceAttributeSame

Same name in this branch
  1. 9 core/modules/ckeditor/tests/src/FunctionalJavascript/MediaTest.php \Drupal\Tests\ckeditor\FunctionalJavascript\MediaTest::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 MediaTest::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/MediaTest.php, line 1640

Class

MediaTest
@coversDefaultClass \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Media @group ckeditor5 @internal

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.