function AttributeHelperTest::testMergeCollectionsArgumentException

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

@covers ::mergeCollections

File

core/tests/Drupal/Tests/Core/Template/AttributeHelperTest.php, line 74

Class

AttributeHelperTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Template%21AttributeHelper.php/class/AttributeHelper/11.x" title="Helper class to deal with mixed array and Attribute operations." class="local">\Drupal\Core\Template\AttributeHelper</a> @group Template

Namespace

Drupal\Tests\Core\Template

Code

public function testMergeCollectionsArgumentException() : void {
    $attributes = new Attribute([
        'class' => [
            'example-class',
        ],
    ]);
    $this->expectException(\InvalidArgumentException::class);
    $this->expectExceptionMessage('Invalid collection argument');
    AttributeHelper::mergeCollections($attributes, 'not an array');
    $this->expectException(\InvalidArgumentException::class);
    $this->expectExceptionMessage('Invalid collection argument');
    AttributeHelper::mergeCollections('not an array', $attributes);
}

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