3 namespace Drupal\Tests\system\Functional\System;
5 use Drupal\Tests\BrowserTestBase;
8 * Test SimplePageVariant main content rendering fallback page display variant.
12 class MainContentFallbackTest extends BrowserTestBase {
19 public static $modules = ['block', 'system_test'];
24 protected function setUp() {
27 // Create and log in admin user.
28 $this->adminUser = $this->drupalCreateUser([
29 'access administration pages',
30 'administer site configuration',
33 $this->drupalLogin($this->adminUser);
36 $this->webUser = $this->drupalCreateUser(['access user profiles']);
40 * Test availability of main content: Drupal falls back to SimplePageVariant.
42 public function testMainContentFallback() {
44 // Uninstall the block module.
45 $edit['uninstall[block]'] = 'block';
46 $this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
47 $this->drupalPostForm(NULL, NULL, t('Uninstall'));
48 $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
49 $this->rebuildContainer();
50 $this->assertFalse(\Drupal::moduleHandler()->moduleExists('block'), 'Block module uninstall.');
52 // When Block module is not installed and BlockPageVariant is not available,
53 // Drupal should fall back to SimplePageVariant. Both for the admin and the
55 $this->drupalGet('admin/config/system/site-information');
56 $this->assertField('site_name', 'Fallback to SimplePageVariant works for admin theme.');
57 $this->drupalGet('system-test/main-content-fallback');
58 $this->assertText(t('Content to test main content fallback'), 'Fallback to SimplePageVariant works for front-end theme.');
59 // Request a user* page and see if it is displayed.
60 $this->drupalLogin($this->webUser);
61 $this->drupalGet('user/' . $this->webUser->id() . '/edit');
62 $this->assertField('mail', 'User interface still available.');
64 // Enable the block module again.
65 $this->drupalLogin($this->adminUser);
67 $edit['modules[block][enable]'] = 'block';
68 $this->drupalPostForm('admin/modules', $edit, t('Install'));
69 $this->assertText(t('Module Block has been enabled.'), 'Modules status has been updated.');
70 $this->rebuildContainer();
71 $this->assertTrue(\Drupal::moduleHandler()->moduleExists('block'), 'Block module re-enabled.');