Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Test\EventSubscriber\HttpRequestSubscriber.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Test\EventSubscriber;
|
||||
|
||||
use GuzzleHttp\Event\BeforeEvent;
|
||||
use GuzzleHttp\Event\SubscriberInterface;
|
||||
|
||||
/**
|
||||
* Overrides the User-Agent HTTP header for outbound HTTP requests.
|
||||
*/
|
||||
class HttpRequestSubscriber implements SubscriberInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getEvents() {
|
||||
return array(
|
||||
'before' => array('onBeforeSendRequest'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Event callback for the 'before' event
|
||||
*/
|
||||
public function onBeforeSendRequest(BeforeEvent $event) {
|
||||
// If the database prefix is being used by SimpleTest to run the tests in a copied
|
||||
// database then set the user-agent header to the database prefix so that any
|
||||
// calls to other Drupal pages will run the SimpleTest prefixed database. The
|
||||
// user-agent is used to ensure that multiple testing sessions running at the
|
||||
// same time won't interfere with each other as they would if the database
|
||||
// prefix were stored statically in a file or database variable.
|
||||
if ($test_prefix = drupal_valid_test_ua()) {
|
||||
$event->getRequest()->setHeader('User-Agent', drupal_generate_test_ua($test_prefix));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
33
core/lib/Drupal/Core/Test/TestKernel.php
Normal file
33
core/lib/Drupal/Core/Test/TestKernel.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Test\TestKernel.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Test;
|
||||
|
||||
use Drupal\Core\DrupalKernel;
|
||||
|
||||
/**
|
||||
* Kernel to mock requests to test simpletest.
|
||||
*/
|
||||
class TestKernel extends DrupalKernel {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($environment, $class_loader, $allow_dumping = TRUE) {
|
||||
// Include our bootstrap file.
|
||||
require_once __DIR__ . '/../../../../includes/bootstrap.inc';
|
||||
|
||||
// Exit if we should be in a test environment but aren't.
|
||||
if (!drupal_valid_test_ua()) {
|
||||
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
|
||||
exit;
|
||||
}
|
||||
|
||||
parent::__construct($environment, $class_loader, $allow_dumping);
|
||||
}
|
||||
|
||||
}
|
99
core/lib/Drupal/Core/Test/TestRunnerKernel.php
Normal file
99
core/lib/Drupal/Core/Test/TestRunnerKernel.php
Normal file
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Test\TestRunnerKernel.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Test;
|
||||
|
||||
use Drupal\Core\DrupalKernel;
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Drupal\Core\Installer\InstallerServiceProvider;
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use Drupal\Core\Site\Settings;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Kernel for run-tests.sh.
|
||||
*/
|
||||
class TestRunnerKernel extends DrupalKernel {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function createFromRequest(Request $request, $class_loader, $environment = 'test_runner', $allow_dumping = TRUE) {
|
||||
return parent::createFromRequest($request, $class_loader, $environment);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($environment, $class_loader) {
|
||||
parent::__construct($environment, $class_loader, FALSE);
|
||||
|
||||
// Prime the module list and corresponding Extension objects.
|
||||
// @todo Remove System module. Needed because
|
||||
// \Drupal\Core\Datetime\DateFormatter has a (needless) dependency on the
|
||||
// 'date_format' entity, so calls to format_date()/format_interval() cause
|
||||
// a plugin not found exception.
|
||||
$this->moduleList = array(
|
||||
'system' => 0,
|
||||
'simpletest' => 0,
|
||||
);
|
||||
$this->moduleData = array(
|
||||
'system' => new Extension($this->root, 'module', 'core/modules/system/system.info.yml', 'system.module'),
|
||||
'simpletest' => new Extension($this->root, 'module', 'core/modules/simpletest/simpletest.info.yml', 'simpletest.module'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function boot() {
|
||||
// Ensure that required Settings exist.
|
||||
if (!Settings::getAll()) {
|
||||
new Settings(array(
|
||||
'hash_salt' => 'run-tests',
|
||||
'container_yamls' => [],
|
||||
// If there is no settings.php, then there is no parent site. In turn,
|
||||
// there is no public files directory; use a custom public files path.
|
||||
'file_public_path' => 'sites/default/files',
|
||||
));
|
||||
}
|
||||
|
||||
// Remove Drupal's error/exception handlers; they are designed for HTML
|
||||
// and there is no storage nor a (watchdog) logger here.
|
||||
restore_error_handler();
|
||||
restore_exception_handler();
|
||||
|
||||
// In addition, ensure that PHP errors are not hidden away in logs.
|
||||
ini_set('display_errors', TRUE);
|
||||
|
||||
parent::boot();
|
||||
|
||||
$this->getContainer()->get('module_handler')->loadAll();
|
||||
|
||||
simpletest_classloader_register();
|
||||
|
||||
// Register stream wrappers.
|
||||
$this->getContainer()->get('stream_wrapper_manager')->register();
|
||||
|
||||
// Create the build/artifacts directory if necessary.
|
||||
include_once DRUPAL_ROOT . '/core/includes/file.inc';
|
||||
if (!is_dir('public://simpletest')) {
|
||||
mkdir('public://simpletest', 0777, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function discoverServiceProviders() {
|
||||
parent::discoverServiceProviders();
|
||||
// The test runner does not require an installed Drupal site to exist.
|
||||
// Therefore, its environment is identical to that of the early installer.
|
||||
$this->serviceProviderClasses['app']['Test'] = 'Drupal\Core\Installer\InstallerServiceProvider';
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue