public function FeedsMapperFieldTestCase::testTextFieldValidationForUsers in Feeds 7.2
Tests text field validation for users.
File
- tests/
feeds_mapper_field.test, line 432 - Contains FeedsMapperFieldTestCase.
Class
- FeedsMapperFieldTestCase
- Test case for simple CCK field mapper mappers/content.inc.
Code
public function testTextFieldValidationForUsers() {
// Create a field with settings to validate.
field_create_field(array(
'field_name' => 'field_alpha',
'type' => 'text',
'settings' => array(
'max_length' => 5,
),
));
field_create_instance(array(
'field_name' => 'field_alpha',
'entity_type' => 'user',
'label' => 'alpha_text_label',
'bundle' => 'user',
'widget' => array(
'type' => 'text_textfield',
),
));
// Create and configure importer.
$this
->createImporterConfiguration('Content CSV', 'csv');
$this
->setSettings('csv', NULL, array(
'content_type' => '',
'import_period' => FEEDS_SCHEDULE_NEVER,
));
$this
->setPlugin('csv', 'FeedsFileFetcher');
$this
->setPlugin('csv', 'FeedsCSVParser');
$this
->setPlugin('csv', 'FeedsUserProcessor');
$this
->addMappings('csv', array(
0 => array(
'source' => 'title',
'target' => 'name',
),
1 => array(
'source' => 'alpha',
'target' => 'field_alpha',
),
));
// Import CSV file. Users should fail to import because mail address is
// missing.
$this
->importFile('csv', $this
->absolutePath() . '/tests/feeds/content.csv');
$this
->assertText('Failed importing 2 users.');
$this
->assertText('User name missing or email not valid.');
$this
->assertText("Field validation errors in item 'Ut wisi enim ad minim veniam'");
$this
->assertText('alpha_text_label: the text may not be longer than 5 characters.');
}