Commit 587c514d authored by alexpott's avatar alexpott

Issue #2734423 by dawehner, jibran: Convert the remaining old kernel tests over

parent da40012f
......@@ -20,8 +20,7 @@
/**
* Base class for Drupal tests.
*
* Do not extend this class directly; use either
* \Drupal\simpletest\WebTestBase or \Drupal\simpletest\KernelTestBase.
* Do not extend this class directly; use \Drupal\simpletest\WebTestBase.
*/
abstract class TestBase {
......
......@@ -2,7 +2,7 @@
namespace Drupal\simpletest\Tests;
use Drupal\simpletest\KernelTestBase;
use Drupal\simpletest\WebTestBase;
/**
* This test should not load since it requires a module that is not found.
......@@ -10,7 +10,7 @@
* @group simpletest
* @dependencies simpletest_missing_module
*/
class MissingDependentModuleUnitTest extends KernelTestBase {
class MissingDependentModuleUnitTest extends WebTestBase {
/**
* Ensure that this test will not be loaded despite its dependency.
......
......@@ -127,7 +127,7 @@ public function testTestingThroughUI() {
$tests = array(
// A KernelTestBase test.
'Drupal\system\Tests\DrupalKernel\DrupalKernelTest',
'Drupal\KernelTests\KernelTestBaseTest',
// A PHPUnit unit test.
'Drupal\Tests\action\Unit\Menu\ActionLocalTasksTest',
// A PHPUnit functional test.
......
......@@ -5,11 +5,11 @@
* Contains \Drupal\views\Tests\Plugin\PluginBaseTest.
*/
namespace Drupal\views\Tests\Plugin;
namespace Drupal\Tests\views\Kernel\Plugin;
use Drupal\Core\Render\RenderContext;
use Drupal\Core\Render\Markup;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
use Drupal\views\Plugin\views\PluginBase;
/**
......
<?php
namespace Drupal\system\Tests\DrupalKernel;
namespace Drupal\KernelTests\Core\DrupalKernel;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Site\Settings;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\HttpFoundation\Request;
/**
......@@ -14,29 +13,17 @@
*/
class DrupalKernelTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
// DrupalKernel relies on global $config_directories and requires those
// directories to exist. Therefore, create the directories, but do not
// invoke KernelTestBase::setUp(), since that would set up further
// environment aspects, which would distort this test, because it tests
// the DrupalKernel (re-)building itself.
$this->prepareConfigDirectories();
$this->settingsSet('php_storage', array('service_container' => array(
'bin' => 'service_container',
'class' => 'Drupal\Component\PhpStorage\MTimeProtectedFileStorage',
'directory' => DRUPAL_ROOT . '/' . $this->publicFilesDirectory . '/php',
'secret' => Settings::getHashSalt(),
)));
}
/**
* {@inheritdoc}
*/
protected function prepareConfigDirectories() {
\Drupal::setContainer($this->originalContainer);
parent::prepareConfigDirectories();
\Drupal::unsetContainer();
$this->root = static::getDrupalRoot();
$this->bootEnvironment();
}
/**
......@@ -56,10 +43,10 @@ protected function prepareConfigDirectories() {
*/
protected function getTestKernel(Request $request, array $modules_enabled = NULL) {
// Manually create kernel to avoid replacing settings.
$class_loader = require DRUPAL_ROOT . '/autoload.php';
$class_loader = require $this->root . '/autoload.php';
$kernel = DrupalKernel::createFromRequest($request, $class_loader, 'testing');
$this->settingsSet('container_yamls', []);
$this->settingsSet('hash_salt', $this->databasePrefix);
$this->setSetting('container_yamls', []);
$this->setSetting('hash_salt', $this->databasePrefix);
if (isset($modules_enabled)) {
$kernel->updateModules($modules_enabled);
}
......@@ -158,7 +145,7 @@ public function testCompileDIC() {
*/
public function testRepeatedBootWithDifferentEnvironment() {
$request = Request::createFromGlobals();
$class_loader = require DRUPAL_ROOT . '/autoload.php';
$class_loader = require $this->root . '/autoload.php';
$environments = [
'testing1',
......@@ -169,8 +156,8 @@ public function testRepeatedBootWithDifferentEnvironment() {
foreach ($environments as $environment) {
$kernel = DrupalKernel::createFromRequest($request, $class_loader, $environment);
$this->settingsSet('container_yamls', []);
$this->settingsSet('hash_salt', $this->databasePrefix);
$this->setSetting('container_yamls', []);
$this->setSetting('hash_salt', $this->databasePrefix);
$kernel->boot();
}
......
......@@ -1191,7 +1191,7 @@ public function __get($name) {
'kernel',
// @see \Drupal\simpletest\TestBase::prepareEnvironment()
'generatedTestFiles',
// @see \Drupal\simpletest\KernelTestBase::containerBuild()
// Properties from the old KernelTestBase class that has been removed.
'keyValueFactory',
);
if (in_array($name, $denied) || strpos($name, 'original') === 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment