function ContentUICrud::testFieldContentUI in Content Construction Kit (CCK) 6.3
Same name and namespace in other branches
- 6.2 tests/content.crud.test \ContentUICrud::testFieldContentUI()
File
- tests/
content.crud.test, line 840
Class
Code
function testFieldContentUI() {
// Create a content type with a field
$type1 = 'simpletest' . mt_rand();
$type1_obj = $this
->drupalCreateContentType(array(
'type' => $type1,
));
$admin_type1_url = 'admin/content/node-type/' . $type1;
$field_name = strtolower($this
->randomName(10));
$field_url = 'field_' . $field_name;
$field = $this
->createFieldText(array(
'text_processing' => 1,
'multiple' => 0,
'field_name' => $field_url,
), $type1_obj);
// Save a node with content in the text field
$edit = array();
$edit['title'] = $this
->randomName(20);
$edit['body'] = $this
->randomName(20);
$value = $this
->randomName(20);
$edit[$field_url . '[0][value]'] = $value;
$this
->drupalPost('node/add/' . $type1, $edit, 'Save');
$node = node_load(array(
'title' => $edit['title'],
));
$this
->drupalGet('node/' . $node->nid);
$this
->assertText($value, 'Textfield value saved and displayed');
// Alter the field to have unlimited values
$edit = array();
$edit['multiple'] = '1';
$this
->drupalPost($admin_type1_url . '/fields/' . $field_url, $edit, 'Save field settings');
// Save a node with content in multiple text fields
$edit = array();
$edit['title'] = $this
->randomName(20);
$edit['body'] = $this
->randomName(20);
// Add more textfields (non-JS).
$this
->drupalPost('node/add/' . $type1, $edit, "Add another item");
$this
->drupalPost(NULL, $edit, "Add another item");
$value1 = $this
->randomName(20);
$value2 = $this
->randomName(20);
$value3 = $this
->randomName(20);
$edit[$field_url . '[0][value]'] = $value1;
$edit[$field_url . '[1][value]'] = $value2;
$edit[$field_url . '[2][value]'] = $value3;
// This will fail if we don't have at least 3 textfields.
$this
->drupalPost(NULL, $edit, 'Save');
$node = node_load(array(
'title' => $edit['title'],
));
$this
->drupalGet('node/' . $node->nid);
$this
->assertText($value3, '3rd textfield value saved and displayed');
}