function NodeDisplaysFields::testNdCustomLabels in Node displays 6.3
Same name and namespace in other branches
- 6.2 tests/nd.fields.test \NodeDisplaysFields::testNdCustomLabels()
- 7 tests/nd.fields.test \NodeDisplaysFields::testNdCustomLabels()
Test custom field labels.
File
- tests/
nd.fields.test, line 267 - Tests for Node displays (fields)
Class
- NodeDisplaysFields
- @file Tests for Node displays (fields)
Code
function testNdCustomLabels() {
$admin_user = $this
->drupalCreateUser(array(
'administer nodes',
'access display suite',
'administer nd',
'configure layout for nd',
'export and import settings',
'revert overridden settings',
'use PHP in custom fields',
));
$this
->drupalLogin($admin_user);
$this
->drupalGet('admin/build/ds/nd/fields');
$fields = variable_get('nd_fields', array());
// Add a new real field.
$edit = array(
'code_key' => 'test_field_real',
'code_title' => 'Real field',
'code_code' => '<?php echo "Output of a custom field"; ?>',
);
$this
->drupalPost('admin/build/ds/nd/fields', $edit, t('Save code field'));
// Make sure we can use the fields for this test.
$edit = array(
'title[full][region]' => 'header',
'title[full][label][format]' => 'above',
'test_field_real[full][region]' => 'middle',
'test_field_real[full][label][format]' => 'above',
);
$this
->drupalPost('admin/build/ds/layout/page/full', $edit, t('Save'));
// Create page.
$page_node = $this
->drupalCreateNode(array(
'title' => 'MyTitle',
));
// Check the value of the labels.
$this
->assertText('Title', t('Title label is shown on page.'), t('Labels'));
$this
->assertText('Real field', t('Custom field label is shown on page.'), t('Labels'));
// Change the label of this new real field.
// Note: run this patch on D6 to allow posts to hidden fields:
// http://drupal.org/node/488810#comment-1693662 .
$edit = array(
'title[full][label_value]' => 'New Title',
'test_field_real[full][label_value]' => 'Unreal field',
);
$this
->drupalPost('admin/build/ds/layout/page/full', $edit, t('Save'));
// See if the label values have changed.
$out = $this
->drupalGet('node/' . $page_node->nid);
$this
->assertText('New Title', t('The title label is changed.'), t('Labels'));
$this
->assertText('Unreal field', t('The custom field label is changed.'), t('Labels'));
}