You are here

public function ContextTestTrait::testSetInvalidContext in Feeds extensible parsers 8

Tests setting an invalid context on the mapping form.

@covers ::mappingFormAlter @covers ::mappingFormValidate

@dataProvider dataProviderInvalidContext

File

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

Class

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

Namespace

Drupal\Tests\feeds_ex\Functional\Feeds\Parser

Code

public function testSetInvalidContext($context, $expected_error, $expected_context = '') {
  $edit = [
    'context' => $context,
  ];
  $this
    ->drupalPostForm('/admin/structure/feeds/manage/' . $this->feedType
    ->id() . '/mapping', $edit, 'Save');
  $this
    ->assertText($expected_error);

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