Skip to content

Commit 848c2bf

Browse files
authored
Allow static calls to \Drupal in \Drupal\TestSite\TestSetupInterface (#575)
1 parent 0d5be5a commit 848c2bf

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/Rules/Drupal/GlobalDrupalDependencyInjectionRule.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public function processNode(Node $node, Scope $scope): array
5050
// and cannot use dependency injection. Function calls like
5151
// file_exists, stat, etc. will construct the class directly.
5252
'Drupal\Core\StreamWrapper\StreamWrapperInterface',
53+
// Ignore Nightwatch test setup classes.
54+
'Drupal\TestSite\TestSetupInterface',
5355
];
5456

5557
foreach ($allowed_list as $item) {

tests/src/Rules/GlobalDrupalDependencyInjectionRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public function resultData(): \Generator
5353
[],
5454
];
5555

56+
yield [
57+
__DIR__ . '/data/bug-515.php',
58+
[],
59+
];
60+
5661
if (PHP_VERSION_ID >= 80100) {
5762
yield [
5863
__DIR__ . '/data/bug-500.php',

tests/src/Rules/data/bug-515.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace NightwatchSetup;
4+
5+
use Drupal\TestSite\TestSetupInterface;
6+
7+
final class TestSetup implements TestSetupInterface {
8+
9+
public function setup()
10+
{
11+
\Drupal::service('module_installer')->install(['node', 'block']);
12+
}
13+
}

0 commit comments

Comments
 (0)