function ToolbarTestSetup::setup

Run the code to setup the test environment.

You have access to any API provided by any installed module. For example, to install modules use:

\Drupal::service('module_installer')->install([
  'my_module',
]);

Check out TestSiteInstallTestScript for an example.

Overrides TestSetupInterface::setup

File

core/modules/toolbar/tests/src/Nightwatch/ToolbarTestSetup.php, line 20

Class

ToolbarTestSetup
Sets up the site for testing the toolbar module.

Namespace

Drupal\Tests\toolbar\Nightwatch

Code

public function setup() : void {
  $module_installer = \Drupal::service('module_installer');
  assert($module_installer instanceof ModuleInstallerInterface);
  $module_installer->install([
    'toolbar',
  ]);
  $role = Role::load(RoleInterface::ANONYMOUS_ID);
  foreach ([
    'access toolbar',
    'access administration pages',
    'administer modules',
    'administer site configuration',
    'administer account settings',
  ] as $permission) {
    $role->grantPermission($permission);
  }
  $role->save();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.