annotate core/modules/simpletest/src/TestDiscovery.php @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children 12f9dff5fda9
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\simpletest;
Chris@0 4
Chris@0 5 use Doctrine\Common\Annotations\SimpleAnnotationReader;
Chris@0 6 use Doctrine\Common\Reflection\StaticReflectionParser;
Chris@0 7 use Drupal\Component\Annotation\Reflection\MockFileFinder;
Chris@0 8 use Drupal\Component\Utility\NestedArray;
Chris@0 9 use Drupal\Core\Extension\ExtensionDiscovery;
Chris@0 10 use Drupal\Core\Extension\ModuleHandlerInterface;
Chris@0 11 use Drupal\simpletest\Exception\MissingGroupException;
Chris@0 12 use PHPUnit_Util_Test;
Chris@0 13
Chris@0 14 /**
Chris@0 15 * Discovers available tests.
Chris@0 16 */
Chris@0 17 class TestDiscovery {
Chris@0 18
Chris@0 19 /**
Chris@0 20 * The class loader.
Chris@0 21 *
Chris@0 22 * @var \Composer\Autoload\ClassLoader
Chris@0 23 */
Chris@0 24 protected $classLoader;
Chris@0 25
Chris@0 26 /**
Chris@4 27 * Statically cached list of test classes.
Chris@0 28 *
Chris@4 29 * @var array
Chris@0 30 */
Chris@4 31 protected $testClasses;
Chris@0 32
Chris@0 33 /**
Chris@0 34 * Cached map of all test namespaces to respective directories.
Chris@0 35 *
Chris@0 36 * @var array
Chris@0 37 */
Chris@0 38 protected $testNamespaces;
Chris@0 39
Chris@0 40 /**
Chris@0 41 * Cached list of all available extension names, keyed by extension type.
Chris@0 42 *
Chris@0 43 * @var array
Chris@0 44 */
Chris@0 45 protected $availableExtensions;
Chris@0 46
Chris@0 47 /**
Chris@0 48 * The app root.
Chris@0 49 *
Chris@0 50 * @var string
Chris@0 51 */
Chris@0 52 protected $root;
Chris@0 53
Chris@0 54 /**
Chris@0 55 * The module handler.
Chris@0 56 *
Chris@0 57 * @var \Drupal\Core\Extension\ModuleHandlerInterface
Chris@0 58 */
Chris@0 59 protected $moduleHandler;
Chris@0 60
Chris@0 61 /**
Chris@0 62 * Constructs a new test discovery.
Chris@0 63 *
Chris@0 64 * @param string $root
Chris@0 65 * The app root.
Chris@0 66 * @param $class_loader
Chris@0 67 * The class loader. Normally Composer's ClassLoader, as included by the
Chris@0 68 * front controller, but may also be decorated; e.g.,
Chris@0 69 * \Symfony\Component\ClassLoader\ApcClassLoader.
Chris@0 70 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
Chris@0 71 * The module handler.
Chris@0 72 */
Chris@4 73 public function __construct($root, $class_loader, ModuleHandlerInterface $module_handler) {
Chris@0 74 $this->root = $root;
Chris@0 75 $this->classLoader = $class_loader;
Chris@0 76 $this->moduleHandler = $module_handler;
Chris@0 77 }
Chris@0 78
Chris@0 79 /**
Chris@0 80 * Registers test namespaces of all extensions and core test classes.
Chris@0 81 *
Chris@0 82 * @return array
Chris@0 83 * An associative array whose keys are PSR-4 namespace prefixes and whose
Chris@0 84 * values are directory names.
Chris@0 85 */
Chris@0 86 public function registerTestNamespaces() {
Chris@0 87 if (isset($this->testNamespaces)) {
Chris@0 88 return $this->testNamespaces;
Chris@0 89 }
Chris@0 90 $this->testNamespaces = [];
Chris@0 91
Chris@0 92 $existing = $this->classLoader->getPrefixesPsr4();
Chris@0 93
Chris@0 94 // Add PHPUnit test namespaces of Drupal core.
Chris@0 95 $this->testNamespaces['Drupal\\Tests\\'] = [$this->root . '/core/tests/Drupal/Tests'];
Chris@0 96 $this->testNamespaces['Drupal\\KernelTests\\'] = [$this->root . '/core/tests/Drupal/KernelTests'];
Chris@0 97 $this->testNamespaces['Drupal\\FunctionalTests\\'] = [$this->root . '/core/tests/Drupal/FunctionalTests'];
Chris@0 98 $this->testNamespaces['Drupal\\FunctionalJavascriptTests\\'] = [$this->root . '/core/tests/Drupal/FunctionalJavascriptTests'];
Chris@0 99
Chris@0 100 $this->availableExtensions = [];
Chris@0 101 foreach ($this->getExtensions() as $name => $extension) {
Chris@0 102 $this->availableExtensions[$extension->getType()][$name] = $name;
Chris@0 103
Chris@0 104 $base_path = $this->root . '/' . $extension->getPath();
Chris@0 105
Chris@0 106 // Add namespace of disabled/uninstalled extensions.
Chris@0 107 if (!isset($existing["Drupal\\$name\\"])) {
Chris@0 108 $this->classLoader->addPsr4("Drupal\\$name\\", "$base_path/src");
Chris@0 109 }
Chris@0 110 // Add Simpletest test namespace.
Chris@0 111 $this->testNamespaces["Drupal\\$name\\Tests\\"][] = "$base_path/src/Tests";
Chris@0 112
Chris@0 113 // Add PHPUnit test namespaces.
Chris@0 114 $this->testNamespaces["Drupal\\Tests\\$name\\Unit\\"][] = "$base_path/tests/src/Unit";
Chris@0 115 $this->testNamespaces["Drupal\\Tests\\$name\\Kernel\\"][] = "$base_path/tests/src/Kernel";
Chris@0 116 $this->testNamespaces["Drupal\\Tests\\$name\\Functional\\"][] = "$base_path/tests/src/Functional";
Chris@0 117 $this->testNamespaces["Drupal\\Tests\\$name\\FunctionalJavascript\\"][] = "$base_path/tests/src/FunctionalJavascript";
Chris@0 118
Chris@0 119 // Add discovery for traits which are shared between different test
Chris@0 120 // suites.
Chris@0 121 $this->testNamespaces["Drupal\\Tests\\$name\\Traits\\"][] = "$base_path/tests/src/Traits";
Chris@0 122 }
Chris@0 123
Chris@0 124 foreach ($this->testNamespaces as $prefix => $paths) {
Chris@0 125 $this->classLoader->addPsr4($prefix, $paths);
Chris@0 126 }
Chris@0 127
Chris@0 128 return $this->testNamespaces;
Chris@0 129 }
Chris@0 130
Chris@0 131 /**
Chris@0 132 * Discovers all available tests in all extensions.
Chris@0 133 *
Chris@0 134 * @param string $extension
Chris@0 135 * (optional) The name of an extension to limit discovery to; e.g., 'node'.
Chris@0 136 * @param string[] $types
Chris@0 137 * An array of included test types.
Chris@0 138 *
Chris@0 139 * @return array
Chris@0 140 * An array of tests keyed by the the group name.
Chris@0 141 * @code
Chris@0 142 * $groups['block'] => array(
Chris@0 143 * 'Drupal\Tests\block\Functional\BlockTest' => array(
Chris@0 144 * 'name' => 'Drupal\Tests\block\Functional\BlockTest',
Chris@0 145 * 'description' => 'Tests block UI CRUD functionality.',
Chris@0 146 * 'group' => 'block',
Chris@0 147 * ),
Chris@0 148 * );
Chris@0 149 * @endcode
Chris@0 150 *
Chris@0 151 * @todo Remove singular grouping; retain list of groups in 'group' key.
Chris@0 152 * @see https://www.drupal.org/node/2296615
Chris@0 153 */
Chris@0 154 public function getTestClasses($extension = NULL, array $types = []) {
Chris@0 155 $reader = new SimpleAnnotationReader();
Chris@0 156 $reader->addNamespace('Drupal\\simpletest\\Annotation');
Chris@0 157
Chris@4 158 if (!isset($extension) && empty($types)) {
Chris@4 159 if (!empty($this->testClasses)) {
Chris@4 160 return $this->testClasses;
Chris@0 161 }
Chris@0 162 }
Chris@0 163 $list = [];
Chris@0 164
Chris@0 165 $classmap = $this->findAllClassFiles($extension);
Chris@0 166
Chris@0 167 // Prevent expensive class loader lookups for each reflected test class by
Chris@0 168 // registering the complete classmap of test classes to the class loader.
Chris@0 169 // This also ensures that test classes are loaded from the discovered
Chris@0 170 // pathnames; a namespace/classname mismatch will throw an exception.
Chris@0 171 $this->classLoader->addClassMap($classmap);
Chris@0 172
Chris@0 173 foreach ($classmap as $classname => $pathname) {
Chris@0 174 $finder = MockFileFinder::create($pathname);
Chris@0 175 $parser = new StaticReflectionParser($classname, $finder, TRUE);
Chris@0 176 try {
Chris@0 177 $info = static::getTestInfo($classname, $parser->getDocComment());
Chris@0 178 }
Chris@0 179 catch (MissingGroupException $e) {
Chris@0 180 // If the class name ends in Test and is not a migrate table dump.
Chris@0 181 if (preg_match('/Test$/', $classname) && strpos($classname, 'migrate_drupal\Tests\Table') === FALSE) {
Chris@0 182 throw $e;
Chris@0 183 }
Chris@0 184 // If the class is @group annotation just skip it. Most likely it is an
Chris@0 185 // abstract class, trait or test fixture.
Chris@0 186 continue;
Chris@0 187 }
Chris@0 188 // Skip this test class if it is a Simpletest-based test and requires
Chris@0 189 // unavailable modules. TestDiscovery should not filter out module
Chris@0 190 // requirements for PHPUnit-based test classes.
Chris@0 191 // @todo Move this behavior to \Drupal\simpletest\TestBase so tests can be
Chris@0 192 // marked as skipped, instead.
Chris@0 193 // @see https://www.drupal.org/node/1273478
Chris@0 194 if ($info['type'] == 'Simpletest') {
Chris@0 195 if (!empty($info['requires']['module'])) {
Chris@0 196 if (array_diff($info['requires']['module'], $this->availableExtensions['module'])) {
Chris@0 197 continue;
Chris@0 198 }
Chris@0 199 }
Chris@0 200 }
Chris@0 201
Chris@0 202 $list[$info['group']][$classname] = $info;
Chris@0 203 }
Chris@0 204
Chris@0 205 // Sort the groups and tests within the groups by name.
Chris@0 206 uksort($list, 'strnatcasecmp');
Chris@0 207 foreach ($list as &$tests) {
Chris@0 208 uksort($tests, 'strnatcasecmp');
Chris@0 209 }
Chris@0 210
Chris@0 211 // Allow modules extending core tests to disable originals.
Chris@4 212 $this->moduleHandler->alterDeprecated('Convert your test to a PHPUnit-based one and implement test listeners. See: https://www.drupal.org/node/2939892', 'simpletest', $list);
Chris@0 213
Chris@4 214 if (!isset($extension) && empty($types)) {
Chris@4 215 $this->testClasses = $list;
Chris@0 216 }
Chris@0 217
Chris@0 218 if ($types) {
Chris@0 219 $list = NestedArray::filter($list, function ($element) use ($types) {
Chris@0 220 return !(is_array($element) && isset($element['type']) && !in_array($element['type'], $types));
Chris@0 221 });
Chris@0 222 }
Chris@0 223
Chris@0 224 return $list;
Chris@0 225 }
Chris@0 226
Chris@0 227 /**
Chris@0 228 * Discovers all class files in all available extensions.
Chris@0 229 *
Chris@0 230 * @param string $extension
Chris@0 231 * (optional) The name of an extension to limit discovery to; e.g., 'node'.
Chris@0 232 *
Chris@0 233 * @return array
Chris@0 234 * A classmap containing all discovered class files; i.e., a map of
Chris@0 235 * fully-qualified classnames to pathnames.
Chris@0 236 */
Chris@0 237 public function findAllClassFiles($extension = NULL) {
Chris@0 238 $classmap = [];
Chris@0 239 $namespaces = $this->registerTestNamespaces();
Chris@0 240 if (isset($extension)) {
Chris@0 241 // Include tests in the \Drupal\Tests\{$extension} namespace.
Chris@0 242 $pattern = "/Drupal\\\(Tests\\\)?$extension\\\/";
Chris@0 243 $namespaces = array_intersect_key($namespaces, array_flip(preg_grep($pattern, array_keys($namespaces))));
Chris@0 244 }
Chris@0 245 foreach ($namespaces as $namespace => $paths) {
Chris@0 246 foreach ($paths as $path) {
Chris@0 247 if (!is_dir($path)) {
Chris@0 248 continue;
Chris@0 249 }
Chris@0 250 $classmap += static::scanDirectory($namespace, $path);
Chris@0 251 }
Chris@0 252 }
Chris@0 253 return $classmap;
Chris@0 254 }
Chris@0 255
Chris@0 256 /**
Chris@0 257 * Scans a given directory for class files.
Chris@0 258 *
Chris@0 259 * @param string $namespace_prefix
Chris@0 260 * The namespace prefix to use for discovered classes. Must contain a
Chris@0 261 * trailing namespace separator (backslash).
Chris@0 262 * For example: 'Drupal\\node\\Tests\\'
Chris@0 263 * @param string $path
Chris@0 264 * The directory path to scan.
Chris@0 265 * For example: '/path/to/drupal/core/modules/node/tests/src'
Chris@0 266 *
Chris@0 267 * @return array
Chris@0 268 * An associative array whose keys are fully-qualified class names and whose
Chris@0 269 * values are corresponding filesystem pathnames.
Chris@0 270 *
Chris@0 271 * @throws \InvalidArgumentException
Chris@0 272 * If $namespace_prefix does not end in a namespace separator (backslash).
Chris@0 273 *
Chris@0 274 * @todo Limit to '*Test.php' files (~10% less files to reflect/introspect).
Chris@0 275 * @see https://www.drupal.org/node/2296635
Chris@0 276 */
Chris@0 277 public static function scanDirectory($namespace_prefix, $path) {
Chris@0 278 if (substr($namespace_prefix, -1) !== '\\') {
Chris@0 279 throw new \InvalidArgumentException("Namespace prefix for $path must contain a trailing namespace separator.");
Chris@0 280 }
Chris@0 281 $flags = \FilesystemIterator::UNIX_PATHS;
Chris@0 282 $flags |= \FilesystemIterator::SKIP_DOTS;
Chris@0 283 $flags |= \FilesystemIterator::FOLLOW_SYMLINKS;
Chris@0 284 $flags |= \FilesystemIterator::CURRENT_AS_SELF;
Chris@4 285 $flags |= \FilesystemIterator::KEY_AS_FILENAME;
Chris@0 286
Chris@0 287 $iterator = new \RecursiveDirectoryIterator($path, $flags);
Chris@4 288 $filter = new \RecursiveCallbackFilterIterator($iterator, function ($current, $file_name, $iterator) {
Chris@0 289 if ($iterator->hasChildren()) {
Chris@0 290 return TRUE;
Chris@0 291 }
Chris@4 292 // We don't want to discover abstract TestBase classes, traits or
Chris@4 293 // interfaces. They can be deprecated and will call @trigger_error()
Chris@4 294 // during discovery.
Chris@4 295 return
Chris@4 296 substr($file_name, -4) === '.php' &&
Chris@4 297 substr($file_name, -12) !== 'TestBase.php' &&
Chris@4 298 substr($file_name, -9) !== 'Trait.php' &&
Chris@4 299 substr($file_name, -13) !== 'Interface.php';
Chris@0 300 });
Chris@0 301 $files = new \RecursiveIteratorIterator($filter);
Chris@0 302 $classes = [];
Chris@0 303 foreach ($files as $fileinfo) {
Chris@0 304 $class = $namespace_prefix;
Chris@0 305 if ('' !== $subpath = $fileinfo->getSubPath()) {
Chris@0 306 $class .= strtr($subpath, '/', '\\') . '\\';
Chris@0 307 }
Chris@0 308 $class .= $fileinfo->getBasename('.php');
Chris@0 309 $classes[$class] = $fileinfo->getPathname();
Chris@0 310 }
Chris@0 311 return $classes;
Chris@0 312 }
Chris@0 313
Chris@0 314 /**
Chris@0 315 * Retrieves information about a test class for UI purposes.
Chris@0 316 *
Chris@0 317 * @param string $classname
Chris@0 318 * The test classname.
Chris@0 319 * @param string $doc_comment
Chris@0 320 * (optional) The class PHPDoc comment. If not passed in reflection will be
Chris@0 321 * used but this is very expensive when parsing all the test classes.
Chris@0 322 *
Chris@0 323 * @return array
Chris@0 324 * An associative array containing:
Chris@0 325 * - name: The test class name.
Chris@0 326 * - description: The test (PHPDoc) summary.
Chris@0 327 * - group: The test's first @group (parsed from PHPDoc annotations).
Chris@0 328 * - requires: An associative array containing test requirements parsed from
Chris@0 329 * PHPDoc annotations:
Chris@0 330 * - module: List of Drupal module extension names the test depends on.
Chris@0 331 *
Chris@0 332 * @throws \Drupal\simpletest\Exception\MissingGroupException
Chris@0 333 * If the class does not have a @group annotation.
Chris@0 334 */
Chris@0 335 public static function getTestInfo($classname, $doc_comment = NULL) {
Chris@0 336 if ($doc_comment === NULL) {
Chris@0 337 $reflection = new \ReflectionClass($classname);
Chris@0 338 $doc_comment = $reflection->getDocComment();
Chris@0 339 }
Chris@0 340 $info = [
Chris@0 341 'name' => $classname,
Chris@0 342 ];
Chris@0 343 $annotations = [];
Chris@0 344 // Look for annotations, allow an arbitrary amount of spaces before the
Chris@0 345 // * but nothing else.
Chris@0 346 preg_match_all('/^[ ]*\* \@([^\s]*) (.*$)/m', $doc_comment, $matches);
Chris@0 347 if (isset($matches[1])) {
Chris@0 348 foreach ($matches[1] as $key => $annotation) {
Chris@0 349 if (!empty($annotations[$annotation])) {
Chris@0 350 // Only have the first match per annotation. This deals with
Chris@0 351 // multiple @group annotations.
Chris@0 352 continue;
Chris@0 353 }
Chris@0 354 $annotations[$annotation] = $matches[2][$key];
Chris@0 355 }
Chris@0 356 }
Chris@0 357
Chris@0 358 if (empty($annotations['group'])) {
Chris@0 359 // Concrete tests must have a group.
Chris@0 360 throw new MissingGroupException(sprintf('Missing @group annotation in %s', $classname));
Chris@0 361 }
Chris@0 362 $info['group'] = $annotations['group'];
Chris@0 363 // Put PHPUnit test suites into their own custom groups.
Chris@0 364 if ($testsuite = static::getPhpunitTestSuite($classname)) {
Chris@0 365 $info['type'] = 'PHPUnit-' . $testsuite;
Chris@0 366 }
Chris@0 367 else {
Chris@0 368 $info['type'] = 'Simpletest';
Chris@0 369 }
Chris@0 370
Chris@0 371 if (!empty($annotations['coversDefaultClass'])) {
Chris@0 372 $info['description'] = 'Tests ' . $annotations['coversDefaultClass'] . '.';
Chris@0 373 }
Chris@0 374 else {
Chris@0 375 $info['description'] = static::parseTestClassSummary($doc_comment);
Chris@0 376 }
Chris@0 377 if (isset($annotations['dependencies'])) {
Chris@0 378 $info['requires']['module'] = array_map('trim', explode(',', $annotations['dependencies']));
Chris@0 379 }
Chris@0 380
Chris@0 381 return $info;
Chris@0 382 }
Chris@0 383
Chris@0 384 /**
Chris@0 385 * Parses the phpDoc summary line of a test class.
Chris@0 386 *
Chris@0 387 * @param string $doc_comment
Chris@0 388 *
Chris@0 389 * @return string
Chris@0 390 * The parsed phpDoc summary line. An empty string is returned if no summary
Chris@0 391 * line can be parsed.
Chris@0 392 */
Chris@0 393 public static function parseTestClassSummary($doc_comment) {
Chris@0 394 // Normalize line endings.
Chris@0 395 $doc_comment = preg_replace('/\r\n|\r/', '\n', $doc_comment);
Chris@0 396 // Strip leading and trailing doc block lines.
Chris@0 397 $doc_comment = substr($doc_comment, 4, -4);
Chris@0 398
Chris@0 399 $lines = explode("\n", $doc_comment);
Chris@0 400 $summary = [];
Chris@0 401 // Add every line to the summary until the first empty line or annotation
Chris@0 402 // is found.
Chris@0 403 foreach ($lines as $line) {
Chris@0 404 if (preg_match('/^[ ]*\*$/', $line) || preg_match('/^[ ]*\* \@/', $line)) {
Chris@0 405 break;
Chris@0 406 }
Chris@0 407 $summary[] = trim($line, ' *');
Chris@0 408 }
Chris@0 409 return implode(' ', $summary);
Chris@0 410 }
Chris@0 411
Chris@0 412 /**
Chris@0 413 * Parses annotations in the phpDoc of a test class.
Chris@0 414 *
Chris@0 415 * @param \ReflectionClass $class
Chris@0 416 * The reflected test class.
Chris@0 417 *
Chris@0 418 * @return array
Chris@0 419 * An associative array that contains all annotations on the test class;
Chris@0 420 * typically including:
Chris@0 421 * - group: A list of @group values.
Chris@0 422 * - requires: An associative array of @requires values; e.g.:
Chris@0 423 * - module: A list of Drupal module dependencies that are required to
Chris@0 424 * exist.
Chris@0 425 *
Chris@0 426 * @see PHPUnit_Util_Test::parseTestMethodAnnotations()
Chris@0 427 * @see http://phpunit.de/manual/current/en/incomplete-and-skipped-tests.html#incomplete-and-skipped-tests.skipping-tests-using-requires
Chris@0 428 */
Chris@0 429 public static function parseTestClassAnnotations(\ReflectionClass $class) {
Chris@0 430 $annotations = PHPUnit_Util_Test::parseTestMethodAnnotations($class->getName())['class'];
Chris@0 431
Chris@0 432 // @todo Enhance PHPUnit upstream to allow for custom @requires identifiers.
Chris@0 433 // @see PHPUnit_Util_Test::getRequirements()
Chris@0 434 // @todo Add support for 'PHP', 'OS', 'function', 'extension'.
Chris@0 435 // @see https://www.drupal.org/node/1273478
Chris@0 436 if (isset($annotations['requires'])) {
Chris@0 437 foreach ($annotations['requires'] as $i => $value) {
Chris@0 438 list($type, $value) = explode(' ', $value, 2);
Chris@0 439 if ($type === 'module') {
Chris@0 440 $annotations['requires']['module'][$value] = $value;
Chris@0 441 unset($annotations['requires'][$i]);
Chris@0 442 }
Chris@0 443 }
Chris@0 444 }
Chris@0 445 return $annotations;
Chris@0 446 }
Chris@0 447
Chris@0 448 /**
Chris@0 449 * Determines the phpunit testsuite for a given classname.
Chris@0 450 *
Chris@0 451 * @param string $classname
Chris@0 452 * The test classname.
Chris@0 453 *
Chris@0 454 * @return string|false
Chris@0 455 * The testsuite name or FALSE if its not a phpunit test.
Chris@0 456 */
Chris@0 457 public static function getPhpunitTestSuite($classname) {
Chris@0 458 if (preg_match('/Drupal\\\\Tests\\\\Core\\\\(\w+)/', $classname, $matches)) {
Chris@0 459 return 'Unit';
Chris@0 460 }
Chris@0 461 if (preg_match('/Drupal\\\\Tests\\\\Component\\\\(\w+)/', $classname, $matches)) {
Chris@0 462 return 'Unit';
Chris@0 463 }
Chris@0 464 // Module tests.
Chris@0 465 if (preg_match('/Drupal\\\\Tests\\\\(\w+)\\\\(\w+)/', $classname, $matches)) {
Chris@0 466 return $matches[2];
Chris@0 467 }
Chris@0 468 // Core tests.
Chris@0 469 elseif (preg_match('/Drupal\\\\(\w*)Tests\\\\/', $classname, $matches)) {
Chris@0 470 if ($matches[1] == '') {
Chris@0 471 return 'Unit';
Chris@0 472 }
Chris@0 473 return $matches[1];
Chris@0 474 }
Chris@0 475 return FALSE;
Chris@0 476 }
Chris@0 477
Chris@0 478 /**
Chris@0 479 * Returns all available extensions.
Chris@0 480 *
Chris@0 481 * @return \Drupal\Core\Extension\Extension[]
Chris@0 482 * An array of Extension objects, keyed by extension name.
Chris@0 483 */
Chris@0 484 protected function getExtensions() {
Chris@0 485 $listing = new ExtensionDiscovery($this->root);
Chris@0 486 // Ensure that tests in all profiles are discovered.
Chris@0 487 $listing->setProfileDirectories([]);
Chris@0 488 $extensions = $listing->scan('module', TRUE);
Chris@0 489 $extensions += $listing->scan('profile', TRUE);
Chris@0 490 $extensions += $listing->scan('theme', TRUE);
Chris@0 491 return $extensions;
Chris@0 492 }
Chris@0 493
Chris@0 494 }