1 layout.test LayoutInterfaceTest::testLayoutTemplates()

Test that layout templates may be enabled and disabled.

File

core/modules/layout/tests/layout.test, line 142
Tests for the Layout module.

Class

LayoutInterfaceTest
Tests the interface for adding, removing, and moving blocks.

Code

function testLayoutTemplates() {
  // Attempt to disable the 1 column layout (should fail).
  $this->backdropGet('admin/structure/layouts/settings');
  $edit = array(
    'templates[boxton]' => FALSE,
    'templates[moscone]' => TRUE,
    'templates[moscone_flipped]' => TRUE,
    'templates[simmons]' => TRUE,
  );
  $this->backdropPost(NULL, $edit, t('Save configuration'));
  $this->assertText(t('The "Boxton" layout template is currently in use and may not be disabled.'));

  // Check to see that the Simmons layout is an existing option.
  $this->backdropGet('admin/structure/layouts/manage/default/configure');
  $this->assertText('Simmons');

  // Disable the Bartik layout.
  $edit = array(
    'templates[boxton]' => TRUE,
    'templates[moscone]' => TRUE,
    'templates[moscone_flipped]' => TRUE,
    'templates[simmons]' => FALSE,
  );
  $this->backdropPost('admin/structure/layouts/settings', $edit, t('Save configuration'));
  $this->assertText(t('Your configuration has been saved.'));

  // Check to see that the Simmons layout is no longer an option.
  $this->backdropGet('admin/structure/layouts/manage/default/configure');
  $this->assertNoText('Simmons');

  // Check that hidden templates are not shown by default.
  $this->assertNoText('3/3/4 columns');

  // Enable hidden layouts manually.
  config_set('layout.settings', 'excluded_templates', array());

  // Check that the hidden templates are now available.
  $this->backdropGet('admin/structure/layouts/manage/default/configure');
  $this->assertText('3/3/4 columns');
  $this->backdropGet('admin/structure/layouts/settings');
  $this->assertText('3/3/4 columns');

  // Disable the legacy Bartik layout.
  $edit = array(
    'templates[three_three_four_column]' => FALSE,
  );
  $this->backdropPost('admin/structure/layouts/settings', $edit, t('Save configuration'));
  $this->assertNoText('3/3/4 columns');

  // Post again just make sure the hidden option doesn't return.
  $this->backdropPost('admin/structure/layouts/settings', array(), t('Save configuration'));
  $this->assertNoText('3/3/4 columns');
}