You are here

function NodeDisplaysBuildModes::testBuildModesMatrix in Node displays 7

Same name and namespace in other branches
  1. 6.3 tests/nd.buildmodes.test \NodeDisplaysBuildModes::testBuildModesMatrix()
  2. 6 tests/nd.buildmodes.test \NodeDisplaysBuildModes::testBuildModesMatrix()
  3. 6.2 tests/nd.buildmodes.test \NodeDisplaysBuildModes::testBuildModesMatrix()

Test matrix build modes.

File

tests/nd.buildmodes.test, line 43
Tests for Node displays (Build modes)

Class

NodeDisplaysBuildModes
@file Tests for Node displays (Build modes)

Code

function testBuildModesMatrix() {
  $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);
  $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/ds/layout/page', $edit, t('Save'));
  $edit = array(
    'title[teaser][region]' => 'header',
  );
  $this
    ->drupalPost('admin/ds/layout/page/teaser', $edit, t('Save'));

  // Story display settings.
  $edit = array(
    'title[full][region]' => 'header',
  );
  $this
    ->drupalPost('admin/ds/layout/story', $edit, t('Save'));
  $edit = array(
    'title[teaser][region]' => 'header',
  );
  $this
    ->drupalPost('admin/ds/layout/story/teaser', $edit, t('Save'));

  // Create page & story node.
  $page_node = $this
    ->drupalCreateNode();
  $story_node = $this
    ->drupalCreateNode(array(
    'type' => 'story',
  ));

  // Test on render_by_ds property.
  $page_object = $this
    ->_nd_build_object($page_node);
  $this
    ->assertTrue($page_object->render_by_ds, t('Page full rendered by ND'), t('ND settings exclude'));
  $story_object = $this
    ->_nd_build_object($page_node);
  $this
    ->assertTrue($story_object->render_by_ds, 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/ds/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_ds, 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_ds, 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/ds/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_ds property.
  $page_object = $this
    ->_nd_build_object($page_node, 'teaser', TRUE, FALSE);
  $this
    ->assertTrue($page_object->render_by_ds, 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_ds, t('Story full not rendered by ND'), t('ND settings exclude'));
}