function ContentMigrateTextTestCase::testMultiNodeTextMigrate in Content Construction Kit (CCK) 7.3
Test multiple node import of a text field.
File
- modules/
content_migrate/ tests/ content_migrate.test, line 466 - Content Migrate Test Cases
Class
- ContentMigrateTextTestCase
- @class Content Migrate Text Test Case.
Code
function testMultiNodeTextMigrate() {
// We need a field to migrate.
$test_field = $this
->setupField('text', 'text_textfield', 0, 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,
);
$nodes = array();
for ($i = 0; $i < 3; $i++) {
$nodes[$i] = $this
->drupalCreateNode($settings);
// Add arbitrary field data to the node.
$value = array(
'value' => $this
->randomName(10),
);
$this
->createFieldData($value, $test_field, $nodes[$i], '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'));
for ($i = 0; $i < 3; $i++) {
// Check to see if the node has the field label on it.
// @todo Check data integrity instead?
$this
->drupalGet('node/' . $nodes[$i]->nid);
$this
->assertText($test_field['label'], t('Found field, %field, on node %node.', array(
'%field' => $test_field['field_name'],
'%node' => $nodes[$i]->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'],
)));
$this
->drupalLogout();
}