-
Notifications
You must be signed in to change notification settings - Fork 0
/
kernel-test-base.patch
63 lines (60 loc) · 2.09 KB
/
kernel-test-base.patch
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
diff --git a/tests/Drupal/KernelTests/KernelTestBase.php b/tests/Drupal/KernelTests/KernelTestBase.php
index 64d267c..6012511 100644
--- a/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/tests/Drupal/KernelTests/KernelTestBase.php
@@ -201,6 +201,13 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
'config_test.dynamic.system',
];
+ /**
+ * The default list of directories that will be ignored by Drupal's file API.
+ *
+ * @var array
+ */
+ protected $ignoreDirectories = [];
+
/**
* {@inheritdoc}
*/
@@ -227,11 +234,32 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
parent::setUp();
$this->root = static::getDrupalRoot();
+ $this->backupIgnoreDirectories();
$this->initFileCache();
$this->bootEnvironment();
$this->bootKernel();
}
+ /**
+ * Backup "file_scan_ignore_directories" set in site's settings.php.
+ *
+ * @see \Drupal\KernelTests\KernelTestBase::getExtensionsForModules()
+ */
+ protected function backupIgnoreDirectories() {
+ /** @var $settings */
+ require_once $this->root . '/core/includes/bootstrap.inc';
+ $request = new Request();
+ $site_path = DrupalKernel::findSitePath($request);
+
+ if (file_exists($this->root . '/' . $site_path . '/settings.php')) {
+ $app_root = $this->root;
+ require_once $this->root . '/' . $site_path . '/settings.php';
+ if (isset($settings['file_scan_ignore_directories'])) {
+ $this->ignoreDirectories = $settings['file_scan_ignore_directories'];
+ }
+ }
+ }
+
/**
* Bootstraps a basic test environment.
*
@@ -494,6 +522,11 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
*/
private function getExtensionsForModules(array $modules) {
$extensions = [];
+
+ $settings = Settings::getAll();
+ $settings['file_scan_ignore_directories'] = $this->ignoreDirectories;
+ new Settings($settings);
+
$discovery = new ExtensionDiscovery($this->root);
$discovery->setProfileDirectories([]);
$list = $discovery->scan('module');