function NodeDisplaysRegions::testRendering in Node displays 6.3
Same name and namespace in other branches
- 6 tests/nd.regions.test \NodeDisplaysRegions::testRendering()
- 6.2 tests/nd.regions.test \NodeDisplaysRegions::testRendering()
- 7 tests/nd.regions.test \NodeDisplaysRegions::testRendering()
Test if nodeapi & preprocess do their job good by excluding fields and putting them in the right region.
File
- tests/
nd.regions.test, line 79 - Tests for Node displays (regions)
Class
- NodeDisplaysRegions
- @file Tests for Node displays (regions)
Code
function testRendering() {
$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);
$page_node = $this
->drupalCreateNode();
// First post.
$edit = array(
'title[full][region]' => 'header',
'author[full][region]' => 'middle',
'body[full][region]' => 'middle',
'links[full][region]' => 'footer',
'post_date[full][region]' => 'disabled',
);
$this
->drupalPost('admin/build/ds/layout/page/full', $edit, t('Save'));
$page_object = $this
->_nd_build_object($page_node);
$this
->assertTrue(in_array('title', array_keys($page_object->regions['header'])), t('Title is in header region'), t('Rendering tests'));
$this
->assertTrue(in_array('author', array_keys($page_object->regions['middle'])), t('Author is in middle region'), t('Rendering tests'));
$this
->assertTrue(in_array('body', array_keys($page_object->regions['middle'])), t('Body is in middle region'), t('Rendering tests'));
$this
->assertTrue(in_array('links', array_keys($page_object->regions['footer'])), t('Links is in footer region'), t('Rendering tests'));
$this
->assertTrue($this
->_nd_field_not_found('post_date', $page_object->regions), t('Post date is disabled'), t('Rendering tests'));
// Just surf to a page to reset the static cache of ds_get_settings();
$this
->drupalGet('node');
// Let's do another one..
$edit = array(
'title[full][region]' => 'disabled',
'author[full][region]' => 'right',
'body[full][region]' => 'middle',
'links[full][region]' => 'footer',
'post_date[full][region]' => 'footer',
);
$this
->drupalPost('admin/build/ds/layout/page/full', $edit, t('Save'));
// Reset the static cache.
$settings = ds_get_settings('nd', 'page', 'full', 'settings', TRUE);
// Now verify.
$page_object = $this
->_nd_build_object($page_node);
$this
->assertTrue(in_array('post_date', array_keys($page_object->regions['footer'])), t('Post date is in footer region'), t('Rendering tests'));
$this
->assertTrue(in_array('author', array_keys($page_object->regions['right'])), t('Author is in right region'), t('Rendering tests'));
$this
->assertTrue(in_array('body', array_keys($page_object->regions['middle'])), t('Body is in middle region'), t('Rendering tests'));
$this
->assertTrue(in_array('links', array_keys($page_object->regions['footer'])), t('Links is in footer region'), t('Rendering tests'));
$this
->assertTrue($this
->_nd_field_not_found('title', $page_object->regions), t('Title is disabled'), t('Rendering tests'));
}