1 layout.test | public LayoutUpgradePathTest::testLayoutUpgrade() |
Tests a successful upgrade, where block positions copied to layouts.
File
- core/
modules/ layout/ tests/ layout.test, line 2824 - Tests for the Layout module.
Class
- LayoutUpgradePathTest
- Tests the upgrade path from block-based regions to layouts.
Code
public function testLayoutUpgrade() {
$this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
$this->backdropGet('user');
$blocks = array(
'l-header' => array(
'block-system-header',
'block-system-main-menu',
),
'l-sidebar-first' => array(
'block-search-form',
),
'l-triptych-middle' => array(
'block-node-syndicate',
),
'l-footer-first-column' => array(
'block-system-main-menu',
),
'l-footer-second-column' => array(
'block-system-management',
),
'l-footer-third-column' => array(
'block-system-user-menu',
),
'l-footer-fourth-column' => array(
// No blocks in forth column. The "navigation" block had been here in
// the D7 dump, but the navigation menu was removed in Backdrop.
),
'l-footer' => array(
'block-system-powered-by'
),
);
$this->assertBlocks($blocks);
$this->assertNoBlocks(array(
'l-footer-fourth-column' => array(
'block', // No blocks at all should be in the fourth column
),
));
// Check a node article, which should have the recent nodes block.
$article_node = $this->backdropCreateNode(array(
'type' => 'article',
'title' => $this->randomString(),
));
$this->backdropGet('node/' . $article_node->nid);
$article_blocks = $blocks;
$article_blocks['sidebar-second'][] = 'block-node-recent';
$this->assertBlocks($article_blocks);
// Check that the blocks are NOT available on page content.
// Check a node post, which should have the recent nodes block.
$page_node = $this->backdropCreateNode(array(
'type' => 'page',
'title' => $this->randomString(),
));
$this->backdropGet('node/' . $page_node->nid);
$this->assertBlocks($blocks);
$this->assertNoBlocks(array(
'l-sidebar-section' => array(
'block-node-recent'
),
));
// Check for path-based blocks, which should not be shown on /user.
$profile_blocks = $blocks;
$this->backdropGet('user/1');
$this->assertBlocks($profile_blocks);
// The Recent Comments block should still be shown on the homepage, but not
// on paths other than node*.
$path_blocks = array(
'l-triptych-last' => array(
'block-comment-recent',
),
);
$this->backdropGet('<front>');
$this->assertBlocks($path_blocks);
$this->backdropGet('node/' . $article_node->nid);
$this->assertBlocks($path_blocks);
$this->backdropGet('user/1');
$this->assertNoBlocks($path_blocks);
// Logout, and check the homepage for the Account menu block, which should
// only be visible to authenticated users.
$this->backdropLogout();
$this->backdropGet('<front>');
$this->assertNoBlocks(array(
'.region-footer-thirdcolumn' => array(
'block-system-user-menu',
),
));
}