function NodeDisplaysDefaults::testDefaults in Node displays 6.2
Same name and namespace in other branches
- 6.3 tests/nd.tools.test \NodeDisplaysDefaults::testDefaults()
- 7 tests/nd.tools.test \NodeDisplaysDefaults::testDefaults()
Test defaults.
File
- tests/
nd.tools.test, line 39 - Tests for Node displays (defaults)
Class
- NodeDisplaysDefaults
- @file Tests for Node displays (defaults)
Code
function testDefaults() {
drupal_flush_all_caches();
$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);
// Verify settings are default.
$settings = ds_get_settings('nd', 'page', 'full', 'settings', TRUE);
$this
->assertEqual($settings['status'], DS_SETTINGS_DEFAULT, t('Settings for page full are default'), t('Default settings'));
// Verify that test key is available on page but not on story.
$this
->drupalGet(DS_PATH_LAYOUT . '/page/full');
$this
->assertRaw('edit-test-key-full-label-value', t('Default test key found'), t('Default fields'));
$this
->drupalGet(DS_PATH_LAYOUT . '/story/full');
$this
->assertNoRaw('edit-test-key-full-label-value', t('Default test key not found'), t('Default fields'));
// Verify test key is rendered.
$page_node = $this
->drupalCreateNode();
$this
->drupalGet('node/' . $page_node->nid);
$this
->assertText('Test key: ' . $page_node->nid, t('Test key rendered.'), t('Default fields'));
// Verify that we have overriden settings by disabling test key.
$edit = array(
'author[full][region]' => 'header',
'post_date[full][region]' => 'header',
'body[full][region]' => 'middle',
'test_key[full][region]' => 'disabled',
);
$this
->drupalPost(DS_PATH_LAYOUT . '/page/full', $edit, t('Save'));
$this
->drupalGet('node/' . $page_node->nid);
$this
->assertNoText('Test key: ' . $page_node->nid, t('Test key not rendered.'), t('Default fields'));
// Verify display settings are overriden.
$settings = ds_get_settings('nd', 'page', 'full', 'settings', TRUE);
$this
->assertEqual($settings['status'], DS_SETTINGS_OVERRIDDEN, t('Settings for page full are overriden'), t('Default settings'));
// Verify we can revert to default settings and se test key is rendered again.
$this
->drupalPost(DS_PATH_TOOLS . '/revert/nd/page/full', array(), t('Confirm'));
$this
->drupalGet('node/' . $page_node->nid);
$this
->assertText('Test key: ' . $page_node->nid, t('Test key rendered.'), t('Default fields'));
// Verify settings are default again.
$settings = ds_get_settings('nd', 'page', 'full', 'settings', TRUE);
$this
->assertEqual($settings['status'], DS_SETTINGS_DEFAULT, t('Settings for page full are default'), t('Default settings'));
}