InfoAlterTest.php in Link Attributes widget 8
File
tests/src/Kernel/InfoAlterTest.php
View source
<?php
namespace Drupal\Tests\link_attributes\Kernel;
use Drupal\KernelTests\KernelTestBase;
class InfoAlterTest extends KernelTestBase {
protected static $modules = [
'system',
'link_attributes',
'link_attributes_test_alterinfo',
];
public function testLinkAttributesManagerInfoAlter() {
$linkAttributesManager = $this->container
->get('plugin.manager.link_attributes');
$definition = $linkAttributesManager
->getDefinitions();
$this
->assertEquals('textfield', $definition['class']['type'], 'Without altering the plugin definition the class attribute is a textfield.');
\Drupal::state()
->set('link_attributes_test_alterinfo.hook_link_attributes_plugin_alter', TRUE);
$linkAttributesManager
->clearCachedDefinitions();
$definition = $linkAttributesManager
->getDefinitions();
$this
->assertEquals('select', $definition['class']['type'], 'After altering the plugin definition the class attribute is a select.');
$this
->assertArrayHasKey('button', $definition['class']['options']);
}
}