You are here

feeds_mapper_emfield.test in Feeds 6

Same filename and directory in other branches
  1. 7 tests/feeds_mapper_emfield.test

Test case for simple CCK field mapper mappers/emfield.inc.

File

tests/feeds_mapper_emfield.test
View source
<?php

module_load_include('test', 'feeds', 'tests/feeds_mapper');

/**
 * @file
 * Test case for simple CCK field mapper mappers/emfield.inc.
 */

/**
 * Class for testing Feeds <em>emfield</em> mapper.
 */
class FeedsMapperEmfieldTestCase extends FeedsMapperTestCase {
  public static function getInfo() {
    return array(
      'name' => 'Mapper: Emfield',
      'description' => 'Test Feeds Mapper support for Emfield CCK fields.',
      'group' => 'Feeds',
      'dependencies' => array(
        'content',
        'emfield',
      ),
    );
  }
  function setUp() {
    parent::setUp(array(
      'content',
      'emfield',
      'emvideo',
    ));
  }

  /**
   * Basic test loading a doulbe entry CSV file.
   */
  function test() {

    // Create content type.
    $typename = $this
      ->createContentType(array(), array(
      'video' => array(
        'type' => 'emvideo',
        'widget' => 'emvideo_textfields',
      ),
    ));

    // Create and configure importer.
    $this
      ->createImporterConfiguration('Emfield CSV', 'csv');
    $this
      ->setSettings('csv', NULL, array(
      'content_type' => '',
      'import_period' => FEEDS_SCHEDULE_NEVER,
    ));
    $this
      ->setPlugin('csv', 'FeedsFileFetcher');
    $this
      ->setPlugin('csv', 'FeedsCSVParser');
    $this
      ->setSettings('csv', 'FeedsNodeProcessor', array(
      'content_type' => $typename,
    ));
    $this
      ->addMappings('csv', array(
      array(
        'source' => 'title',
        'target' => 'title',
      ),
      array(
        'source' => 'created',
        'target' => 'created',
      ),
      array(
        'source' => 'body',
        'target' => 'body',
      ),
      array(
        'source' => 'video',
        'target' => 'field_video',
      ),
    ));

    // Import CSV file.
    $this
      ->importFile('csv', $this
      ->absolutePath() . '/tests/feeds/emfield.csv');
    $this
      ->assertText('Created 2 ' . $typename . ' nodes.');

    // Check the two imported files.
    $this
      ->drupalGet('node/1/edit');
    $this
      ->assertFieldByName('field_video[0][embed]', 'http://www.youtube.com/watch?v=gpkhANg919Y');
    $this
      ->drupalGet('node/2/edit');
    $this
      ->assertFieldByName('field_video[0][embed]', 'http://www.youtube.com/watch?v=ewAGXAeCXJY');
  }

}

Classes

Namesort descending Description
FeedsMapperEmfieldTestCase Class for testing Feeds <em>emfield</em> mapper.