function AttributesTest::testAttributeIteration

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Common/AttributesTest.php \Drupal\Tests\Core\Common\AttributesTest::testAttributeIteration()
  2. 8.9.x core/tests/Drupal/Tests/Core/Common/AttributesTest.php \Drupal\Tests\Core\Common\AttributesTest::testAttributeIteration()
  3. 10 core/tests/Drupal/Tests/Core/Common/AttributesTest.php \Drupal\Tests\Core\Common\AttributesTest::testAttributeIteration()

Tests attribute iteration.

File

core/tests/Drupal/Tests/Core/Common/AttributesTest.php, line 64

Class

AttributesTest
Tests the <a href="/api/drupal/core%21lib%21Drupal%21Core%21Template%21Attribute.php/class/Attribute/11.x" title="Collects, sanitizes, and renders HTML attributes." class="local">Drupal\Core\Template\Attribute</a> functionality.

Namespace

Drupal\Tests\Core\Common

Code

public function testAttributeIteration() : void {
    $attribute = new Attribute([
        'key1' => 'value1',
    ]);
    foreach ($attribute as $value) {
        $this->assertSame((string) $value, 'value1', 'Iterate over attribute.');
    }
}

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