You are here

public function FeedsMapperFieldTestCase::testIntegerFieldValidation in Feeds 7.2

Tests integer field validation.

File

tests/feeds_mapper_field.test, line 285
Contains FeedsMapperFieldTestCase.

Class

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

Code

public function testIntegerFieldValidation() {

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

  // 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,
  ));
  $this
    ->addMappings('csv', array(
    0 => array(
      'source' => 'title',
      'target' => 'title',
    ),
    1 => array(
      'source' => 'beta',
      'target' => 'field_beta',
    ),
  ));
  $this
    ->importFile('csv', $this
    ->absolutePath() . '/tests/feeds/content.csv');
  $this
    ->assertText('Created 1 node');
  $this
    ->assertText('Failed importing 1 node.');
  $this
    ->assertText("Field validation errors in item 'Lorem ipsum'");
  $this
    ->assertText('beta_number_integer_label: the value may be no greater than 40.');
}