Issue #3151118 by alexpott, Beakerboy, kapilkumar0324, anmolgoyal74, jungle, heddn, Mile23, andypost, daffie: Include bootstrap.inc using composer
parent
a8ef4362e6
commit
b72fe50a60
|
@ -527,7 +527,7 @@
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"url": "core",
|
"url": "core",
|
||||||
"reference": "0809224944e41d0a5d03f65e1f7a179512647923"
|
"reference": "af5b9453adf15c6831b1f73e322f8c59da877f14"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"asm89/stack-cors": "^1.1",
|
"asm89/stack-cors": "^1.1",
|
||||||
|
@ -752,6 +752,9 @@
|
||||||
"lib/Drupal/Core/DrupalKernelInterface.php",
|
"lib/Drupal/Core/DrupalKernelInterface.php",
|
||||||
"lib/Drupal/Core/Installer/InstallerRedirectTrait.php",
|
"lib/Drupal/Core/Installer/InstallerRedirectTrait.php",
|
||||||
"lib/Drupal/Core/Site/Settings.php"
|
"lib/Drupal/Core/Site/Settings.php"
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
"includes/bootstrap.inc"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -16,7 +16,6 @@ $autoloader = require_once 'autoload.php';
|
||||||
// Disable garbage collection during test runs. Under certain circumstances the
|
// Disable garbage collection during test runs. Under certain circumstances the
|
||||||
// update path will create so many objects that garbage collection causes
|
// update path will create so many objects that garbage collection causes
|
||||||
// segmentation faults.
|
// segmentation faults.
|
||||||
require_once 'core/includes/bootstrap.inc';
|
|
||||||
if (drupal_valid_test_ua()) {
|
if (drupal_valid_test_ua()) {
|
||||||
gc_collect_cycles();
|
gc_collect_cycles();
|
||||||
gc_disable();
|
gc_disable();
|
||||||
|
|
|
@ -198,7 +198,8 @@
|
||||||
"lib/Drupal/Core/DrupalKernelInterface.php",
|
"lib/Drupal/Core/DrupalKernelInterface.php",
|
||||||
"lib/Drupal/Core/Installer/InstallerRedirectTrait.php",
|
"lib/Drupal/Core/Installer/InstallerRedirectTrait.php",
|
||||||
"lib/Drupal/Core/Site/Settings.php"
|
"lib/Drupal/Core/Site/Settings.php"
|
||||||
]
|
],
|
||||||
|
"files": [ "includes/bootstrap.inc" ]
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"preferred-install": "dist"
|
"preferred-install": "dist"
|
||||||
|
|
|
@ -311,9 +311,6 @@ function install_begin_request($class_loader, &$install_state) {
|
||||||
$install_state['parameters']['langcode'] = preg_replace('/[^a-zA-Z_0-9\-]/', '', $install_state['parameters']['langcode']);
|
$install_state['parameters']['langcode'] = preg_replace('/[^a-zA-Z_0-9\-]/', '', $install_state['parameters']['langcode']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow command line scripts to override server variables used by Drupal.
|
|
||||||
require_once __DIR__ . '/bootstrap.inc';
|
|
||||||
|
|
||||||
// If the hash salt leaks, it becomes possible to forge a valid testing user
|
// If the hash salt leaks, it becomes possible to forge a valid testing user
|
||||||
// agent, install a new copy of Drupal, and take over the original site.
|
// agent, install a new copy of Drupal, and take over the original site.
|
||||||
// The user agent header is used to pass a database prefix in the request when
|
// The user agent header is used to pass a database prefix in the request when
|
||||||
|
|
|
@ -984,9 +984,6 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
|
||||||
$app_root = static::guessApplicationRoot();
|
$app_root = static::guessApplicationRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include our bootstrap file.
|
|
||||||
require_once $app_root . '/core/includes/bootstrap.inc';
|
|
||||||
|
|
||||||
// Enforce E_STRICT, but allow users to set levels not part of E_STRICT.
|
// Enforce E_STRICT, but allow users to set levels not part of E_STRICT.
|
||||||
error_reporting(E_STRICT | E_ALL);
|
error_reporting(E_STRICT | E_ALL);
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,6 @@ class TestKernel extends DrupalKernel {
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function __construct($environment, $class_loader, $allow_dumping = TRUE) {
|
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.
|
// Exit if we should be in a test environment but aren't.
|
||||||
if (!drupal_valid_test_ua()) {
|
if (!drupal_valid_test_ua()) {
|
||||||
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
|
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
|
||||||
|
|
|
@ -1195,24 +1195,3 @@ class TestEntityType extends ContentEntityType {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Drupal\entity_test\Entity;
|
|
||||||
|
|
||||||
if (!function_exists('t')) {
|
|
||||||
|
|
||||||
function t($string, array $args = []) {
|
|
||||||
return strtr($string, $args);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace Drupal\Core\Entity;
|
|
||||||
|
|
||||||
if (!function_exists('t')) {
|
|
||||||
|
|
||||||
function t($string, array $args = []) {
|
|
||||||
return strtr($string, $args);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ require_once __DIR__ . '/includes/utility.inc';
|
||||||
|
|
||||||
$request = Request::createFromGlobals();
|
$request = Request::createFromGlobals();
|
||||||
// Manually resemble early bootstrap of DrupalKernel::boot().
|
// Manually resemble early bootstrap of DrupalKernel::boot().
|
||||||
require_once __DIR__ . '/includes/bootstrap.inc';
|
|
||||||
DrupalKernel::bootEnvironment();
|
DrupalKernel::bootEnvironment();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -17,7 +17,6 @@ if (PHP_SAPI !== 'cli') {
|
||||||
|
|
||||||
// Bootstrap.
|
// Bootstrap.
|
||||||
$autoloader = require __DIR__ . '/../../autoload.php';
|
$autoloader = require __DIR__ . '/../../autoload.php';
|
||||||
require_once __DIR__ . '/../includes/bootstrap.inc';
|
|
||||||
$request = Request::createFromGlobals();
|
$request = Request::createFromGlobals();
|
||||||
Settings::initialize(dirname(__DIR__, 2), DrupalKernel::findSitePath($request), $autoloader);
|
Settings::initialize(dirname(__DIR__, 2), DrupalKernel::findSitePath($request), $autoloader);
|
||||||
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
|
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
|
||||||
|
|
|
@ -17,7 +17,6 @@ if (PHP_SAPI !== 'cli') {
|
||||||
|
|
||||||
// Bootstrap.
|
// Bootstrap.
|
||||||
$autoloader = require __DIR__ . '/../../autoload.php';
|
$autoloader = require __DIR__ . '/../../autoload.php';
|
||||||
require_once __DIR__ . '/../includes/bootstrap.inc';
|
|
||||||
$request = Request::createFromGlobals();
|
$request = Request::createFromGlobals();
|
||||||
Settings::initialize(dirname(__DIR__, 2), DrupalKernel::findSitePath($request), $autoloader);
|
Settings::initialize(dirname(__DIR__, 2), DrupalKernel::findSitePath($request), $autoloader);
|
||||||
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
|
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
|
||||||
|
|
|
@ -18,7 +18,6 @@ if (PHP_SAPI !== 'cli') {
|
||||||
|
|
||||||
// Bootstrap.
|
// Bootstrap.
|
||||||
$autoloader = require __DIR__ . '/../../autoload.php';
|
$autoloader = require __DIR__ . '/../../autoload.php';
|
||||||
require_once __DIR__ . '/../includes/bootstrap.inc';
|
|
||||||
$request = Request::createFromGlobals();
|
$request = Request::createFromGlobals();
|
||||||
Settings::initialize(dirname(__DIR__, 2), DrupalKernel::findSitePath($request), $autoloader);
|
Settings::initialize(dirname(__DIR__, 2), DrupalKernel::findSitePath($request), $autoloader);
|
||||||
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
|
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
|
||||||
|
|
|
@ -16,7 +16,6 @@ if (PHP_SAPI !== 'cli') {
|
||||||
}
|
}
|
||||||
|
|
||||||
$autoloader = require __DIR__ . '/../../autoload.php';
|
$autoloader = require __DIR__ . '/../../autoload.php';
|
||||||
require_once __DIR__ . '/../includes/bootstrap.inc';
|
|
||||||
|
|
||||||
$request = Request::createFromGlobals();
|
$request = Request::createFromGlobals();
|
||||||
Settings::initialize(DRUPAL_ROOT, DrupalKernel::findSitePath($request), $autoloader);
|
Settings::initialize(DRUPAL_ROOT, DrupalKernel::findSitePath($request), $autoloader);
|
||||||
|
|
|
@ -258,8 +258,6 @@ abstract class KernelTestBase extends TestCase implements ServiceProviderInterfa
|
||||||
|
|
||||||
$this->classLoader = require $this->root . '/autoload.php';
|
$this->classLoader = require $this->root . '/autoload.php';
|
||||||
|
|
||||||
require_once $this->root . '/core/includes/bootstrap.inc';
|
|
||||||
|
|
||||||
// Set up virtual filesystem.
|
// Set up virtual filesystem.
|
||||||
Database::addConnectionInfo('default', 'test-runner', $this->getDatabaseConnectionInfo()['default']);
|
Database::addConnectionInfo('default', 'test-runner', $this->getDatabaseConnectionInfo()['default']);
|
||||||
$test_db = new TestDatabase();
|
$test_db = new TestDatabase();
|
||||||
|
|
|
@ -60,7 +60,6 @@ class QuickStartTest extends TestCase {
|
||||||
}
|
}
|
||||||
// Get a lock and a valid site path.
|
// Get a lock and a valid site path.
|
||||||
$this->testDb = new TestDatabase();
|
$this->testDb = new TestDatabase();
|
||||||
include $this->root . '/core/includes/bootstrap.inc';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -59,13 +59,6 @@ class CronTest extends UnitTestCase {
|
||||||
protected function setUp(): void {
|
protected function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
// @todo Remove in https://www.drupal.org/project/drupal/issues/2932518
|
|
||||||
//
|
|
||||||
// This line is currently needed so that watchdog_exception() is available
|
|
||||||
// when unit testing Drupal\Core\Cron and can safely be removed once that
|
|
||||||
// class no longer refers to it.
|
|
||||||
require_once $this->root . '/core/includes/bootstrap.inc';
|
|
||||||
|
|
||||||
// Construct a state object used for testing logger assertions.
|
// Construct a state object used for testing logger assertions.
|
||||||
$this->state = new State(new KeyValueMemoryFactory());
|
$this->state = new State(new KeyValueMemoryFactory());
|
||||||
|
|
||||||
|
|
|
@ -82,11 +82,6 @@ class DatabaseTest extends UnitTestCase {
|
||||||
*/
|
*/
|
||||||
public function testFindDriverAutoloadDirectoryException($expected_message, $namespace, $include_tests) {
|
public function testFindDriverAutoloadDirectoryException($expected_message, $namespace, $include_tests) {
|
||||||
new Settings(['extension_discovery_scan_tests' => $include_tests]);
|
new Settings(['extension_discovery_scan_tests' => $include_tests]);
|
||||||
if ($include_tests === FALSE) {
|
|
||||||
// \Drupal\Core\Extension\ExtensionDiscovery::scan() needs
|
|
||||||
// drupal_valid_test_ua().
|
|
||||||
include $this->root . '/core/includes/bootstrap.inc';
|
|
||||||
}
|
|
||||||
$this->expectException(\RuntimeException::class);
|
$this->expectException(\RuntimeException::class);
|
||||||
$this->expectExceptionMessage($expected_message);
|
$this->expectExceptionMessage($expected_message);
|
||||||
Database::findDriverAutoloadDirectory($namespace, $this->root);
|
Database::findDriverAutoloadDirectory($namespace, $this->root);
|
||||||
|
|
|
@ -1,195 +1,183 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Drupal\Tests\Core\DrupalKernel {
|
namespace Drupal\Tests\Core\DrupalKernel;
|
||||||
|
|
||||||
use Drupal\Core\DrupalKernel;
|
use Drupal\Core\DrupalKernel;
|
||||||
use Drupal\Tests\UnitTestCase;
|
use Drupal\Tests\UnitTestCase;
|
||||||
use org\bovigo\vfs\vfsStream;
|
use org\bovigo\vfs\vfsStream;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @coversDefaultClass \Drupal\Core\DrupalKernel
|
||||||
|
* @group DrupalKernel
|
||||||
|
*/
|
||||||
|
class DrupalKernelTest extends UnitTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @coversDefaultClass \Drupal\Core\DrupalKernel
|
* Tests hostname validation with settings.
|
||||||
* @group DrupalKernel
|
*
|
||||||
|
* @covers ::setupTrustedHosts
|
||||||
|
* @dataProvider providerTestTrustedHosts
|
||||||
*/
|
*/
|
||||||
class DrupalKernelTest extends UnitTestCase {
|
public function testTrustedHosts($host, $server_name, $message, $expected = FALSE) {
|
||||||
|
$request = new Request();
|
||||||
|
|
||||||
/**
|
$trusted_host_patterns = [
|
||||||
* Tests hostname validation with settings.
|
'^example\.com$',
|
||||||
*
|
'^.+\.example\.com$',
|
||||||
* @covers ::setupTrustedHosts
|
'^example\.org',
|
||||||
* @dataProvider providerTestTrustedHosts
|
'^.+\.example\.org',
|
||||||
*/
|
];
|
||||||
public function testTrustedHosts($host, $server_name, $message, $expected = FALSE) {
|
|
||||||
$request = new Request();
|
|
||||||
|
|
||||||
$trusted_host_patterns = [
|
if (!empty($host)) {
|
||||||
'^example\.com$',
|
$request->headers->set('HOST', $host);
|
||||||
'^.+\.example\.com$',
|
|
||||||
'^example\.org',
|
|
||||||
'^.+\.example\.org',
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!empty($host)) {
|
|
||||||
$request->headers->set('HOST', $host);
|
|
||||||
}
|
|
||||||
|
|
||||||
$request->server->set('SERVER_NAME', $server_name);
|
|
||||||
|
|
||||||
$method = new \ReflectionMethod('Drupal\Core\DrupalKernel', 'setupTrustedHosts');
|
|
||||||
$method->setAccessible(TRUE);
|
|
||||||
$valid_host = $method->invoke(NULL, $request, $trusted_host_patterns);
|
|
||||||
|
|
||||||
$this->assertSame($expected, $valid_host, $message);
|
|
||||||
|
|
||||||
// Reset the trusted hosts because it is statically stored on the request.
|
|
||||||
$method->invoke(NULL, $request, []);
|
|
||||||
// Reset the request factory because it is statically stored on the request.
|
|
||||||
Request::setFactory(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
$request->server->set('SERVER_NAME', $server_name);
|
||||||
* Provides test data for testTrustedHosts().
|
|
||||||
*/
|
|
||||||
public function providerTestTrustedHosts() {
|
|
||||||
$data = [];
|
|
||||||
|
|
||||||
// Tests canonical URL.
|
$method = new \ReflectionMethod('Drupal\Core\DrupalKernel', 'setupTrustedHosts');
|
||||||
$data[] = [
|
$method->setAccessible(TRUE);
|
||||||
'www.example.com',
|
$valid_host = $method->invoke(NULL, $request, $trusted_host_patterns);
|
||||||
'www.example.com',
|
|
||||||
'canonical URL is trusted',
|
|
||||||
TRUE,
|
|
||||||
];
|
|
||||||
|
|
||||||
// Tests missing hostname for HTTP/1.0 compatibility where the Host
|
$this->assertSame($expected, $valid_host, $message);
|
||||||
// header is optional.
|
|
||||||
$data[] = [NULL, 'www.example.com', 'empty Host is valid', TRUE];
|
|
||||||
|
|
||||||
// Tests the additional patterns from the settings.
|
// Reset the trusted hosts because it is statically stored on the request.
|
||||||
$data[] = [
|
$method->invoke(NULL, $request, []);
|
||||||
'example.com',
|
// Reset the request factory because it is statically stored on the request.
|
||||||
'www.example.com',
|
Request::setFactory(NULL);
|
||||||
'host from settings is trusted',
|
}
|
||||||
TRUE,
|
|
||||||
];
|
|
||||||
$data[] = [
|
|
||||||
'subdomain.example.com',
|
|
||||||
'www.example.com',
|
|
||||||
'host from settings is trusted',
|
|
||||||
TRUE,
|
|
||||||
];
|
|
||||||
$data[] = [
|
|
||||||
'www.example.org',
|
|
||||||
'www.example.com',
|
|
||||||
'host from settings is trusted',
|
|
||||||
TRUE,
|
|
||||||
];
|
|
||||||
$data[] = [
|
|
||||||
'example.org',
|
|
||||||
'www.example.com',
|
|
||||||
'host from settings is trusted',
|
|
||||||
TRUE,
|
|
||||||
];
|
|
||||||
|
|
||||||
// Tests mismatch.
|
/**
|
||||||
$data[] = [
|
* Provides test data for testTrustedHosts().
|
||||||
'www.blackhat.com',
|
*/
|
||||||
'www.example.com',
|
public function providerTestTrustedHosts() {
|
||||||
'unspecified host is untrusted',
|
$data = [];
|
||||||
FALSE,
|
|
||||||
];
|
|
||||||
|
|
||||||
return $data;
|
// Tests canonical URL.
|
||||||
}
|
$data[] = [
|
||||||
|
'www.example.com',
|
||||||
|
'www.example.com',
|
||||||
|
'canonical URL is trusted',
|
||||||
|
TRUE,
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
// Tests missing hostname for HTTP/1.0 compatibility where the Host
|
||||||
* Tests site path finding.
|
// header is optional.
|
||||||
*
|
$data[] = [NULL, 'www.example.com', 'empty Host is valid', TRUE];
|
||||||
* This test is run in a separate process since it defines DRUPAL_ROOT. This
|
|
||||||
* stops any possible pollution of other tests.
|
// Tests the additional patterns from the settings.
|
||||||
*
|
$data[] = [
|
||||||
* @covers ::findSitePath
|
'example.com',
|
||||||
* @runInSeparateProcess
|
'www.example.com',
|
||||||
*/
|
'host from settings is trusted',
|
||||||
public function testFindSitePath() {
|
TRUE,
|
||||||
$vfs_root = vfsStream::setup('drupal_root');
|
];
|
||||||
$sites_php = <<<'EOD'
|
$data[] = [
|
||||||
|
'subdomain.example.com',
|
||||||
|
'www.example.com',
|
||||||
|
'host from settings is trusted',
|
||||||
|
TRUE,
|
||||||
|
];
|
||||||
|
$data[] = [
|
||||||
|
'www.example.org',
|
||||||
|
'www.example.com',
|
||||||
|
'host from settings is trusted',
|
||||||
|
TRUE,
|
||||||
|
];
|
||||||
|
$data[] = [
|
||||||
|
'example.org',
|
||||||
|
'www.example.com',
|
||||||
|
'host from settings is trusted',
|
||||||
|
TRUE,
|
||||||
|
];
|
||||||
|
|
||||||
|
// Tests mismatch.
|
||||||
|
$data[] = [
|
||||||
|
'www.blackhat.com',
|
||||||
|
'www.example.com',
|
||||||
|
'unspecified host is untrusted',
|
||||||
|
FALSE,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests site path finding.
|
||||||
|
*
|
||||||
|
* This test is run in a separate process since it defines DRUPAL_ROOT. This
|
||||||
|
* stops any possible pollution of other tests.
|
||||||
|
*
|
||||||
|
* @covers ::findSitePath
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testFindSitePath() {
|
||||||
|
$vfs_root = vfsStream::setup('drupal_root');
|
||||||
|
$sites_php = <<<'EOD'
|
||||||
<?php
|
<?php
|
||||||
$sites['8888.www.example.org'] = 'example';
|
$sites['8888.www.example.org'] = 'example';
|
||||||
EOD;
|
EOD;
|
||||||
|
|
||||||
// Create the expected directory structure.
|
// Create the expected directory structure.
|
||||||
vfsStream::create([
|
vfsStream::create([
|
||||||
'sites' => [
|
'sites' => [
|
||||||
'sites.php' => $sites_php,
|
'sites.php' => $sites_php,
|
||||||
'example' => [
|
'example' => [
|
||||||
'settings.php' => 'test',
|
'settings.php' => 'test',
|
||||||
],
|
|
||||||
],
|
],
|
||||||
]);
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$request->server->set('SERVER_NAME', 'www.example.org');
|
$request->server->set('SERVER_NAME', 'www.example.org');
|
||||||
$request->server->set('SERVER_PORT', '8888');
|
$request->server->set('SERVER_PORT', '8888');
|
||||||
$request->server->set('SCRIPT_NAME', '/index.php');
|
$request->server->set('SCRIPT_NAME', '/index.php');
|
||||||
$this->assertEquals('sites/example', DrupalKernel::findSitePath($request, TRUE, $vfs_root->url('drupal_root')));
|
$this->assertEquals('sites/example', DrupalKernel::findSitePath($request, TRUE, $vfs_root->url('drupal_root')));
|
||||||
$this->assertEquals('sites/example', DrupalKernel::findSitePath($request, FALSE, $vfs_root->url('drupal_root')));
|
$this->assertEquals('sites/example', DrupalKernel::findSitePath($request, FALSE, $vfs_root->url('drupal_root')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A fake autoloader for testing
|
||||||
|
*/
|
||||||
|
class FakeAutoloader {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers this instance as an autoloader.
|
||||||
|
*
|
||||||
|
* @param bool $prepend
|
||||||
|
* Whether to prepend the autoloader or not
|
||||||
|
*/
|
||||||
|
public function register($prepend = FALSE) {
|
||||||
|
spl_autoload_register([$this, 'loadClass'], TRUE, $prepend);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A fake autoloader for testing
|
* Unregisters this instance as an autoloader.
|
||||||
*/
|
*/
|
||||||
class FakeAutoloader {
|
public function unregister() {
|
||||||
|
spl_autoload_unregister([$this, 'loadClass']);
|
||||||
/**
|
|
||||||
* Registers this instance as an autoloader.
|
|
||||||
*
|
|
||||||
* @param bool $prepend
|
|
||||||
* Whether to prepend the autoloader or not
|
|
||||||
*/
|
|
||||||
public function register($prepend = FALSE) {
|
|
||||||
spl_autoload_register([$this, 'loadClass'], TRUE, $prepend);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregisters this instance as an autoloader.
|
|
||||||
*/
|
|
||||||
public function unregister() {
|
|
||||||
spl_autoload_unregister([$this, 'loadClass']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the given class or interface.
|
|
||||||
*
|
|
||||||
* @return null
|
|
||||||
* This class never loads.
|
|
||||||
*/
|
|
||||||
public function loadClass() {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds a file by class name while caching lookups to APC.
|
|
||||||
*
|
|
||||||
* @return null
|
|
||||||
* This class never finds.
|
|
||||||
*/
|
|
||||||
public function findFile() {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
if (!function_exists('drupal_valid_test_ua')) {
|
|
||||||
|
|
||||||
function drupal_valid_test_ua($new_prefix = NULL) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the given class or interface.
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
* This class never loads.
|
||||||
|
*/
|
||||||
|
public function loadClass() {
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a file by class name while caching lookups to APC.
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
* This class never finds.
|
||||||
|
*/
|
||||||
|
public function findFile() {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ if (PHP_SAPI !== 'cli') {
|
||||||
}
|
}
|
||||||
|
|
||||||
$autoloader = require_once 'autoload.php';
|
$autoloader = require_once 'autoload.php';
|
||||||
require_once 'core/includes/bootstrap.inc';
|
|
||||||
require_once 'core/includes/errors.inc';
|
require_once 'core/includes/errors.inc';
|
||||||
define('DRUPAL_TEST_IN_CHILD_SITE', FALSE);
|
define('DRUPAL_TEST_IN_CHILD_SITE', FALSE);
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,6 @@ class ExtensionSerializationTest extends UnitTestCase {
|
||||||
* @covers ::__wakeup
|
* @covers ::__wakeup
|
||||||
*/
|
*/
|
||||||
public function testServiceAppRouteUsage() {
|
public function testServiceAppRouteUsage() {
|
||||||
// The assumption of our test is that DRUPAL_ROOT is not defined.
|
|
||||||
$this->assertFalse(defined('DRUPAL_ROOT'), 'Constant DRUPAL_ROOT is defined.');
|
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
// Set a dummy container app.root to test against.
|
// Set a dummy container app.root to test against.
|
||||||
$container->setParameter('app.root', 'vfs://dummy_app_root');
|
$container->setParameter('app.root', 'vfs://dummy_app_root');
|
||||||
|
@ -56,6 +54,14 @@ class ExtensionSerializationTest extends UnitTestCase {
|
||||||
$reflected_root = new \ReflectionProperty($extension, 'root');
|
$reflected_root = new \ReflectionProperty($extension, 'root');
|
||||||
$reflected_root->setAccessible(TRUE);
|
$reflected_root->setAccessible(TRUE);
|
||||||
$this->assertEquals('vfs://dummy_app_root', $reflected_root->getValue($extension));
|
$this->assertEquals('vfs://dummy_app_root', $reflected_root->getValue($extension));
|
||||||
|
|
||||||
|
// Change the app root and test serializing and unserializing again.
|
||||||
|
$container->setParameter('app.root', 'vfs://dummy_app_root2');
|
||||||
|
\Drupal::setContainer($container);
|
||||||
|
$extension = unserialize(serialize($extension));
|
||||||
|
$reflected_root = new \ReflectionProperty($extension, 'root');
|
||||||
|
$reflected_root->setAccessible(TRUE);
|
||||||
|
$this->assertEquals('vfs://dummy_app_root2', $reflected_root->getValue($extension));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -111,13 +111,3 @@ class MachineNameTest extends UnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Drupal\Core\Render\Element;
|
|
||||||
|
|
||||||
if (!function_exists('t')) {
|
|
||||||
|
|
||||||
function t($string, array $args = []) {
|
|
||||||
return strtr($string, $args);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -77,9 +77,6 @@ trait TestRequirementsTrait {
|
||||||
* skipped. Callers should not catch this exception.
|
* skipped. Callers should not catch this exception.
|
||||||
*/
|
*/
|
||||||
private function checkModuleRequirements($root, array $annotations) {
|
private function checkModuleRequirements($root, array $annotations) {
|
||||||
// drupal_valid_ua() might not be loaded.
|
|
||||||
require_once $root . '/core/includes/bootstrap.inc';
|
|
||||||
|
|
||||||
// Make a list of required modules.
|
// Make a list of required modules.
|
||||||
$required_modules = [];
|
$required_modules = [];
|
||||||
foreach ($annotations as $requirement) {
|
foreach ($annotations as $requirement) {
|
||||||
|
|
|
@ -16,7 +16,6 @@ $autoloader = require_once 'autoload.php';
|
||||||
// Disable garbage collection during test runs. Under certain circumstances the
|
// Disable garbage collection during test runs. Under certain circumstances the
|
||||||
// update path will create so many objects that garbage collection causes
|
// update path will create so many objects that garbage collection causes
|
||||||
// segmentation faults.
|
// segmentation faults.
|
||||||
require_once 'core/includes/bootstrap.inc';
|
|
||||||
if (drupal_valid_test_ua()) {
|
if (drupal_valid_test_ua()) {
|
||||||
gc_collect_cycles();
|
gc_collect_cycles();
|
||||||
gc_disable();
|
gc_disable();
|
||||||
|
|
Loading…
Reference in New Issue