function ContentMigrateListTestCase::testSelectListMigration in Content Construction Kit (CCK) 7.3
File
- modules/
content_migrate/ tests/ content_migrate.test, line 563 - Content Migrate Test Cases
Class
- ContentMigrateListTestCase
- @class List widget functional test case
Code
function testSelectListMigration() {
// We need a field to migrate.
$values = array();
for ($i = 0; $i < 5; $i++) {
$val = $this
->randomName(10);
$values['value'][$val] = $val;
if ($i == 0) {
$default = array(
'value' => $val,
);
}
else {
if ($i == 2) {
$data = array(
'value' => $val,
);
}
}
}
$test_field = $this
->setupField('text', 'optionwidgets_select', 0, 0, $default, $values);
// 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,
);
$node = $this
->drupalCreateNode($settings);
// Add arbitrary field data to the node.
$this
->createFieldData($data, $test_field, $node, 'content_type_' . $settings['type']);
// 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'));
// Test data integrity
$this
->drupalGet('node/' . $node->nid);
$this
->assertText($test_field['label'], t('Found field, %field, on node %node.', array(
'%field' => $test_field['field_name'],
'%node' => $node->title,
)));
$this
->drupalGet('node/' . $node->nid . '/edit');
$this
->assertOptionSelected('edit-' . $id . '-' . LANGUAGE_NONE, $data['value'], t('Value, %value, was selected in the select list in the node edit form.', array(
'%value' => $data['value'],
)));
// 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'],
)));
// Make sure allowed values matches.
$n = 0;
$allowed_values = '';
foreach ($values['value'] as $val => $label) {
if ($n != 0) {
$allowed_values .= "\n";
}
$allowed_values .= $val . '|' . $label;
$n++;
}
$this
->drupalGet('admin/structure/types/manage/' . $this->content_type->type . '/fields/' . $test_field['field_name']);
$this
->assertFieldById('edit-field-settings-allowed-values', $allowed_values, t('Found allowed values, %values, on the field edit form.', array(
'%values' => $allowed_values,
)));
$this
->drupalLogout();
}