1 layout.test | public LayoutDeletionTest::testLayoutDeletion() |
Tests that layouts that have special roles issue warning messages upon attempted deletion.
File
- core/
modules/ layout/ tests/ layout.test, line 3746 - Tests for the Layout module.
Class
- LayoutDeletionTest
- Tests that ensures deletion messages are appropriate if layout page has any special role.
Code
public function testLayoutDeletion() {
// Create our new layout that we'll be attempting to delete.
$this->backdropGet('admin/structure/layouts');
$this->clickLink(t('Add layout'));
// Create a new layout at a new path.
$layout_title = $this->randomName();
$layout_name = strtolower($layout_title);
$layout_url = 'a-special-layout';
$edit = array(
'title' => $layout_title,
'name' => $layout_name,
'layout_template' => 'moscone_flipped',
'path' => $layout_url,
);
$this->backdropPost(NULL, $edit, t('Create layout'));
layout_reset_caches();
$deletion_path = 'admin/structure/layouts/manage/' . $layout_name . '/delete';
// First make sure there's no special message if the layout isn't special.
// The first sentence of all of our messages is the same.
$this->backdropGet($deletion_path);
$this->assertNoText(format_string('This layout creates a page at @path', array('@path' => $layout_url)));
// Make our layout the home page, try to delete it, and check for its
// message. Then restore the system setting.
config_set('system.core', 'site_frontpage', $layout_url);
$this->backdropGet($deletion_path);
$this->assertText(format_string('This layout creates a page at @path that is used as the home page of the site.', array('@path' => $layout_url)));
config_set('system.core', 'site_frontpage', '');
// Make our layout the 403 page, try to delete it, and check for its
// message. Then restore the system setting.
config_set('system.core', 'site_403', $layout_url);
$this->backdropGet($deletion_path);
$this->assertText(format_string('This layout creates a page at @path that is used as the default 403 (access denied) page of the site.', array('@path' => $layout_url)));
config_set('system.core', 'site_403', '');
// Make our layout the 404 page, try to delete it, and check for its
// message. Then restore the system setting.
config_set('system.core', 'site_404', $layout_url);
$this->backdropGet($deletion_path);
$this->assertText(format_string('This layout creates a page at @path that is used as the default 404 (not found) page of the site.', array('@path' => $layout_url)));
config_set('system.core', 'site_404', '');
}