function NodeDisplaysFields::testNdFieldgroups in Display Suite 6.3
Test fieldgroups.
File
- modules/
nd/ tests/ nd.fields.test, line 317 - Tests for Node displays (fields)
Class
- NodeDisplaysFields
- @file Tests for Node displays (fields)
Code
function testNdFieldgroups() {
$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(DS_PATH_MODULES . '/nd/fieldgroups');
$fields = variable_get('nd_fields', array());
// Add a new fieldgroup.
$edit = array(
'key' => 'test_group',
'name' => 'Test group',
);
$this
->drupalPost(DS_PATH_MODULES . '/nd/fieldgroups', $edit, t('Save fieldgroup'));
$fields = variable_get('nd_fields', array());
$this
->assertTrue(array_key_exists('ds_group_test_group', $fields), t('test_group exists'), t('Fieldgroups'));
$this
->assertEqual($fields['ds_group_test_group']['title'], $edit['name'], t('Title equals Test group'), t('Fieldgroups'));
// Make sure we can use the fields for this test.
$edit = array(
'title[full][region]' => 'header',
'title[full][label][format]' => 'above',
'ds_group_test_group[full][region]' => 'header',
'ds_group_test_group[full][label][format]' => 'above',
);
$this
->drupalPost(DS_PATH_LAYOUT . '/page/full', $edit, t('Save'));
// Create page.
$page_node = $this
->drupalCreateNode(array(
'title' => 'MyTitle',
));
// Title must be shown, test group not.
$this
->drupalGet('node/' . $page_node->nid);
$this
->assertText('Title', t('Title is shown on page.'), t('Fieldgroups'));
$this
->assertNoText('Test group', t('Test group is not shown on page.'), t('Fieldgroups'));
// Put title in the test group fieldset.
// Note: run this patch on D6 to allow posts to hidden fields:
// http://drupal.org/node/488810#comment-1693662 .
$edit = array(
'title[full][parent_id]' => 'ds_group_test_group',
);
$this
->drupalPost(DS_PATH_LAYOUT . '/page/full', $edit, t('Save'));
// Title must be shown, inside the fieldgroup div.
$this
->drupalGet('node/' . $page_node->nid);
$this
->assertText('Title', t('Title is shown on page.'), t('Fieldgroups'));
$this
->assertText('Test group', t('Test group is not shown on page.'), t('Fieldgroups'));
}