Issue #2631478 by neclimdul: bootstrap.php loader can show as changed global state
parent
17bc367138
commit
87cded8723
|
@ -235,8 +235,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
|
||||||
$this->streamWrappers = array();
|
$this->streamWrappers = array();
|
||||||
\Drupal::unsetContainer();
|
\Drupal::unsetContainer();
|
||||||
|
|
||||||
// @see /core/tests/bootstrap.php
|
$this->classLoader = require $this->root . '/autoload.php';
|
||||||
$this->classLoader = $GLOBALS['loader'];
|
|
||||||
|
|
||||||
require_once $this->root . '/core/includes/bootstrap.inc';
|
require_once $this->root . '/core/includes/bootstrap.inc';
|
||||||
|
|
||||||
|
|
|
@ -87,8 +87,21 @@ function drupal_phpunit_get_extension_namespaces($dirs) {
|
||||||
if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
|
if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
|
||||||
define('PHPUNIT_COMPOSER_INSTALL', __DIR__ . '/../../autoload.php');
|
define('PHPUNIT_COMPOSER_INSTALL', __DIR__ . '/../../autoload.php');
|
||||||
}
|
}
|
||||||
// Start with classes in known locations.
|
|
||||||
|
/**
|
||||||
|
* Populate class loader with additional namespaces for tests.
|
||||||
|
*
|
||||||
|
* We run this in a function to avoid setting the class loader to a global
|
||||||
|
* that can change. This change can cause unpredictable false positives for
|
||||||
|
* phpunit's global state change watcher. The class loader can be retrieved from
|
||||||
|
* composer at any time by requiring autoload.php.
|
||||||
|
*/
|
||||||
|
function drupal_phpunit_populate_class_loader() {
|
||||||
|
|
||||||
|
/** @var \Composer\Autoload\ClassLoader $loader */
|
||||||
$loader = require __DIR__ . '/../../autoload.php';
|
$loader = require __DIR__ . '/../../autoload.php';
|
||||||
|
|
||||||
|
// Start with classes in known locations.
|
||||||
$loader->add('Drupal\\Tests', __DIR__);
|
$loader->add('Drupal\\Tests', __DIR__);
|
||||||
$loader->add('Drupal\\KernelTests', __DIR__);
|
$loader->add('Drupal\\KernelTests', __DIR__);
|
||||||
|
|
||||||
|
@ -104,6 +117,12 @@ foreach ($GLOBALS['namespaces'] as $prefix => $paths) {
|
||||||
$loader->addPsr4($prefix, $paths);
|
$loader->addPsr4($prefix, $paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $loader;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Do class loader population.
|
||||||
|
drupal_phpunit_populate_class_loader();
|
||||||
|
|
||||||
// Set sane locale settings, to ensure consistent string, dates, times and
|
// Set sane locale settings, to ensure consistent string, dates, times and
|
||||||
// numbers handling.
|
// numbers handling.
|
||||||
// @see \Drupal\Core\DrupalKernel::bootEnvironment()
|
// @see \Drupal\Core\DrupalKernel::bootEnvironment()
|
||||||
|
|
Loading…
Reference in New Issue