You are here

public function AggregatorPluginSettingsBaseTest::testSettingsForm in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php \Drupal\Tests\aggregator\Unit\Plugin\AggregatorPluginSettingsBaseTest::testSettingsForm()

Test 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\Plugin

Code

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
    ->at(0))
    ->method('buildConfigurationForm')
    ->with($this
    ->anything(), $form_state)
    ->will($this
    ->returnArgument(0));
  $test_processor
    ->expects($this
    ->at(1))
    ->method('validateConfigurationForm')
    ->with($this
    ->anything(), $form_state);
  $test_processor
    ->expects($this
    ->at(2))
    ->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);
}