View source
<?php
namespace Drupal\Tests\domain_config_ui\Traits;
trait DomainConfigUITestTrait {
protected $adminUser;
protected $editorUser;
protected $limitedUser;
protected $languageUser;
public function createAdminUser() {
$this->adminUser = $this
->drupalCreateUser([
'access administration pages',
'access content',
'administer domains',
'administer domain config ui',
'administer site configuration',
'administer languages',
'administer themes',
'set default domain configuration',
'translate domain configuration',
'use domain config ui',
'view domain information',
]);
}
public function createEditorUser() {
$this->editorUser = $this
->drupalCreateUser([
'access administration pages',
'access content',
'administer site configuration',
'administer languages',
]);
}
public function createLimitedUser() {
$this->limitedUser = $this
->drupalCreateUser([
'access administration pages',
'administer languages',
'administer site configuration',
'use domain config ui',
'set default domain configuration',
]);
}
public function createLanguageUser() {
$this->languageUser = $this
->drupalCreateUser([
'access administration pages',
'use domain config ui',
'translate domain configuration',
'administer site configuration',
]);
}
public function createLanguage() {
$adminUser = $this
->drupalCreateUser([
'administer languages',
'access administration pages',
]);
$this
->drupalLogin($adminUser);
$edit = [
'predefined_langcode' => 'es',
];
$this
->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
$edit = [
'language_interface[enabled][language-url]' => '1',
];
$this
->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
$this
->drupalLogout();
$this
->rebuildContainer();
$es = \Drupal::entityTypeManager()
->getStorage('configurable_language')
->load('es');
$this
->assertTrue(!empty($es), 'Created test language.');
}
}