You are here

public function MappingFormTest::testPluginWithMappingFormValidate in Feeds 8.3

Tests that plugins validate the mapping form.

File

tests/src/Functional/Form/MappingFormTest.php, line 75

Class

MappingFormTest
@coversDefaultClass \Drupal\feeds\Form\MappingForm @group feeds

Namespace

Drupal\Tests\feeds\Functional\Form

Code

public function testPluginWithMappingFormValidate() {
  $feed_type = $this
    ->createFeedType([
    'parser' => 'parser_with_mapping_form',
  ]);

  // ParserWithMappingForm::mappingFormValidate() doesn't accept the value
  // 'invalid'.
  $edit = [
    'dummy' => 'invalid',
  ];
  $this
    ->drupalPostForm('/admin/structure/feeds/manage/' . $feed_type
    ->id() . '/mapping', $edit, 'Save');
  $this
    ->assertText('Invalid value.');

  // Assert that the dummy value was *not* saved for the parser.
  $feed_type = $this
    ->reloadEntity($feed_type);
  $config = $feed_type
    ->getParser()
    ->getConfiguration();
  $this
    ->assertEquals('', $config['dummy']);
}