1 layout.test LayoutInterfaceTest::testViewPageLink()

Test the path view page link.

File

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

Class

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

Code

function testViewPageLink() {
  $this->backdropGet('admin/structure/layouts');
  $this->clickLink(t('Add layout'));

  // Test the default value for layout template is set.
  $this->assertFieldByXPath('//input[@name="layout_template"][@checked="checked"]', TRUE, 'The Layout template default value is set.');
  $default_layout_template = config_get('layout.layout.default', 'layout_template');
  $field_id = 'edit-layout-template-' . str_replace('_', '-', $default_layout_template);
  $this->assertFieldChecked($field_id, 'The Layout template default value is the same as the default layout.');

  // Create a new layout at a new path.
  $layout_title = $this->randomName();
  $layout_name = strtolower($layout_title);
  $layout_url = 'a-menu-item-path';
  $edit = array(
    'title' => $layout_title,
    'name' => $layout_name,
    'layout_template' => 'moscone_flipped',
    'path' => $layout_url,
  );
  $this->backdropPost(NULL, $edit, t('Create layout'));
  $this->backdropGet('admin/structure/layouts/manage/' . $layout_name);
  layout_reset_caches();

  // Check that the view page link is present.
  $this->assertLinkByHref($layout_url, 0, 'View page link found.');
  $this->assertLink('View page', 0, 'View page link text found.');
  $this->clickLink(t('View page'));
  $this->assertResponse(200, 'View page link goes to path.');

  // Create a new layout overriding node/%.
  $layout_title = $this->randomName();
  $layout_name = strtolower($layout_title);
  $layout_url = 'node/%';
  $edit = array(
    'title' => $layout_title,
    'name' => $layout_name,
    'layout_template' => 'moscone_flipped',
    'path' => $layout_url,
  );
  $this->backdropPost('admin/structure/layouts/add', $edit, t('Create layout'));

  // Check that the view page link is not present.
  $this->assertNoLinkByHref($layout_url, 0, 'View page link found.');
  $this->assertNoLink('View page', 1, 'View page link text found.');
}