function AttributeTest::testAttributeValueBaseCopy

Same name and namespace in other branches
  1. main core/tests/Drupal/Tests/Core/Template/AttributeTest.php \Drupal\Tests\Core\Template\AttributeTest::testAttributeValueBaseCopy()

Tests AttributeValueBase copy.

File

core/tests/Drupal/Tests/Core/Template/AttributeTest.php, line 31

Class

AttributeTest
Tests Drupal\Core\Template\Attribute.

Namespace

Drupal\Tests\Core\Template

Code

public function testAttributeValueBaseCopy() : void {
  $original_attributes = new Attribute([
    'checked' => TRUE,
    'class' => [
      'who',
      'is',
      'on',
    ],
    'id' => 'first',
  ]);
  $attributes['selected'] = $original_attributes['checked'];
  $attributes['id'] = $original_attributes['id'];
  $attributes = new Attribute($attributes);
  $this->assertSame(' checked class="who is on" id="first"', (string) $original_attributes, 'Original boolean value used with original name.');
  $this->assertSame(' selected id="first"', (string) $attributes, 'Original boolean value used with new name.');
}

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