function NodeDisplaysBuildModes::testBuildModesMatrix in Node displays 6
Same name and namespace in other branches
- 6.3 tests/nd.buildmodes.test \NodeDisplaysBuildModes::testBuildModesMatrix()
- 6.2 tests/nd.buildmodes.test \NodeDisplaysBuildModes::testBuildModesMatrix()
- 7 tests/nd.buildmodes.test \NodeDisplaysBuildModes::testBuildModesMatrix()
Test matrix build modes.
File
- tests/
nd.buildmodes.test, line 52 - Tests for Node displays (Build modes)
Class
- NodeDisplaysBuildModes
- @file Tests for Node displays (Build modes)
Code
function testBuildModesMatrix() {
$admin_user = $this
->drupalCreateUser(array(
'administer content types',
'administer nodes',
));
$this
->drupalLogin($admin_user);
$exclude_build_modes = variable_get('nd_buildmodes_exclude', array());
$this
->assertEqual(array(), $exclude_build_modes, t('Preprocess exclude is empty'), t('ND settings exclude'));
// Page display settings.
$edit = array(
'title[full][region]' => 'header',
);
$this
->drupalPost('admin/content/node-type/page/display', $edit, t('Save'));
$edit = array(
'title[teaser][region]' => 'header',
);
$this
->drupalPost('admin/content/node-type/page/display/teaser', $edit, t('Save'));
// Story display settings.
$edit = array(
'title[full][region]' => 'header',
);
$this
->drupalPost('admin/content/node-type/story/display', $edit, t('Save'));
$edit = array(
'title[teaser][region]' => 'header',
);
$this
->drupalPost('admin/content/node-type/story/display/teaser', $edit, t('Save'));
// Create page & story node.
$page_node = $this
->drupalCreateNode();
$story_node = $this
->drupalCreateNode(array(
'type' => 'story',
));
// Test on render_by_nd property.
$page_object = $this
->_nd_build_object($page_node);
$this
->assertTrue($page_object->render_by_nd, t('Page full rendered by ND'), t('ND settings exclude'));
$story_object = $this
->_nd_build_object($page_node);
$this
->assertTrue($story_object->render_by_nd, t('Story full rendered by ND'), t('ND settings exclude'));
// Exclude page teaser & story full.
$edit = array(
'page-teaser' => TRUE,
'story-full' => TRUE,
);
$this
->drupalPost('admin/content/types/nd/buildmodes', $edit, t('Save settings'));
$exclude_build_modes = variable_get('nd_buildmodes_exclude', array());
$this
->assertTrue($exclude_build_modes['page']['teaser'], t('Teaser page will not be processed'), t('ND settings matrix'));
$this
->assertTrue($exclude_build_modes['story']['full'], t('Story full will not be processed'), t('ND settings matrix'));
// Test on render_by_nd property.
$page_object = $this
->_nd_build_object($page_node, 'teaser', TRUE, FALSE);
$this
->assertFalse($page_object->render_by_nd, t('Page teaser not rendered by ND'), t('ND settings exclude'));
$story_object = $this
->_nd_build_object($story_node, 'full', FALSE, TRUE);
$this
->assertFalse($story_object->render_by_nd, t('Story full not rendered by ND'), t('ND settings exclude'));
// de-exclude page-teaser again.
$edit = array(
'page-teaser' => FALSE,
'story-full' => TRUE,
);
$this
->drupalPost('admin/content/types/nd/buildmodes', $edit, t('Save settings'));
$exclude_build_modes = variable_get('nd_buildmodes_exclude', array());
$this
->assertFalse($exclude_build_modes['page']['teaser'], t('Teaser page will not be processed'), t('ND settings matrix'));
$this
->assertTrue($exclude_build_modes['story']['full'], t('Story full will not be processed'), t('ND settings matrix'));
// Test on render_by_nd property.
$page_object = $this
->_nd_build_object($page_node, 'teaser', TRUE, FALSE);
$this
->assertTrue($page_object->render_by_nd, t('Page teaser rendered by ND'), t('ND settings exclude'));
$story_object = $this
->_nd_build_object($story_node, 'full', FALSE, TRUE);
$this
->assertFalse($story_object->render_by_nd, t('Story full not rendered by ND'), t('ND settings exclude'));
}