public function FeedsMapperFieldTestCase::testTextFieldValidationWithoutNodeTitle in Feeds 7.2
Tests text field validation for nodes without a title.
The error message should refer the GUID of an item if the entity has no label.
File
- tests/
feeds_mapper_field.test, line 331 - Contains FeedsMapperFieldTestCase.
Class
- FeedsMapperFieldTestCase
- Test case for simple CCK field mapper mappers/content.inc.
Code
public function testTextFieldValidationWithoutNodeTitle() {
// Create a field with settings to validate.
$max_length = 5;
$typename = $this
->createContentType(array(), array(
'alpha' => array(
'type' => 'text',
'settings' => array(
'field[settings][max_length]' => $max_length,
),
),
));
// 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
->setSettings('csv', 'FeedsNodeProcessor', array(
'bundle' => $typename,
));
$this
->addMappings('csv', array(
0 => array(
'source' => 'guid',
'target' => 'guid',
),
1 => array(
'source' => 'alpha',
'target' => 'field_alpha',
),
));
// Import CSV file.
$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 '2'");
$this
->assertText('alpha_text_label: the text may not be longer than 5 characters.');
}