Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
587c514d
Commit
587c514d
authored
Jun 15, 2016
by
Alex Pott
Browse files
Issue
#2734423
by dawehner, jibran: Convert the remaining old kernel tests over
parent
da40012f
Changes
6
Hide whitespace changes
Inline
Side-by-side
core/modules/simpletest/src/TestBase.php
View file @
587c514d
...
...
@@ -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
{
...
...
core/modules/simpletest/src/Tests/MissingDependentModuleUnitTest.php
View file @
587c514d
...
...
@@ -2,7 +2,7 @@
namespace
Drupal\simpletest\Tests
;
use
Drupal\simpletest\
Kernel
TestBase
;
use
Drupal\simpletest\
Web
TestBase
;
/**
* 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
Kernel
TestBase
{
class
MissingDependentModuleUnitTest
extends
Web
TestBase
{
/**
* Ensure that this test will not be loaded despite its dependency.
...
...
core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php
View file @
587c514d
...
...
@@ -127,7 +127,7 @@ public function testTestingThroughUI() {
$tests
=
array
(
// A KernelTestBase test.
'Drupal\
system\Tests\DrupalKernel\DrupalKernel
Test'
,
'Drupal\
KernelTests\KernelTestBase
Test'
,
// A PHPUnit unit test.
'Drupal\Tests\action\Unit\Menu\ActionLocalTasksTest'
,
// A PHPUnit functional test.
...
...
core/modules/views/
src/Tests
/Plugin/PluginBaseTest.php
→
core/modules/views/
tests/src/Kernel
/Plugin/PluginBaseTest.php
View file @
587c514d
...
...
@@ -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\
simplet
est\KernelTestBase
;
use
Drupal\
KernelT
est
s
\KernelTestBase
;
use
Drupal\views\Plugin\views\PluginBase
;
/**
...
...
core/
modules/system/src/Tests
/DrupalKernel/DrupalKernelTest.php
→
core/
tests/Drupal/KernelTests/Core
/DrupalKernel/DrupalKernelTest.php
View file @
587c514d
<?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
->
setting
sSet
(
'container_yamls'
,
[]);
$this
->
setting
sSet
(
'hash_salt'
,
$this
->
databasePrefix
);
$this
->
set
Set
ting
(
'container_yamls'
,
[]);
$this
->
set
Set
ting
(
'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
->
setting
sSet
(
'container_yamls'
,
[]);
$this
->
setting
sSet
(
'hash_salt'
,
$this
->
databasePrefix
);
$this
->
set
Set
ting
(
'container_yamls'
,
[]);
$this
->
set
Set
ting
(
'hash_salt'
,
$this
->
databasePrefix
);
$kernel
->
boot
();
}
...
...
core/tests/Drupal/KernelTests/KernelTestBase.php
View file @
587c514d
...
...
@@ -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
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment