function IconExtractorSettingsFormTest::testGenerateSettingsFormWithValues
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Theme/Icon/IconExtractorSettingsFormTest.php \Drupal\Tests\Core\Theme\Icon\IconExtractorSettingsFormTest::testGenerateSettingsFormWithValues()
Test the IconExtractorSettingsForm::generateSettingsForm method.
File
-
core/
tests/ Drupal/ Tests/ Core/ Theme/ Icon/ IconExtractorSettingsFormTest.php, line 377
Class
Namespace
Drupal\Tests\Core\Theme\IconCode
public function testGenerateSettingsFormWithValues() : void {
$options = [
'test_saved' => [
'title' => 'Test Saved',
'description' => 'Form test saved',
'type' => 'string',
],
];
$form_state = $this->createStub(SubformStateInterface::class);
$subform_state = $this->createMock(SubformStateInterface::class);
$form_state->method('getCompleteFormState')
->willReturn($subform_state);
$subform_state->expects($this->once())
->method('getValue')
->with('saved_values')
->willReturn([
'test_saved' => 'saved value',
]);
$actual = IconExtractorSettingsForm::generateSettingsForm($options, $form_state);
$expected = [
'test_saved' => [
'#title' => $options['test_saved']['title'],
'#description' => $options['test_saved']['description'],
'#default_value' => 'saved value',
'#type' => 'textfield',
],
];
$this->assertSame($expected, $actual);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.