public function AggregatorPluginSettingsBaseTest::testSettingsForm in Drupal 9
Same name and namespace in other branches
- 8 core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php \Drupal\Tests\aggregator\Unit\Plugin\AggregatorPluginSettingsBaseTest::testSettingsForm()
Tests for AggregatorPluginSettingsBase.
Ensure that the settings form calls build, validate and submit methods on plugins that extend AggregatorPluginSettingsBase.
File
- core/
modules/ aggregator/ tests/ src/ Unit/ Plugin/ AggregatorPluginSettingsBaseTest.php, line 79
Class
- AggregatorPluginSettingsBaseTest
- Tests settings configuration of individual aggregator plugins.
Namespace
Drupal\Tests\aggregator\Unit\PluginCode
public function testSettingsForm() {
// Emulate a form state of a submitted form.
$form_state = (new FormState())
->setValues([
'dummy_length' => '',
'aggregator_allowed_html_tags' => '',
]);
$test_processor = $this
->getMockBuilder('Drupal\\aggregator_test\\Plugin\\aggregator\\processor\\TestProcessor')
->setMethods([
'buildConfigurationForm',
'validateConfigurationForm',
'submitConfigurationForm',
])
->setConstructorArgs([
[],
'aggregator_test',
[
'description' => '',
],
$this->configFactory,
])
->getMock();
$test_processor
->expects($this
->once())
->method('buildConfigurationForm')
->with($this
->anything(), $form_state)
->will($this
->returnArgument(0));
$test_processor
->expects($this
->once())
->method('validateConfigurationForm')
->with($this
->anything(), $form_state);
$test_processor
->expects($this
->once())
->method('submitConfigurationForm')
->with($this
->anything(), $form_state);
$this->managers['processor']
->expects($this
->once())
->method('createInstance')
->with($this
->equalTo('aggregator_test'))
->will($this
->returnValue($test_processor));
$form = $this->settingsForm
->buildForm([], $form_state);
$this->settingsForm
->validateForm($form, $form_state);
$this->settingsForm
->submitForm($form, $form_state);
}