public function LoggingConfigFormTest::testBuildForm in Purge 8.3
@covers \Drupal\purge_ui\Form\LoggingConfigForm::buildForm
File
- modules/
purge_ui/ tests/ src/ Functional/ Form/ LoggingConfigFormTest.php, line 60
Class
Namespace
Drupal\Tests\purge_ui\Functional\FormCode
public function testBuildForm() : void {
$form = $this
->formInstance()
->buildForm([], $this
->getFormStateInstance());
// Verify the text description.
$this
->assertSame(TRUE, isset($form['msg']['#markup']));
$this
->assertSame(TRUE, (bool) strpos($form['msg']['#markup']
->render(), 'named <i><code>purge'));
// Verify the structure of the table and that it holds the testchannel.
$this
->assertSame(TRUE, isset($form['table']['#header']['id']));
$this
->assertSame('Id', $form['table']['#header']['id']
->render());
$this
->assertSame(9, count($form['table']['#header']));
$this
->assertSame('checkbox', $form['table']['testchannel'][0]['#type']);
$this
->assertSame(FALSE, $form['table']['testchannel'][0]['#default_value']);
$this
->assertSame(TRUE, $form['table']['testchannel'][1]['#default_value']);
$this
->assertSame(TRUE, $form['table']['testchannel'][2]['#default_value']);
$this
->assertSame(FALSE, $form['table']['testchannel'][3]['#default_value']);
$this
->assertSame(TRUE, $form['table']['testchannel'][4]['#default_value']);
$this
->assertSame(FALSE, $form['table']['testchannel'][5]['#default_value']);
$this
->assertSame(FALSE, $form['table']['testchannel'][6]['#default_value']);
$this
->assertSame(FALSE, $form['table']['testchannel'][7]['#default_value']);
$this
->assertSame(3, count($form['table']));
// Verify the action buttons.
$this
->assertSame('submit', $form['actions']['submit']['#type']);
$this
->assertSame('Save', $form['actions']['submit']['#value']
->render());
$this
->assertSame('primary', $form['actions']['submit']['#button_type']);
$this
->assertSame('::setChannels', $form['actions']['submit']['#ajax']['callback']);
$this
->assertSame('submit', $form['actions']['cancel']['#type']);
$this
->assertSame('Cancel', $form['actions']['cancel']['#value']
->render());
$this
->assertSame('danger', $form['actions']['cancel']['#button_type']);
$this
->assertSame('::closeDialog', $form['actions']['cancel']['#ajax']['callback']);
}