You are here

function NodeDisplaysRegions::testRendering in Node displays 6

Same name and namespace in other branches
  1. 6.3 tests/nd.regions.test \NodeDisplaysRegions::testRendering()
  2. 6.2 tests/nd.regions.test \NodeDisplaysRegions::testRendering()
  3. 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 content types',
    'administer nodes',
  ));
  $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',
    'terms[full][region]' => 'disabled',
  );
  $this
    ->drupalPost('admin/content/node-type/page/display', $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('terms', $page_object->regions), t('Terms is disabled'), t('Rendering tests'));

  // Let's do another one..
  $edit = array(
    'title[full][region]' => 'disabled',
    'author[full][region]' => 'right',
    'body[full][region]' => 'middle',
    'links[full][region]' => 'footer',
    'terms[full][region]' => 'footer',
  );
  $this
    ->drupalPost('admin/content/node-type/page/display', $edit, t('Save'));
  $page_object = $this
    ->_nd_build_object($page_node);
  $this
    ->assertTrue(in_array('terms', array_keys($page_object->regions['footer'])), t('Terms 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'));
}