You are here

public function AttributesTest::providerTestAttributeData in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Common/AttributesTest.php \Drupal\Tests\Core\Common\AttributesTest::providerTestAttributeData()

Provides data for the Attribute test.

Return value

array

File

core/tests/Drupal/Tests/Core/Common/AttributesTest.php, line 25
Contains \Drupal\Tests\Core\Common\AttributesTest.

Class

AttributesTest
Tests the Drupal\Core\Template\Attribute functionality.

Namespace

Drupal\Tests\Core\Common

Code

public function providerTestAttributeData() {
  return array(
    // Verify that special characters are HTML encoded.
    array(
      array(
        '&"\'<>' => 'value',
      ),
      ' &amp;&quot;&#039;&lt;&gt;="value"',
      'HTML encode attribute names.',
    ),
    array(
      array(
        'title' => '&"\'<>',
      ),
      ' title="&amp;&quot;&#039;&lt;&gt;"',
      'HTML encode attribute values.',
    ),
    // Verify multi-value attributes are concatenated with spaces.
    array(
      array(
        'class' => array(
          'first',
          'last',
        ),
      ),
      ' class="first last"',
      'Concatenate multi-value attributes.',
    ),
    // Verify boolean attribute values are rendered correctly.
    array(
      array(
        'disabled' => TRUE,
      ),
      ' disabled',
      'Boolean attribute is rendered.',
    ),
    array(
      array(
        'disabled' => FALSE,
      ),
      '',
      'Boolean attribute is not rendered.',
    ),
    // Verify empty attribute values are rendered.
    array(
      array(
        'alt' => '',
      ),
      ' alt=""',
      'Empty attribute value #1.',
    ),
    array(
      array(
        'alt' => NULL,
      ),
      '',
      'Null attribute value #2.',
    ),
    // Verify multiple attributes are rendered.
    array(
      array(
        'id' => 'id-test',
        'class' => array(
          'first',
          'last',
        ),
        'alt' => 'Alternate',
      ),
      ' id="id-test" class="first last" alt="Alternate"',
      'Multiple attributes.',
    ),
    // Verify empty attributes array is rendered.
    array(
      array(),
      '',
      'Empty attributes array.',
    ),
  );
}