public function MappingFormTest::testMissingTargetWarning in Feeds 8.3
Tests that the mapping page is displayed with a missing target plugin.
File
- tests/
src/ Functional/ Form/ MappingFormTest.php, line 129
Class
- MappingFormTest
- @coversDefaultClass \Drupal\feeds\Form\MappingForm @group feeds
Namespace
Drupal\Tests\feeds\Functional\FormCode
public function testMissingTargetWarning() {
// Create a feed type and map to a non-existent target.
$feed_type = $this
->createFeedType();
$feed_type
->addMapping([
'target' => 'non_existent',
'map' => [
'value' => 'title',
],
]);
$feed_type
->save();
// Go to the mapping page and assert that a warning is being displayed.
$this
->drupalGet('/admin/structure/feeds/manage/' . $feed_type
->id() . '/mapping');
$this
->assertSession()
->pageTextContains('The Feeds target "non_existent" does not exist.');
$this
->assertSession()
->pageTextContains('Error: target is missing (non_existent)');
// Try to resolve the issue by removing the mapping.
$edit = [
'remove_mappings[2]' => 1,
];
$this
->drupalPostForm(NULL, $edit, 'Save');
// Reload the page to clear any warnings.
$this
->drupalGet('/admin/structure/feeds/manage/' . $feed_type
->id() . '/mapping');
// Assert that the warning is no longer displayed.
$this
->assertSession()
->pageTextNotContains('The Feeds target "non_existent" does not exist.');
$this
->assertSession()
->pageTextNotContains('Error: target is missing (non_existent)');
// Assert that the particular mapping no longer exists on the feed type.
$feed_type = $this
->reloadEntity($feed_type);
$this
->assertEquals($this
->getDefaultMappings(), $feed_type
->getMappings());
}