public function MainContentFallbackTest::testMainContentFallback in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/tests/src/Functional/System/MainContentFallbackTest.php \Drupal\Tests\system\Functional\System\MainContentFallbackTest::testMainContentFallback()
- 10 core/modules/system/tests/src/Functional/System/MainContentFallbackTest.php \Drupal\Tests\system\Functional\System\MainContentFallbackTest::testMainContentFallback()
Test availability of main content: Drupal falls back to SimplePageVariant.
File
- core/
modules/ system/ tests/ src/ Functional/ System/ MainContentFallbackTest.php, line 47
Class
- MainContentFallbackTest
- Test SimplePageVariant main content rendering fallback page display variant.
Namespace
Drupal\Tests\system\Functional\SystemCode
public function testMainContentFallback() {
$edit = [];
// Uninstall the block module.
$edit['uninstall[block]'] = 'block';
$this
->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
$this
->drupalPostForm(NULL, NULL, t('Uninstall'));
$this
->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
$this
->rebuildContainer();
$this
->assertFalse(\Drupal::moduleHandler()
->moduleExists('block'), 'Block module uninstall.');
// When Block module is not installed and BlockPageVariant is not available,
// Drupal should fall back to SimplePageVariant. Both for the admin and the
// front-end theme.
$this
->drupalGet('admin/config/system/site-information');
$this
->assertField('site_name', 'Fallback to SimplePageVariant works for admin theme.');
$this
->drupalGet('system-test/main-content-fallback');
$this
->assertText(t('Content to test main content fallback'), 'Fallback to SimplePageVariant works for front-end theme.');
// Request a user* page and see if it is displayed.
$this
->drupalLogin($this->webUser);
$this
->drupalGet('user/' . $this->webUser
->id() . '/edit');
$this
->assertField('mail', 'User interface still available.');
// Enable the block module again.
$this
->drupalLogin($this->adminUser);
$edit = [];
$edit['modules[block][enable]'] = 'block';
$this
->drupalPostForm('admin/modules', $edit, t('Install'));
$this
->assertText(t('Module Block has been enabled.'), 'Modules status has been updated.');
$this
->rebuildContainer();
$this
->assertTrue(\Drupal::moduleHandler()
->moduleExists('block'), 'Block module re-enabled.');
}