function ContentMigrateTextTestCase::testMultiValueTextFieldMigration in Content Construction Kit (CCK) 7.3
Test multiple valued text fields.
File
- modules/
content_migrate/ tests/ content_migrate.test, line 416 - Content Migrate Test Cases
Class
- ContentMigrateTextTestCase
- @class Content Migrate Text Test Case.
Code
function testMultiValueTextFieldMigration() {
// We need a field to migrate.
$test_field = $this
->setupField('text', 'text_textfield', 3, 0, '');
// Save the field and field_instance to the database. And alter table.
$this
->createField($test_field);
// Create a node to work with.
$settings = array(
'type' => $this->content_type->type,
);
$test_node = $this
->drupalCreateNode($settings);
$values = array();
// Add arbitrary field data to the node.
for ($i = 0; $i < 3; $i++) {
$values[$i] = array(
'value' => $this
->randomName(10),
);
$this
->createFieldData($values[$i], $test_field, $test_node, 'content_type_' . $settings['type'], $i);
}
// Okay let's do the work.
$this
->drupalLogin($this->admin_user);
$id = str_replace('_', '-', $test_field['field_name']);
$this
->drupalGet('admin/structure/content_migrate');
$this
->assertNoFieldChecked('edit-available-data-' . $id, t('Found form field for CCK field %field.', array(
'%field' => $test_field['field_name'],
)));
$edit = array(
'available[data][' . $test_field['field_name'] . ']' => $test_field['field_name'],
);
$this
->drupalPost('admin/structure/content_migrate', $edit, t('Migrate selected fields'));
// Check to see if the node has the field label on it.
// @todo Check data integrity instead?
$this
->drupalGet('node/' . $test_node->nid);
$this
->assertText($test_field['label'], t('Found field, %field, on node %node.', array(
'%field' => $test_field['field_name'],
'%node' => $test_node->title,
)));
// Check to make sure field instance is displayed on the manage fields page.
$this
->drupalGet('admin/structure/types/manage/' . $this->content_type->type . '/fields');
$this
->assertText($test_field['label'], t('Found label, %label, for field, %field, on content type field administration page.', array(
'%field' => $test_field['field_name'],
'%label' => $test_field['label'],
)));
// Test the most important setting, number of values, for this test.
$this
->drupalGet('admin/structure/types/manage/' . $this->content_type->type . '/fields/' . $test_field['field_name']);
$this
->assertOptionSelected('edit-field-cardinality', 3, t('Number of values set to 3.'));
$this
->drupalLogout();
}