You are here

public function FieldTest::test in Feeds 8.3

Basic test loading a double entry CSV file.

File

tests/src/Kernel/Feeds/Target/FieldTest.php, line 119

Class

FieldTest
Tests for mapping to text and numeric fields.

Namespace

Drupal\Tests\feeds\Kernel\Feeds\Target

Code

public function test() {

  // Import CSV file.
  $feed = $this
    ->createFeed($this->feedType
    ->id(), [
    'source' => $this
      ->resourcesPath() . '/csv/content.csv',
  ]);
  $feed
    ->import();
  $this
    ->assertNodeCount(2);

  // Check the two imported nodes.
  $expected_values_per_node = [
    1 => [
      'body' => 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.',
      'field_alpha' => 'Lorem',
      'field_beta' => '42',
      'field_gamma' => '4.20',
      'field_delta' => '3.14159',
    ],
    2 => [
      'body' => 'Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.',
      'field_alpha' => 'Ut wisi',
      'field_beta' => '32',
      'field_gamma' => '1.20',
      'field_delta' => '5.62951',
    ],
  ];
  $this
    ->checkValues($expected_values_per_node);
}