forked from dxpr/dxpr_cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestSite.php
37 lines (30 loc) · 919 Bytes
/
TestSite.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
declare(strict_types=1);
use Drupal\TestSite\TestSetupInterface;
use Drupal\user\Entity\User;
final class TestSite implements TestSetupInterface {
/**
* {@inheritdoc}
*/
public function setup(): void {
\Drupal::configFactory()
->getEditable('system.logging')
->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)
->save();
User::load(1)->setPassword('password')->save();
// Ensure there is a user for each non-administrative role.
$roles = \Drupal::entityTypeManager()
->getStorage('user_role')
->getQuery()
->condition('is_admin', FALSE)
->condition('id', [User::ANONYMOUS_ROLE, User::AUTHENTICATED_ROLE], 'NOT IN')
->execute();
foreach ($roles as $role_id) {
$account = User::create([
'name' => $role_id,
'pass' => 'password',
]);
$account->addRole($role_id)->activate()->save();
}
}
}