public function EntityFormTest::testAttachSubmitHandlerAttachable in Acquia Content Hub 8
Tests the attachSubmitHandler() method, attachable.
@covers ::attachSubmitHandler
File
- tests/
src/ Unit/ Form/ EntityFormTest.php, line 189
Class
- EntityFormTest
- PHPUnit test for the EntityForm class.
Namespace
Drupal\Tests\acquia_contenthub\Unit\FormCode
public function testAttachSubmitHandlerAttachable() {
$form_actions = [
'preview' => [
'#type' => 'submit',
],
'ignored_action' => [
'#type' => 'ignored_type',
'#submit' => [
'existing_submit_handler',
],
],
'attached_action' => [
'#type' => 'submit',
'#submit' => [
'existing_submit_handler',
],
],
];
$expected = [
'preview' => [
'#type' => 'submit',
],
'ignored_action' => [
'#type' => 'ignored_type',
'#submit' => [
'existing_submit_handler',
],
],
'attached_action' => [
'#type' => 'submit',
'#submit' => [
'my_handler',
'existing_submit_handler',
],
],
];
$form_submit_handler = 'my_handler';
$this->entityForm
->attachSubmitHandler($form_actions, $form_submit_handler);
$this
->assertEquals($expected, $form_actions);
}