You are here

public function TimestampTest::testImportTimestamp in Feeds 8.3

Tests importing from a timestamp.

File

tests/src/Kernel/Feeds/Target/TimestampTest.php, line 40

Class

TimestampTest
@coversDefaultClass \Drupal\feeds\Feeds\Target\Timestamp @group feeds

Namespace

Drupal\Tests\feeds\Kernel\Feeds\Target

Code

public function testImportTimestamp() {
  $this->feedType
    ->addMapping([
    'target' => 'created',
    'map' => [
      'value' => 'created',
    ],
  ]);
  $this->feedType
    ->save();

  // Import.
  $feed = $this
    ->createFeed($this->feedType
    ->id(), [
    'source' => $this
      ->resourcesPath() . '/csv/content_date.csv',
  ]);
  $feed
    ->import();

  // Assert three created nodes.
  $this
    ->assertNodeCount(3);
  $expected = [
    1 => 1251936720,
    2 => 1251932360,
    3 => 1190835120,
  ];
  foreach ($expected as $nid => $value) {
    $node = Node::load($nid);
    $this
      ->assertEquals($value, $node->created->value);
  }
}