Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / system / tests / src / Functional / System / MainContentFallbackTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\System;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Test SimplePageVariant main content rendering fallback page display variant.
9  *
10  * @group system
11  */
12 class MainContentFallbackTest extends BrowserTestBase {
13
14   /**
15    * Modules to enable.
16    *
17    * @var array
18    */
19   public static $modules = ['block', 'system_test'];
20
21   protected $adminUser;
22   protected $webUser;
23
24   protected function setUp() {
25     parent::setUp();
26
27     // Create and log in admin user.
28     $this->adminUser = $this->drupalCreateUser([
29       'access administration pages',
30       'administer site configuration',
31       'administer modules',
32     ]);
33     $this->drupalLogin($this->adminUser);
34
35     // Create a web user.
36     $this->webUser = $this->drupalCreateUser(['access user profiles']);
37   }
38
39   /**
40    * Test availability of main content: Drupal falls back to SimplePageVariant.
41    */
42   public function testMainContentFallback() {
43     $edit = [];
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.');
51
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
54     // front-end theme.
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.');
63
64     // Enable the block module again.
65     $this->drupalLogin($this->adminUser);
66     $edit = [];
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.');
72   }
73
74 }