You are here

public function ContextTestTrait::testSetContext in Feeds extensible parsers 8

Tests setting a context on the mapping form.

@covers ::mappingFormAlter @covers ::mappingFormValidate @covers ::mappingFormSubmit

@dataProvider dataProviderValidContext

File

tests/src/Functional/Feeds/Parser/ContextTestTrait.php, line 19

Class

ContextTestTrait
Trait for testing the context field on the mapping form.

Namespace

Drupal\Tests\feeds_ex\Functional\Feeds\Parser

Code

public function testSetContext($context, $expected_context = NULL) {
  if (is_null($expected_context)) {
    $expected_context = $context;
  }
  $edit = [
    'context' => $context,
  ];
  $this
    ->drupalPostForm('/admin/structure/feeds/manage/' . $this->feedType
    ->id() . '/mapping', $edit, 'Save');

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