class ActionsTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Render/Element/ActionsTest.php \Drupal\KernelTests\Core\Render\Element\ActionsTest
- 10 core/tests/Drupal/KernelTests/Core/Render/Element/ActionsTest.php \Drupal\KernelTests\Core\Render\Element\ActionsTest
- 8.9.x core/tests/Drupal/KernelTests/Core/Render/Element/ActionsTest.php \Drupal\KernelTests\Core\Render\Element\ActionsTest
@coversDefaultClass \Drupal\Core\Render\Element\Actions
@group Render
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Render\Element\ActionsTest implements \Drupal\Core\Form\FormInterface extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ActionsTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Render/ Element/ ActionsTest.php, line 13
Namespace
Drupal\KernelTests\Core\Render\ElementView source
class ActionsTest extends KernelTestBase implements FormInterface {
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
];
/**
* {@inheritdoc}
*/
public function getFormId() {
return __CLASS__;
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['actions'] = [
'#type' => 'actions',
];
$form['actions']['key'] = [
'#type' => 'submit',
'#value' => 'Key',
'#dropbutton' => 'submit',
'#cache' => [
'tags' => [
'foo',
],
],
'#attached' => [
'library' => [
'system/base',
],
],
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => 'Save',
];
return $form;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
}
public function testDropbuttonWithBubbleableMetadata() {
$result = \Drupal::formBuilder()->getForm($this);
\Drupal::service('renderer')->renderRoot($result);
$this->assertEquals([
'system/base',
'core/drupal.dropbutton',
], $result['#attached']['library']);
$this->assertEquals([
'foo',
], $result['#cache']['tags']);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.