You are here

function dsExportablesTests::testDSExportablesLayoutFieldsettings in Display Suite 7

Same name and namespace in other branches
  1. 7.2 tests/ds.exportables.test \dsExportablesTests::testDSExportablesLayoutFieldsettings()

File

tests/ds.exportables.test, line 65
Base functions and tests for Display Suite.

Class

dsExportablesTests
@file Base functions and tests for Display Suite.

Code

function testDSExportablesLayoutFieldsettings() {
  $this
    ->dsExportablesSetup();
  $this
    ->drupalGet('admin/structure/types/manage/article/display');
  $this
    ->assertNoText(t('This layout is overridden. Click to revert to default settings.'));
  $settings = array(
    'type' => 'article',
    'title' => 'Exportable',
  );
  $node = $this
    ->drupalCreateNode($settings);
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertRaw('group-left', 'Left region found');
  $this
    ->assertRaw('group-right', 'Right region found');
  $this
    ->assertNoRaw('group-header', 'No header region found');
  $this
    ->assertNoRaw('group-footer', 'No footer region found');
  $this
    ->assertRaw('<h3><a href="' . url('node/1') . '" class="active">Exportable</a></h3>', t('Default title with h3 found'));
  $this
    ->assertRaw('<a href="' . url('node/1') . '" class="active">Read more</a>', t('Default read more found'));

  // Override default layout.
  $layout = array(
    'additional_settings[layout]' => 'ds_2col_stacked',
  );
  $assert = array(
    'regions' => array(
      'header' => '<td colspan="8">' . t('Header') . '</td>',
      'left' => '<td colspan="8">' . t('Left') . '</td>',
      'right' => '<td colspan="8">' . t('Right') . '</td>',
      'footer' => '<td colspan="8">' . t('Footer') . '</td>',
    ),
  );
  $fields = array(
    'fields[post_date][region]' => 'header',
    'fields[author][region]' => 'left',
    'fields[links][region]' => 'left',
    'fields[body][region]' => 'right',
    'fields[comments][region]' => 'footer',
  );
  $this
    ->dsSelectLayout($layout, $assert);
  $this
    ->assertText(t('This layout is overridden. Click to revert to default settings.'));
  $this
    ->dsConfigureUI($fields);
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertRaw('group-left', 'Left region found');
  $this
    ->assertRaw('group-right', 'Left region found');
  $this
    ->assertRaw('group-header', 'Left region found');
  $this
    ->assertRaw('group-footer', 'Left region found');

  // Revert.
  $edit = array();
  $this
    ->drupalPost('admin/structure/ds/revert-layout/node|article|default', $edit, t('Revert'), array(
    'query' => array(
      'destination' => 'admin/structure/types/manage/article/display',
    ),
  ));
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertRaw('group-left', 'Left region found');
  $this
    ->assertRaw('group-right', 'Left region found');
  $this
    ->assertNoRaw('group-header', 'Left region found');
  $this
    ->assertNoRaw('group-footer', 'Left region found');
  $this
    ->assertRaw('<h3><a href="' . url('node/1') . '" class="active">Exportable</a></h3>', t('Default title with h3 found'));
  $this
    ->assertRaw('<a href="' . url('node/1') . '" class="active">Read more</a>', t('Default read more found'));
}