You are here

public function FeedsFileFetcherTest::testPrivateFiles in Feeds 8.2

Test uploading private files.

File

lib/Drupal/feeds/Tests/FeedsFileFetcherTest.php, line 76
File fetcher tests.

Class

FeedsFileFetcherTest
File fetcher test class.

Namespace

Drupal\feeds\Tests

Code

public function testPrivateFiles() {

  // Set up an importer.
  $this
    ->createImporterConfiguration('Node import', 'node');

  // Set and configure plugins and mappings.
  $this
    ->setSettings('node', NULL, array(
    'content_type' => '',
  ));
  $this
    ->setPlugin('node', 'file');
  $this
    ->setPlugin('node', 'csv');
  $this
    ->addMappings('node', array(
    0 => array(
      'source' => 'title',
      'target' => 'title',
    ),
  ));

  // Straight up upload is covered in other tests, focus on direct mode
  // and file batching here.
  $this
    ->setSettings('node', 'file', array(
    'direct' => TRUE,
    'directory' => 'private://feeds',
  ));

  // Verify batching through directories.
  // Copy directory of files.
  $dir = 'private://batchtest';
  $this
    ->copyDir($this
    ->absolutePath() . '/tests/feeds/batch', $dir);

  // Ingest directory of files. Set limit to 5 to force processor to batch,
  // too.
  variable_set('feeds_process_limit', 5);
  $edit = array(
    'feeds[Drupal\\feeds\\Plugin\\feeds\\fetcher\\FeedsFileFetcher][source]' => $dir,
  );
  $this
    ->drupalPost('import/node', $edit, t('Import'));
  $this
    ->assertText('Created 18 nodes');
}