Issue #2734423 by dawehner, jibran: Convert the remaining old kernel tests over
parent
da40012f3b
commit
587c514da4
|
@ -20,8 +20,7 @@ use Drupal\Tests\SessionTestTrait;
|
||||||
/**
|
/**
|
||||||
* Base class for Drupal tests.
|
* Base class for Drupal tests.
|
||||||
*
|
*
|
||||||
* Do not extend this class directly; use either
|
* Do not extend this class directly; use \Drupal\simpletest\WebTestBase.
|
||||||
* \Drupal\simpletest\WebTestBase or \Drupal\simpletest\KernelTestBase.
|
|
||||||
*/
|
*/
|
||||||
abstract class TestBase {
|
abstract class TestBase {
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Drupal\simpletest\Tests;
|
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.
|
* This test should not load since it requires a module that is not found.
|
||||||
|
@ -10,7 +10,7 @@ use Drupal\simpletest\KernelTestBase;
|
||||||
* @group simpletest
|
* @group simpletest
|
||||||
* @dependencies simpletest_missing_module
|
* @dependencies simpletest_missing_module
|
||||||
*/
|
*/
|
||||||
class MissingDependentModuleUnitTest extends KernelTestBase {
|
class MissingDependentModuleUnitTest extends WebTestBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure that this test will not be loaded despite its dependency.
|
* Ensure that this test will not be loaded despite its dependency.
|
||||||
|
|
|
@ -127,7 +127,7 @@ class SimpleTestBrowserTest extends WebTestBase {
|
||||||
|
|
||||||
$tests = array(
|
$tests = array(
|
||||||
// A KernelTestBase test.
|
// A KernelTestBase test.
|
||||||
'Drupal\system\Tests\DrupalKernel\DrupalKernelTest',
|
'Drupal\KernelTests\KernelTestBaseTest',
|
||||||
// A PHPUnit unit test.
|
// A PHPUnit unit test.
|
||||||
'Drupal\Tests\action\Unit\Menu\ActionLocalTasksTest',
|
'Drupal\Tests\action\Unit\Menu\ActionLocalTasksTest',
|
||||||
// A PHPUnit functional test.
|
// A PHPUnit functional test.
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
* Contains \Drupal\views\Tests\Plugin\PluginBaseTest.
|
* 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\RenderContext;
|
||||||
use Drupal\Core\Render\Markup;
|
use Drupal\Core\Render\Markup;
|
||||||
use Drupal\simpletest\KernelTestBase;
|
use Drupal\KernelTests\KernelTestBase;
|
||||||
use Drupal\views\Plugin\views\PluginBase;
|
use Drupal\views\Plugin\views\PluginBase;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,10 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Drupal\system\Tests\DrupalKernel;
|
namespace Drupal\KernelTests\Core\DrupalKernel;
|
||||||
|
|
||||||
use Drupal\Core\DrupalKernel;
|
use Drupal\Core\DrupalKernel;
|
||||||
use Drupal\Core\Site\Settings;
|
use Drupal\KernelTests\KernelTestBase;
|
||||||
use Drupal\simpletest\KernelTestBase;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,29 +13,17 @@ use Symfony\Component\HttpFoundation\Request;
|
||||||
*/
|
*/
|
||||||
class DrupalKernelTest extends KernelTestBase {
|
class DrupalKernelTest extends KernelTestBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
// DrupalKernel relies on global $config_directories and requires those
|
// DrupalKernel relies on global $config_directories and requires those
|
||||||
// directories to exist. Therefore, create the directories, but do not
|
// directories to exist. Therefore, create the directories, but do not
|
||||||
// invoke KernelTestBase::setUp(), since that would set up further
|
// invoke KernelTestBase::setUp(), since that would set up further
|
||||||
// environment aspects, which would distort this test, because it tests
|
// environment aspects, which would distort this test, because it tests
|
||||||
// the DrupalKernel (re-)building itself.
|
// the DrupalKernel (re-)building itself.
|
||||||
$this->prepareConfigDirectories();
|
$this->root = static::getDrupalRoot();
|
||||||
|
$this->bootEnvironment();
|
||||||
$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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,10 +43,10 @@ class DrupalKernelTest extends KernelTestBase {
|
||||||
*/
|
*/
|
||||||
protected function getTestKernel(Request $request, array $modules_enabled = NULL) {
|
protected function getTestKernel(Request $request, array $modules_enabled = NULL) {
|
||||||
// Manually create kernel to avoid replacing settings.
|
// 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');
|
$kernel = DrupalKernel::createFromRequest($request, $class_loader, 'testing');
|
||||||
$this->settingsSet('container_yamls', []);
|
$this->setSetting('container_yamls', []);
|
||||||
$this->settingsSet('hash_salt', $this->databasePrefix);
|
$this->setSetting('hash_salt', $this->databasePrefix);
|
||||||
if (isset($modules_enabled)) {
|
if (isset($modules_enabled)) {
|
||||||
$kernel->updateModules($modules_enabled);
|
$kernel->updateModules($modules_enabled);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +145,7 @@ class DrupalKernelTest extends KernelTestBase {
|
||||||
*/
|
*/
|
||||||
public function testRepeatedBootWithDifferentEnvironment() {
|
public function testRepeatedBootWithDifferentEnvironment() {
|
||||||
$request = Request::createFromGlobals();
|
$request = Request::createFromGlobals();
|
||||||
$class_loader = require DRUPAL_ROOT . '/autoload.php';
|
$class_loader = require $this->root . '/autoload.php';
|
||||||
|
|
||||||
$environments = [
|
$environments = [
|
||||||
'testing1',
|
'testing1',
|
||||||
|
@ -169,8 +156,8 @@ class DrupalKernelTest extends KernelTestBase {
|
||||||
|
|
||||||
foreach ($environments as $environment) {
|
foreach ($environments as $environment) {
|
||||||
$kernel = DrupalKernel::createFromRequest($request, $class_loader, $environment);
|
$kernel = DrupalKernel::createFromRequest($request, $class_loader, $environment);
|
||||||
$this->settingsSet('container_yamls', []);
|
$this->setSetting('container_yamls', []);
|
||||||
$this->settingsSet('hash_salt', $this->databasePrefix);
|
$this->setSetting('hash_salt', $this->databasePrefix);
|
||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1191,7 +1191,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
|
||||||
'kernel',
|
'kernel',
|
||||||
// @see \Drupal\simpletest\TestBase::prepareEnvironment()
|
// @see \Drupal\simpletest\TestBase::prepareEnvironment()
|
||||||
'generatedTestFiles',
|
'generatedTestFiles',
|
||||||
// @see \Drupal\simpletest\KernelTestBase::containerBuild()
|
// Properties from the old KernelTestBase class that has been removed.
|
||||||
'keyValueFactory',
|
'keyValueFactory',
|
||||||
);
|
);
|
||||||
if (in_array($name, $denied) || strpos($name, 'original') === 0) {
|
if (in_array($name, $denied) || strpos($name, 'original') === 0) {
|
||||||
|
|
Loading…
Reference in New Issue