You are here

public function FeedsMapperFileFieldTestCase::test in Feeds 6

Same name and namespace in other branches
  1. 7 tests/feeds_mapper_filefield.test \FeedsMapperFileFieldTestCase::test()

Basic test loading a single entry CSV file.

File

tests/feeds_mapper_filefield.test, line 33
Test case for Filefield mapper mappers/filefield.inc.

Class

FeedsMapperFileFieldTestCase
Class for testing Feeds FileField mapper.

Code

public function test() {
  $static_title = $this
    ->randomName();

  //Create content type
  $typename = $this
    ->createContentType(array(), array(
    'files' => array(
      'type' => 'filefield',
      'settings' => array(
        'multiple' => '1',
        'file_extensions' => 'jpg',
      ),
    ),
  ));

  // Create importer configuration.
  $this
    ->createImporterConfiguration();

  //Create a default importer configuration
  $this
    ->setPlugin('syndication', 'FeedsSimplePieParser');
  $this
    ->setSettings('syndication', 'FeedsNodeProcessor', array(
    'content_type' => $typename,
  ));

  //Processor settings
  $this
    ->addMappings('syndication', array(
    array(
      'source' => 'title',
      'target' => 'title',
    ),
    array(
      'source' => 'timestamp',
      'target' => 'created',
    ),
    array(
      'source' => 'description',
      'target' => 'body',
    ),
    array(
      'source' => 'enclosures',
      'target' => 'field_files',
    ),
  ));
  $nid = $this
    ->createFeedNode('syndication', $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/flickr.xml');
  $this
    ->assertText('Created 4 ' . $typename . ' nodes.');
  $filename = array(
    '3596408735_ce2f0c4824_b',
    '2640019371_495c3f51a2_b',
    '3686290986_334c427e8c_b',
    '2640845934_85c11e5a18_b',
  );
  for ($i = 0; $i < 4; $i++) {
    $this
      ->drupalGet('node/' . ($i + 2) . '/edit');
    $this
      ->assertText($filename[$i]);
  }
}