You are here

public function MediaFeedsMapperMediaTestCase::importSampleFeed in Media Feeds 7

Creates a content type with a media field, a feed importer and imports a sample feed.

1 call to MediaFeedsMapperMediaTestCase::importSampleFeed()
MediaFeedsMapperMediaTestCase::test in tests/media_feeds_mapper.test
Basic test importing a sample feed.

File

tests/media_feeds_mapper.test, line 69
Test case for the Feeds mapping API for the media module.

Class

MediaFeedsMapperMediaTestCase
Class for testing the Media Feeds media_internet mapper.

Code

public function importSampleFeed() {

  // Create a content type with a media field.
  $contentType = $this
    ->createContentType(array(), array(
    'alpha' => array(
      'type' => 'media',
      'widget' => 'media_generic',
    ),
  ));

  // Create a CSV importer configuration.
  $this
    ->createImporterConfiguration('Node import from CVS', 'node');
  $this
    ->setPlugin('node', 'FeedsCSVParser');
  $this
    ->setSettings('node', 'FeedsNodeProcessor', array(
    'content_type' => $contentType,
  ));
  $this
    ->addMappings('node', array(
    array(
      'source' => 'title',
      'target' => 'title',
    ),
    array(
      'source' => 'file',
      'target' => 'field_alpha',
    ),
  ));
  $edit = array(
    'content_type' => '',
  );
  $this
    ->drupalPost('admin/structure/feeds/edit/node/settings', $edit, 'Save');

  // Import.
  $edit = array(
    'feeds[FeedsHTTPFetcher][source]' => url('testing/media_feeds/feed.csv', array(
      'absolute' => TRUE,
    )),
  );
  $this
    ->drupalPost('import/node', $edit, 'Import');
  $this
    ->assertText('Created 1 node');
}