MainContentFallbackTest.php in Zircon Profile 8.0
File
core/modules/system/src/Tests/System/MainContentFallbackTest.php
View source
<?php
namespace Drupal\system\Tests\System;
use Drupal\simpletest\WebTestBase;
class MainContentFallbackTest extends WebTestBase {
public static $modules = array(
'block',
'system_test',
);
protected $adminUser;
protected $webUser;
protected function setUp() {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser(array(
'access administration pages',
'administer site configuration',
'administer modules',
));
$this
->drupalLogin($this->adminUser);
$this->webUser = $this
->drupalCreateUser(array(
'access user profiles',
));
}
function testMainContentFallback() {
$edit = array();
$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.');
$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.');
$this
->drupalLogin($this->webUser);
$this
->drupalGet('user/' . $this->webUser
->id() . '/edit');
$this
->assertField('mail', 'User interface still available.');
$this
->drupalLogin($this->adminUser);
$edit = array();
$edit['modules[Core][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.');
}
}