|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Codeception\Module\Drupal\UserRegistry\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Codeception\Configuration; |
|
6
|
|
|
use Codeception\Exception\Module as ModuleException; |
|
7
|
|
|
use Codeception\Module\Drupal\UserRegistry\DrushTestUserManager; |
|
8
|
|
|
use Codeception\Module\Drupal\UserRegistry\Storage\ModuleConfigStorage; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class TestUsersCommandTrait. |
|
12
|
|
|
* |
|
13
|
|
|
* @package Codeception\Module\Drupal\UserRegistry\Command |
|
14
|
|
|
*/ |
|
15
|
|
|
trait TestUsersCommandTrait |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var \Codeception\Module\Drupal\UserRegistry\DrupalTestUser[] |
|
19
|
|
|
* Store an array of test users to be created or deleted. |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $users; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var \Codeception\Module\Drupal\UserRegistry\TestUserManagerInterface |
|
25
|
|
|
* Store the test user manager being used to create or delete users. |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $testUserManager; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param string $suiteName |
|
31
|
|
|
* @param array $suiteSettings |
|
32
|
|
|
* |
|
33
|
|
|
* @throws ModuleException |
|
34
|
|
|
* @throws \Codeception\Exception\Configuration |
|
35
|
|
|
* @throws \Exception |
|
36
|
|
|
*/ |
|
37
|
|
|
protected function getTestUsers($suiteName, $suiteSettings = null) |
|
38
|
|
|
{ |
|
39
|
|
|
if (!$suiteSettings) { |
|
40
|
|
|
$suiteSettings = Configuration::suiteSettings($suiteName, Configuration::config()); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
if (!isset($suiteSettings['modules']['config']['DrupalUserRegistry'])) { |
|
44
|
|
|
throw new ModuleException( |
|
45
|
|
|
__CLASS__, |
|
46
|
|
|
sprintf("Drupal User Registry is not configured correctly in suite '%s'.", $suiteName) |
|
47
|
|
|
); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
$config = $suiteSettings['modules']['config']['DrupalUserRegistry']; |
|
51
|
|
|
|
|
52
|
|
|
$moduleConfigStorage = new ModuleConfigStorage($config); |
|
53
|
|
|
$this->users = $moduleConfigStorage->load(); |
|
54
|
|
|
$this->testUserManager = new DrushTestUserManager($config, $moduleConfigStorage); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|