Commit 20a08028 authored by catch's avatar catch
Browse files

Issue #2687897 by dawehner, jhedstrom, catch, jibran, Berdir, klausi: Convert...

Issue #2687897 by dawehner, jhedstrom, catch, jibran, Berdir, klausi: Convert system module's kernel tests to NG
parent 4012b7ed
......@@ -4,3 +4,5 @@ description: 'Provides the HTTP Basic authentication provider'
package: Web services
version: VERSION
core: 8.x
dependencies:
- user
......@@ -15,6 +15,9 @@
*
* @see DatabaseBackendUnitTestCase
* For a full working implementation.
*
* @deprecated as of Drupal 8.2.x, will be removed before Drupal 9.0.0. Use
* \Drupal\KernelTests\Core\Cache\GenericCacheBackendUnitTestBase instead.
*/
abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
......
......@@ -2,7 +2,7 @@
namespace Drupal\system\Tests\Common;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Test page rendering hooks.
......
......@@ -3,7 +3,7 @@
namespace Drupal\system\Tests\Common;
use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests scanning system directories in drupal_system_listing().
......
<?php
namespace Drupal\system\Tests\Action;
namespace Drupal\Tests\system\Kernel\Action;
use Drupal\simpletest\KernelTestBase;
use Drupal\Core\Action\ActionInterface;
use Drupal\KernelTests\KernelTestBase;
use Drupal\system\Entity\Action;
use Drupal\user\RoleInterface;
......@@ -12,7 +12,7 @@
*
* @group Action
*/
class ActionUnitTest extends KernelTestBase {
class ActionTest extends KernelTestBase {
/**
* {@inheritdoc}
......
<?php
namespace Drupal\system\Tests\Block;
namespace Drupal\Tests\system\Kernel\Block;
use Drupal\KernelTests\KernelTestBase;
use Drupal\system\Entity\Menu;
use Drupal\block\Entity\Block;
use Drupal\Core\Render\Element;
use Drupal\simpletest\KernelTestBase;
use Drupal\system\Tests\Routing\MockRouteProvider;
use Drupal\Tests\Core\Menu\MenuLinkMock;
use Drupal\user\Entity\User;
......
<?php
namespace Drupal\system\Tests\System;
namespace Drupal\Tests\system\Kernel\System;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests the effectiveness of hook_system_info_alter().
......
# Themes are not supposed to provide/install this kind of config normally.
# This exists for testing purposes only.
# @see \Drupal\system\Tests\Extension\ThemeInstallerTest
# @see \Drupal\KernelTests\Core\Theme\ThemeInstallerTest
id: fancy
label: 'Fancy date'
status: true
......
<?php
namespace Drupal\system\Tests\Common;
namespace Drupal\KernelTests\Core\Asset;
use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Asset\AttachedAssets;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests #attached assets: attached asset libraries and JavaScript settings.
......@@ -195,13 +195,16 @@ function testSettings() {
$js = $this->assetResolver->getJsAssets($assets, FALSE)[1];
$js_render_array = \Drupal::service('asset.js.collection_renderer')->render($js);
$rendered_js = $this->renderer->renderPlain($js_render_array);
// Cast to string since this returns a \Drupal\Core\Render\Markup object.
$rendered_js = (string) $this->renderer->renderPlain($js_render_array);
// Parse the generated drupalSettings <script> back to a PHP representation.
$startToken = '{';
$endToken = '}';
$start = strpos($rendered_js, $startToken);
$end = strrpos($rendered_js, $endToken);
// Convert to a string, as $renderer_js is a \Drupal\Core\Render\Markup
// object.
$json = Unicode::substr($rendered_js, $start, $end - $start + 1);
$parsed_settings = Json::decode($json);
......
<?php
namespace Drupal\system\Tests\Asset;
namespace Drupal\KernelTests\Core\Asset;
use Drupal\Core\Asset\Exception\InvalidLibrariesExtendSpecificationException;
use Drupal\Core\Asset\Exception\InvalidLibrariesOverrideSpecificationException;
......
<?php
namespace Drupal\system\Tests\Asset;
namespace Drupal\KernelTests\Core\Asset;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests that the asset files for all core libraries exist.
......@@ -83,17 +83,17 @@ class ResolvedLibraryDefinitionsFilesMatchTest extends KernelTestBase {
*/
protected $pathsChecked;
/**
* {@inheritdoc}
*/
public static $modules = ['system'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->themeHandler = $this->container->get('theme_handler');
$this->themeInitialization = $this->container->get('theme.initialization');
$this->themeManager = $this->container->get('theme.manager');
$this->libraryDiscovery = $this->container->get('library.discovery');
// Install all core themes.
sort($this->allThemes);
$this->container->get('theme_installer')->install($this->allThemes);
......@@ -109,8 +109,14 @@ protected function setUp() {
return TRUE;
});
$this->allModules = array_keys($all_modules);
$this->allModules[] = 'system';
sort($this->allModules);
$this->enableModules($this->allModules);
$this->container->get('module_installer')->install($this->allModules);
$this->themeHandler = $this->container->get('theme_handler');
$this->themeInitialization = $this->container->get('theme.initialization');
$this->themeManager = $this->container->get('theme.manager');
$this->libraryDiscovery = $this->container->get('library.discovery');
}
/**
......
<?php
namespace Drupal\system\Tests\Bootstrap;
namespace Drupal\KernelTests\Core\Bootstrap;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests that drupal_get_filename() works correctly.
*
* @group Bootstrap
*/
class GetFilenameUnitTest extends KernelTestBase {
class GetFilenameTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['system'];
/**
* Tests that drupal_get_filename() works when the file is not in database.
......
<?php
namespace Drupal\system\Tests\Bootstrap;
namespace Drupal\KernelTests\Core\Bootstrap;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests that drupal_static() and drupal_static_reset() work.
*
* @group Bootstrap
*/
class ResettableStaticUnitTest extends KernelTestBase {
class ResettableStaticTest extends KernelTestBase {
/**
* Tests drupal_static() function.
......
<?php
namespace Drupal\system\Tests\Cache;
namespace Drupal\KernelTests\Core\Cache;
use Drupal\Core\Cache\Apcu4Backend;
use Drupal\Core\Cache\ApcuBackend;
......@@ -11,7 +11,7 @@
* @group Cache
* @requires extension apc
*/
class ApcuBackendUnitTest extends GenericCacheBackendUnitTestBase {
class ApcuBackendTest extends GenericCacheBackendUnitTestBase {
/**
* Get a list of failed requirements.
......
<?php
namespace Drupal\system\Tests\Cache;
namespace Drupal\KernelTests\Core\Cache;
use Drupal\Core\Cache\BackendChain;
use Drupal\Core\Cache\MemoryBackend;
......@@ -10,7 +10,7 @@
*
* @group Cache
*/
class BackendChainUnitTest extends GenericCacheBackendUnitTestBase {
class BackendChainTest extends GenericCacheBackendUnitTestBase {
protected function createCacheBackend($bin) {
$chain = new BackendChain($bin);
......
<?php
namespace Drupal\system\Tests\Cache;
namespace Drupal\KernelTests\Core\Cache;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
use Drupal\simpletest\UserCreationTrait;
use Drupal\user\Entity\Role;
......
<?php
namespace Drupal\system\Tests\Cache;
namespace Drupal\KernelTests\Core\Cache;
use Drupal\Core\Cache\ChainedFastBackend;
use Drupal\Core\Cache\DatabaseBackend;
......@@ -11,7 +11,7 @@
*
* @group Cache
*/
class ChainedFastBackendUnitTest extends GenericCacheBackendUnitTestBase {
class ChainedFastBackendTest extends GenericCacheBackendUnitTestBase {
/**
* Creates a new instance of ChainedFastBackend.
......
<?php
namespace Drupal\system\Tests\Cache;
namespace Drupal\KernelTests\Core\Cache;
use Drupal\Core\Cache\Cache;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\DependencyInjection\Reference;
/**
......@@ -24,8 +24,8 @@ class DatabaseBackendTagTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public function containerBuild(ContainerBuilder $container) {
parent::containerBuild($container);
public function register(ContainerBuilder $container) {
parent::register($container);
// Change container to database cache backends.
$container
->register('cache_factory', 'Drupal\Core\Cache\CacheFactory')
......
<?php
namespace Drupal\system\Tests\Cache;
namespace Drupal\KernelTests\Core\Cache;
use Drupal\Core\Cache\DatabaseBackend;
......@@ -9,7 +9,7 @@
*
* @group Cache
*/
class DatabaseBackendUnitTest extends GenericCacheBackendUnitTestBase {
class DatabaseBackendTest extends GenericCacheBackendUnitTestBase {
/**
* Modules to enable.
......
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