Total Complexity | 4 |
Total Lines | 116 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
18 | abstract class MongoDbTestBase extends KernelTestBase { |
||
19 | |||
20 | const DEFAULT_URI = 'mongodb://localhost:27017'; |
||
21 | |||
22 | const CLIENT_BAD_ALIAS = 'bad'; |
||
23 | |||
24 | const CLIENT_TEST_ALIAS = 'test'; |
||
25 | |||
26 | const DB_BAD_CLIENT_ALIAS = 'bad'; |
||
27 | |||
28 | const DB_INVALID_ALIAS = 'invalid'; |
||
29 | |||
30 | const DB_DEFAULT_ALIAS = 'default'; |
||
31 | |||
32 | const DB_UNSET_ALIAS = 'unset'; |
||
33 | |||
34 | /** |
||
35 | * Modules to enable. |
||
36 | * |
||
37 | * @var string[] |
||
38 | */ |
||
39 | protected static $modules = [MongoDb::MODULE]; |
||
40 | |||
41 | /** |
||
42 | * A test-specific instance of Settings. |
||
43 | * |
||
44 | * @var \Drupal\Core\Site\Settings |
||
45 | */ |
||
46 | protected Settings $settings; |
||
47 | |||
48 | /** |
||
49 | * The MongoDB URI for a test server. |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | protected string $uri; |
||
54 | |||
55 | /** |
||
56 | * Obtain the name of a per-test database. |
||
57 | * |
||
58 | * @param string $postfix |
||
59 | * The way for the caller to differentiate this database from others. |
||
60 | * |
||
61 | * @return string |
||
62 | * The name of the per-test database, like 'simpletest1234_foo'. |
||
63 | */ |
||
64 | public function getTestDatabaseName($postfix) { |
||
65 | return $this->getDatabasePrefix() . '_' . $postfix; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Provide a sane set of default settings. |
||
70 | * |
||
71 | * @return array{clients: array<string, array{uri: string, uriOptions: array<string,mixed>, driverOptions: array<string,mixed>}>, databases: array<string,array{0:string,1:string}>>} |
||
72 | * A settings array only containing MongoDB-related settings. |
||
73 | */ |
||
74 | protected function getSettingsArray(): array { |
||
100 | ], |
||
101 | ], |
||
102 | ]; |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * {@inheritdoc} |
||
107 | * |
||
108 | * This setUp configures $this->settings and $this->>uri. |
||
109 | */ |
||
110 | public function setUp(): void { |
||
111 | parent::setUp(); |
||
112 | // $_ENV if it comes from phpunit.xml <env> |
||
113 | // $_SERVER if it comes from the phpunit command line environment. |
||
114 | $this->uri = $_ENV['MONGODB_URI'] |
||
115 | ?? $_SERVER['MONGODB_URI'] |
||
116 | ?? static::DEFAULT_URI; |
||
117 | |||
118 | $this->settings = new Settings([MongoDb::MODULE => $this->getSettingsArray()]); |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * {@inheritdoc} |
||
123 | * |
||
124 | * This tearDown drops the test database, so child classes do not need to |
||
125 | * clean up behind them. |
||
126 | */ |
||
127 | public function tearDown(): void { |
||
134 | } |
||
135 | |||
137 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths