You are here

public function FeedsMapperFieldTestCase::testIgnoreUnmappedFieldsValidation in Feeds 7.2

Tests that Feeds ignores validation of fields not mapped to.

File

tests/feeds_mapper_field.test, line 534
Contains FeedsMapperFieldTestCase.

Class

FeedsMapperFieldTestCase
Test case for simple CCK field mapper mappers/content.inc.

Code

public function testIgnoreUnmappedFieldsValidation() {

  // Include FeedsProcessor.inc so processor related constants are available.
  module_load_include('inc', 'feeds', 'plugins/FeedsProcessor');

  // Create content type with a field with settings to validate.
  $typename = $this
    ->createContentType(array(), array(
    'alpha' => 'text',
    'beta' => array(
      'type' => 'number_integer',
      'instance_settings' => array(
        'instance[settings][min]' => 30,
        'instance[settings][max]' => 50,
      ),
    ),
  ));

  // Create a node of this type with an out of range integer value.
  $this
    ->drupalCreateNode(array(
    'type' => $typename,
    'title' => 'Lorem ipsum',
    'field_beta' => array(
      LANGUAGE_NONE => array(
        0 => array(
          'value' => 25,
        ),
      ),
    ),
  ));

  // Create and configure importer.
  $this
    ->createImporterConfiguration('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(
    'bundle' => $typename,
    'update_existing' => FEEDS_UPDATE_EXISTING,
  ));
  $this
    ->addMappings('csv', array(
    0 => array(
      'source' => 'title',
      'target' => 'title',
      'unique' => TRUE,
    ),
    1 => array(
      'source' => 'alpha',
      'target' => 'field_alpha',
    ),
  ));
  $this
    ->importFile('csv', $this
    ->absolutePath() . '/tests/feeds/content.csv');
  $this
    ->assertText('Updated 1 node');
  $this
    ->assertNoText('Field validation errors');
}