Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0

This commit is contained in:
Pantheon Automation 2016-10-06 15:16:20 -07:00 committed by Greg Anderson
parent 2f563ab520
commit f1c8716f57
1732 changed files with 52334 additions and 11780 deletions

View file

@ -7,9 +7,6 @@ use Drupal\Component\FileCache\FileCache;
use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Config\ConfigImporter;
use Drupal\Core\Config\StorageComparer;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Database\Database;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderInterface;
@ -18,8 +15,10 @@ use Drupal\Core\Entity\Sql\SqlEntityStorageInterface;
use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\Core\Language\Language;
use Drupal\Core\Site\Settings;
use Drupal\Core\Test\TestDatabase;
use Drupal\simpletest\AssertContentTrait;
use Drupal\simpletest\AssertHelperTrait;
use Drupal\Tests\ConfigTestTrait;
use Drupal\Tests\RandomGeneratorTrait;
use Drupal\simpletest\TestServiceProvider;
use Symfony\Component\DependencyInjection\Reference;
@ -55,6 +54,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
use AssertContentTrait;
use AssertHelperTrait;
use RandomGeneratorTrait;
use ConfigTestTrait;
/**
* {@inheritdoc}
@ -252,31 +252,14 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
require_once $this->root . '/core/includes/bootstrap.inc';
// Set up virtual filesystem.
// Ensure that the generated test site directory does not exist already,
// which may happen with a large amount of concurrent threads and
// long-running tests.
do {
$suffix = mt_rand(100000, 999999);
$this->siteDirectory = 'sites/simpletest/' . $suffix;
$this->databasePrefix = 'simpletest' . $suffix;
} while (is_dir($this->root . '/' . $this->siteDirectory));
$this->vfsRoot = vfsStream::setup('root', NULL, array(
'sites' => array(
'simpletest' => array(
$suffix => array(),
),
),
));
$this->siteDirectory = vfsStream::url('root/sites/simpletest/' . $suffix);
mkdir($this->siteDirectory . '/files', 0775);
mkdir($this->siteDirectory . '/files/config/' . CONFIG_SYNC_DIRECTORY, 0775, TRUE);
Database::addConnectionInfo('default', 'test-runner', $this->getDatabaseConnectionInfo()['default']);
$test_db = new TestDatabase();
$this->siteDirectory = $test_db->getTestSitePath();
// Ensure that all code that relies on drupal_valid_test_ua() can still be
// safely executed. This primarily affects the (test) site directory
// resolution (used by e.g. LocalStream and PhpStorage).
$this->databasePrefix = 'simpletest' . $suffix;
$this->databasePrefix = $test_db->getDatabasePrefix();
drupal_valid_test_ua($this->databasePrefix);
$settings = array(
@ -288,9 +271,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
);
new Settings($settings);
$GLOBALS['config_directories'] = array(
CONFIG_SYNC_DIRECTORY => $this->siteDirectory . '/files/config/sync',
);
$this->setUpFilesystem();
foreach (Database::getAllConnectionInfo() as $key => $targets) {
Database::removeConnection($key);
@ -298,6 +279,29 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
Database::addConnectionInfo('default', 'default', $this->getDatabaseConnectionInfo()['default']);
}
/**
* Sets up the filesystem, so things like the file directory.
*/
protected function setUpFilesystem() {
$test_db = new TestDatabase($this->databasePrefix);
$test_site_path = $test_db->getTestSitePath();
$this->vfsRoot = vfsStream::setup('root');
$this->vfsRoot->addChild(vfsStream::newDirectory($test_site_path));
$this->siteDirectory = vfsStream::url('root/' . $test_site_path);
mkdir($this->siteDirectory . '/files', 0775);
mkdir($this->siteDirectory . '/files/config/' . CONFIG_SYNC_DIRECTORY, 0775, TRUE);
$settings = Settings::getInstance() ? Settings::getAll() : [];
$settings['file_public_path'] = $this->siteDirectory . '/files';
new Settings($settings);
$GLOBALS['config_directories'] = array(
CONFIG_SYNC_DIRECTORY => $this->siteDirectory . '/files/config/sync',
);
}
/**
* @return string
*/
@ -531,11 +535,6 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
// Provide a default configuration, if not set.
if (!isset($configuration['default'])) {
$configuration['default'] = [
'class' => FileCache::class,
'cache_backend_class' => NULL,
'cache_backend_configuration' => [],
];
// @todo Use extension_loaded('apcu') for non-testbot
// https://www.drupal.org/node/2447753.
if (function_exists('apcu_fetch')) {
@ -663,7 +662,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
}
// Shut down the kernel (if bootKernel() was called).
// @see \Drupal\system\Tests\DrupalKernel\DrupalKernelTest
// @see \Drupal\KernelTests\Core\DrupalKernel\DrupalKernelTest
if ($this->container) {
$this->container->get('kernel')->shutdown();
}
@ -998,59 +997,11 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
* \Drupal\Core\Site\Settings::get() to perform custom merges.
*/
protected function setSetting($name, $value) {
$settings = Settings::getAll();
$settings = Settings::getInstance() ? Settings::getAll() : [];
$settings[$name] = $value;
new Settings($settings);
}
/**
* Returns a ConfigImporter object to import test configuration.
*
* @return \Drupal\Core\Config\ConfigImporter
*
* @todo Move into Config-specific test base class.
*/
protected function configImporter() {
if (!$this->configImporter) {
// Set up the ConfigImporter object for testing.
$storage_comparer = new StorageComparer(
$this->container->get('config.storage.sync'),
$this->container->get('config.storage'),
$this->container->get('config.manager')
);
$this->configImporter = new ConfigImporter(
$storage_comparer,
$this->container->get('event_dispatcher'),
$this->container->get('config.manager'),
$this->container->get('lock'),
$this->container->get('config.typed'),
$this->container->get('module_handler'),
$this->container->get('module_installer'),
$this->container->get('theme_handler'),
$this->container->get('string_translation')
);
}
// Always recalculate the changelist when called.
return $this->configImporter->reset();
}
/**
* Copies configuration objects from a source storage to a target storage.
*
* @param \Drupal\Core\Config\StorageInterface $source_storage
* The source config storage.
* @param \Drupal\Core\Config\StorageInterface $target_storage
* The target config storage.
*
* @todo Move into Config-specific test base class.
*/
protected function copyConfig(StorageInterface $source_storage, StorageInterface $target_storage) {
$target_storage->deleteAll();
foreach ($source_storage->listAll() as $name) {
$target_storage->write($name, $source_storage->read($name));
}
}
/**
* Stops test execution.
*/
@ -1146,7 +1097,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
return Settings::get('file_public_path', \Drupal::service('site.path') . '/files');
case 'private_files_directory':
return $this->container->get('config.factory')->get('system.file')->get('path.private');
return Settings::get('file_private_path');
case 'temp_files_directory':
return file_directory_temp();