function MediaEmbedFilterTestBase::assertHasAttributes

Same name in other branches
  1. 9 core/modules/media/tests/src/Kernel/MediaEmbedFilterTestBase.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTestBase::assertHasAttributes()
  2. 8.9.x core/modules/media/tests/src/Kernel/MediaEmbedFilterTestBase.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTestBase::assertHasAttributes()
  3. 10 core/modules/media/tests/src/Kernel/MediaEmbedFilterTestBase.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTestBase::assertHasAttributes()

Assert that the SimpleXMLElement object has the given attributes.

Parameters

\SimpleXMLElement $element: The SimpleXMLElement object to check.

array $expected_attributes: An array of expected attributes.

2 calls to MediaEmbedFilterTestBase::assertHasAttributes()
MediaEmbedFilterTest::testBasics in core/modules/media/tests/src/Kernel/MediaEmbedFilterTest.php
Ensures media entities are rendered correctly.
MediaEmbedFilterTest::testOverridesAltAndTitle in core/modules/media/tests/src/Kernel/MediaEmbedFilterTest.php
@covers ::applyPerEmbedMediaOverrides @dataProvider providerOverridesAltAndTitle

File

core/modules/media/tests/src/Kernel/MediaEmbedFilterTestBase.php, line 200

Class

MediaEmbedFilterTestBase
Base class for Media Embed filter tests.

Namespace

Drupal\Tests\media\Kernel

Code

protected function assertHasAttributes(\SimpleXMLElement $element, array $expected_attributes) {
    foreach ($expected_attributes as $attribute => $value) {
        if ($value === NULL) {
            $this->assertNull($element[$attribute]);
        }
        else {
            $this->assertSame((string) $value, (string) $element[$attribute]);
        }
    }
}

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