Commit 7fc47f35 authored by catch's avatar catch
Browse files

Issue #2324789 by tim.plunkett: Remove UnitTestBase.

parent 2d6516af
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
* *
* @ingroup testing * @ingroup testing
*/ */
abstract class KernelTestBase extends UnitTestBase { abstract class KernelTestBase extends TestBase {
use AssertContentTrait; use AssertContentTrait;
...@@ -47,8 +47,8 @@ abstract class KernelTestBase extends UnitTestBase { ...@@ -47,8 +47,8 @@ abstract class KernelTestBase extends UnitTestBase {
* this property. The values of all properties in all classes in the hierarchy * this property. The values of all properties in all classes in the hierarchy
* are merged. * are merged.
* *
* Unlike UnitTestBase::setUp(), any modules specified in the $modules * Any modules specified in the $modules property are automatically loaded and
* property are automatically loaded and set as the fixed module list. * set as the fixed module list.
* *
* Unlike WebTestBase::setUp(), the specified modules are loaded only, but not * Unlike WebTestBase::setUp(), the specified modules are loaded only, but not
* automatically installed. Modules need to be installed manually, if needed. * automatically installed. Modules need to be installed manually, if needed.
...@@ -143,8 +143,6 @@ protected function setUp() { ...@@ -143,8 +143,6 @@ protected function setUp() {
copy($settings_services_file, DRUPAL_ROOT . '/' . $this->siteDirectory . '/services.yml'); copy($settings_services_file, DRUPAL_ROOT . '/' . $this->siteDirectory . '/services.yml');
} }
parent::setUp();
// Create and set new configuration directories. // Create and set new configuration directories.
$this->prepareConfigDirectories(); $this->prepareConfigDirectories();
...@@ -212,9 +210,9 @@ protected function setUp() { ...@@ -212,9 +210,9 @@ protected function setUp() {
// StreamWrapper APIs. // StreamWrapper APIs.
// @todo Move StreamWrapper management into DrupalKernel. // @todo Move StreamWrapper management into DrupalKernel.
// @see https://drupal.org/node/2028109 // @see https://drupal.org/node/2028109
file_prepare_directory($this->public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
$this->settingsSet('file_public_path', $this->public_files_directory);
$this->streamWrappers = array(); $this->streamWrappers = array();
// The public stream wrapper only depends on the file_public_path setting,
// which is provided by UnitTestBase::setUp().
$this->registerStreamWrapper('public', 'Drupal\Core\StreamWrapper\PublicStream'); $this->registerStreamWrapper('public', 'Drupal\Core\StreamWrapper\PublicStream');
// The temporary stream wrapper is able to operate both with and without // The temporary stream wrapper is able to operate both with and without
// configuration. // configuration.
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* 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 either
* \Drupal\simpletest\WebTestBase or \Drupal\simpletest\UnitTestBase. * \Drupal\simpletest\WebTestBase or \Drupal\simpletest\KernelTestBase.
*/ */
abstract class TestBase { abstract class TestBase {
/** /**
...@@ -1058,7 +1058,6 @@ private function prepareEnvironment() { ...@@ -1058,7 +1058,6 @@ private function prepareEnvironment() {
// Unregister all custom stream wrappers of the parent site. // Unregister all custom stream wrappers of the parent site.
// Availability of Drupal stream wrappers varies by test base class: // Availability of Drupal stream wrappers varies by test base class:
// - UnitTestBase operates in a completely empty environment.
// - KernelTestBase supports and maintains stream wrappers in a custom // - KernelTestBase supports and maintains stream wrappers in a custom
// way. // way.
// - WebTestBase re-initializes Drupal stream wrappers after installation. // - WebTestBase re-initializes Drupal stream wrappers after installation.
......
<?php
/**
* @file
* Definition of Drupal\simpletest\UnitTestBase.
*/
namespace Drupal\simpletest;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\ConnectionNotDefinedException;
/**
* Base test case class for unit tests.
*
* These tests can not access the database nor files. Calling any Drupal
* function that needs the database will throw exceptions. These include
* watchdog(), \Drupal::moduleHandler()->getImplementations(),
* \Drupal::moduleHandler()->invokeAll() etc.
*/
abstract class UnitTestBase extends TestBase {
/**
* Constructor for UnitTestBase.
*/
function __construct($test_id = NULL) {
parent::__construct($test_id);
$this->skipClasses[__CLASS__] = TRUE;
}
/**
* Sets up unit test environment.
*
* Unlike \Drupal\simpletest\WebTestBase::setUp(), UnitTestBase::setUp() does
* not install modules because tests are performed without accessing the
* database. Any required files must be explicitly included by the child class
* setUp() method.
*/
protected function setUp() {
file_prepare_directory($this->public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
$this->settingsSet('file_public_path', $this->public_files_directory);
}
}
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