public function FeedsParaMapperSingleValueTestCase::testImport in Feeds Paragraphs 7
Test importing nodes with paragraphs field value.
- Tests importing a node.
- Checks that the host Paragraphs field exists on the created node.
- Check that the paragraphs bundle field value matches the source.
File
- tests/
importing.test, line 31 - Contains ImportingTestCase.
Class
- FeedsParaMapperSingleValueTestCase
- Tests importing a single value to a content type with a Paragraphs field.
Code
public function testImport() {
parent::import();
parent::topHostParagraphsFieldExists();
parent::topHostParagraphsEntityExists();
$items = parent::getTopHostParagraphsEntities();
$bundle_field = "field_" . $this->bundles[0]['fields'][0]['name'];
$lang = $items[0]
->langcode();
$value_exists = isset($items[0]->{$bundle_field}[$lang][0]['value']);
$message = "The bundle field value exists";
$this
->assertTrue($value_exists, $message, 'Importing');
$source_value = "This is a dummy text";
$value_matches = $items[0]->{$bundle_field}[$lang][0]['value'] === $source_value;
$message = "The value of the bundle field matches the source value";
$this
->assertTrue($value_matches, $message, 'Importing');
$this
->checkFileFieldImport();
}