upgrades core to 8.4.2
This commit is contained in:
@@ -10,6 +10,7 @@ source:
|
||||
- simpletest_httpauth_password
|
||||
- simpletest_httpauth_username
|
||||
- simpletest_verbose
|
||||
source_module: simpletest
|
||||
process:
|
||||
clear_results: simpletest_clear_results
|
||||
'httpauth/method': simpletest_httpauth_method
|
||||
|
||||
@@ -10,6 +10,7 @@ source:
|
||||
- simpletest_httpauth_password
|
||||
- simpletest_httpauth_username
|
||||
- simpletest_verbose
|
||||
source_module: simpletest
|
||||
process:
|
||||
clear_results: simpletest_clear_results
|
||||
'httpauth/method': simpletest_httpauth_method
|
||||
|
||||
@@ -6,8 +6,8 @@ package: Core
|
||||
# core: 8.x
|
||||
configure: simpletest.settings
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
use Drupal\Component\Utility\Environment;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Minimum value of PHP memory_limit for SimpleTest.
|
||||
@@ -18,7 +19,7 @@ const SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT = '128M';
|
||||
function simpletest_requirements($phase) {
|
||||
$requirements = [];
|
||||
|
||||
$has_phpunit = class_exists('\PHPUnit_Framework_TestCase');
|
||||
$has_phpunit = class_exists(TestCase::class);
|
||||
$has_curl = function_exists('curl_init');
|
||||
$open_basedir = ini_get('open_basedir');
|
||||
|
||||
|
||||
@@ -1,48 +1,29 @@
|
||||
/**
|
||||
* @file
|
||||
* Simpletest behaviors.
|
||||
*/
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Collapses table rows followed by group rows on the test listing page.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attach collapse behavior on the test listing page.
|
||||
*/
|
||||
Drupal.behaviors.simpleTestGroupCollapse = {
|
||||
attach: function (context) {
|
||||
attach: function attach(context) {
|
||||
$(context).find('.simpletest-group').once('simpletest-group-collapse').each(function () {
|
||||
var $group = $(this);
|
||||
var $image = $group.find('.simpletest-image');
|
||||
$image
|
||||
.html(drupalSettings.simpleTest.images[0])
|
||||
.on('click', function () {
|
||||
var $tests = $group.nextUntil('.simpletest-group');
|
||||
var expand = !$group.hasClass('expanded');
|
||||
$group.toggleClass('expanded', expand);
|
||||
$tests.toggleClass('js-hide', !expand);
|
||||
$image.html(drupalSettings.simpleTest.images[+expand]);
|
||||
});
|
||||
$image.html(drupalSettings.simpleTest.images[0]).on('click', function () {
|
||||
var $tests = $group.nextUntil('.simpletest-group');
|
||||
var expand = !$group.hasClass('expanded');
|
||||
$group.toggleClass('expanded', expand);
|
||||
$tests.toggleClass('js-hide', !expand);
|
||||
$image.html(drupalSettings.simpleTest.images[+expand]);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggles test checkboxes to match the group checkbox.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches behavior for selecting all tests in a group.
|
||||
*/
|
||||
Drupal.behaviors.simpleTestSelectAll = {
|
||||
attach: function (context) {
|
||||
attach: function attach(context) {
|
||||
$(context).find('.simpletest-group').once('simpletest-group-select-all').each(function () {
|
||||
var $group = $(this);
|
||||
var $cell = $group.find('.simpletest-group-select-all');
|
||||
@@ -50,13 +31,11 @@
|
||||
var $testCheckboxes = $group.nextUntil('.simpletest-group').find('input[type=checkbox]');
|
||||
$cell.append($groupCheckbox);
|
||||
|
||||
// Toggle the test checkboxes when the group checkbox is toggled.
|
||||
$groupCheckbox.on('change', function () {
|
||||
var checked = $(this).prop('checked');
|
||||
$testCheckboxes.prop('checked', checked);
|
||||
});
|
||||
|
||||
// Update the group checkbox when a test checkbox is toggled.
|
||||
function updateGroupCheckbox() {
|
||||
var allChecked = true;
|
||||
$testCheckboxes.each(function () {
|
||||
@@ -73,23 +52,11 @@
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Filters the test list table by a text input search string.
|
||||
*
|
||||
* Text search input: input.table-filter-text
|
||||
* Target table: input.table-filter-text[data-table]
|
||||
* Source text: .table-filter-text-source
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches the filter behavior to the text input element.
|
||||
*/
|
||||
Drupal.behaviors.simpletestTableFilterByText = {
|
||||
attach: function (context) {
|
||||
attach: function attach(context) {
|
||||
var $input = $('input.table-filter-text').once('table-filter-text');
|
||||
var $table = $($input.attr('data-table'));
|
||||
var $rows;
|
||||
var $rows = void 0;
|
||||
var searched = false;
|
||||
|
||||
function filterTestList(e) {
|
||||
@@ -102,22 +69,17 @@
|
||||
$row.closest('tr').toggle(textMatch);
|
||||
}
|
||||
|
||||
// Filter if the length of the query is at least 3 characters.
|
||||
if (query.length >= 3) {
|
||||
// Indicate that a search has been performed, and hide the
|
||||
// "select all" checkbox.
|
||||
searched = true;
|
||||
$('#simpletest-form-table thead th.select-all input').hide();
|
||||
|
||||
$rows.each(showTestRow);
|
||||
}
|
||||
// Restore to the original state if any searching has occurred.
|
||||
else if (searched) {
|
||||
searched = false;
|
||||
$('#simpletest-form-table thead th.select-all input').show();
|
||||
// Restore all rows to their original display state.
|
||||
$rows.css('display', '');
|
||||
}
|
||||
} else if (searched) {
|
||||
searched = false;
|
||||
$('#simpletest-form-table thead th.select-all input').show();
|
||||
|
||||
$rows.css('display', '');
|
||||
}
|
||||
}
|
||||
|
||||
if ($table.length) {
|
||||
@@ -126,5 +88,4 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
@@ -13,6 +13,7 @@ use Drupal\simpletest\TestBase;
|
||||
use Drupal\Core\Test\TestDatabase;
|
||||
use Drupal\simpletest\TestDiscovery;
|
||||
use Drupal\Tests\Listeners\SimpletestUiPrinter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Process\PhpExecutableFinder;
|
||||
use Drupal\Core\Test\TestStatus;
|
||||
|
||||
@@ -284,8 +285,15 @@ function simpletest_phpunit_xml_filepath($test_id) {
|
||||
*
|
||||
* @return string
|
||||
* The path to core's phpunit.xml.dist configuration file.
|
||||
*
|
||||
* @deprecated in Drupal 8.4.x for removal before Drupal 9.0.0. PHPUnit test
|
||||
* runners should change directory into core/ and then run the phpunit tool.
|
||||
* See simpletest_phpunit_run_command() for an example.
|
||||
*
|
||||
* @see simpletest_phpunit_run_command()
|
||||
*/
|
||||
function simpletest_phpunit_configuration_filepath() {
|
||||
@trigger_error('The ' . __FUNCTION__ . ' function is deprecated since version 8.4.x and will be removed in 9.0.0.', E_USER_DEPRECATED);
|
||||
return \Drupal::root() . '/core/phpunit.xml.dist';
|
||||
}
|
||||
|
||||
@@ -337,7 +345,7 @@ function simpletest_phpunit_run_command(array $unescaped_test_classnames, $phpun
|
||||
}
|
||||
else {
|
||||
// Double escape namespaces so they'll work in a regexp.
|
||||
$escaped_test_classnames = array_map(function($class) {
|
||||
$escaped_test_classnames = array_map(function ($class) {
|
||||
return addslashes($class);
|
||||
}, $unescaped_test_classnames);
|
||||
|
||||
@@ -355,7 +363,7 @@ function simpletest_phpunit_run_command(array $unescaped_test_classnames, $phpun
|
||||
|
||||
// exec in a subshell so that the environment is isolated when running tests
|
||||
// via the simpletest UI.
|
||||
$ret = exec(join($command, " "), $output, $status);
|
||||
$ret = exec(implode(" ", $command), $output, $status);
|
||||
|
||||
chdir($old_cwd);
|
||||
putenv('SIMPLETEST_DB=');
|
||||
@@ -412,7 +420,7 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) {
|
||||
|
||||
// Perform the next test.
|
||||
$test_class = array_shift($test_list);
|
||||
if (is_subclass_of($test_class, \PHPUnit_Framework_TestCase::class)) {
|
||||
if (is_subclass_of($test_class, TestCase::class)) {
|
||||
$phpunit_results = simpletest_run_phpunit_tests($test_id, [$test_class]);
|
||||
simpletest_process_phpunit_results($phpunit_results);
|
||||
$test_results[$test_class] = simpletest_summarize_phpunit_result($phpunit_results)[$test_class];
|
||||
@@ -437,20 +445,20 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) {
|
||||
'#theme' => 'simpletest_result_summary',
|
||||
'#label' => t($test_results[$class]['#name'] . ':'),
|
||||
];
|
||||
array_unshift($items, drupal_render($class_test_result));
|
||||
array_unshift($items, \Drupal::service('renderer')->render($class_test_result));
|
||||
}
|
||||
$context['message'] = t('Processed test @num of @max - %test.', ['%test' => $info['name'], '@num' => $max - $size, '@max' => $max]);
|
||||
$overall_results = $test_results + [
|
||||
'#theme' => 'simpletest_result_summary',
|
||||
'#label' => t('Overall results:'),
|
||||
];
|
||||
$context['message'] .= drupal_render($overall_results);
|
||||
$context['message'] .= \Drupal::service('renderer')->render($overall_results);
|
||||
|
||||
$item_list = [
|
||||
'#theme' => 'item_list',
|
||||
'#items' => $items,
|
||||
];
|
||||
$context['message'] .= drupal_render($item_list);
|
||||
$context['message'] .= \Drupal::service('renderer')->render($item_list);
|
||||
|
||||
// Save working values for the next iteration.
|
||||
$context['sandbox']['tests'] = $test_list;
|
||||
@@ -764,9 +772,10 @@ function simpletest_mail_alter(&$message) {
|
||||
* @param $phpunit_xml_file
|
||||
* Path to the PHPUnit XML file.
|
||||
*
|
||||
* @return array[]
|
||||
* @return array[]|null
|
||||
* The results as array of rows in a format that can be inserted into
|
||||
* {simpletest}.
|
||||
* {simpletest}. If the phpunit_xml_file does not have any contents then the
|
||||
* function will return NULL.
|
||||
*/
|
||||
function simpletest_phpunit_xml_to_rows($test_id, $phpunit_xml_file) {
|
||||
$contents = @file_get_contents($phpunit_xml_file);
|
||||
@@ -786,7 +795,7 @@ function simpletest_phpunit_xml_to_rows($test_id, $phpunit_xml_file) {
|
||||
*
|
||||
* @param \SimpleXMLElement $element
|
||||
* The PHPUnit xml to search for test cases.
|
||||
* @param \SimpleXMLElement $suite
|
||||
* @param \SimpleXMLElement $parent
|
||||
* (Optional) The parent of the current element. Defaults to NULL.
|
||||
*
|
||||
* @return array
|
||||
|
||||
@@ -874,7 +874,7 @@ trait AssertContentTrait {
|
||||
// The string cast is necessary because theme functions return
|
||||
// MarkupInterface objects. This means we can assert that $expected
|
||||
// matches the theme output without having to worry about 0 == ''.
|
||||
$output = (string) $renderer->executeInRenderContext(new RenderContext(), function() use ($callback, $variables) {
|
||||
$output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($callback, $variables) {
|
||||
return \Drupal::theme()->render($callback, $variables);
|
||||
});
|
||||
$this->verbose(
|
||||
|
||||
@@ -2,34 +2,18 @@
|
||||
|
||||
namespace Drupal\simpletest;
|
||||
|
||||
use Drupal\Component\Render\MarkupInterface;
|
||||
use Drupal\Tests\AssertHelperTrait as BaseAssertHelperTrait;
|
||||
|
||||
/**
|
||||
* Provides helper methods for assertions.
|
||||
*
|
||||
* @deprecated in Drupal 8.4.x. Will be removed before Drupal 9.0.0. Use
|
||||
* Drupal\Tests\AssertHelperTrait instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2884454
|
||||
*/
|
||||
trait AssertHelperTrait {
|
||||
|
||||
/**
|
||||
* Casts MarkupInterface objects into strings.
|
||||
*
|
||||
* @param string|array $value
|
||||
* The value to act on.
|
||||
*
|
||||
* @return mixed
|
||||
* The input value, with MarkupInterface objects casted to string.
|
||||
*/
|
||||
protected static function castSafeStrings($value) {
|
||||
if ($value instanceof MarkupInterface) {
|
||||
$value = (string) $value;
|
||||
}
|
||||
if (is_array($value)) {
|
||||
array_walk_recursive($value, function (&$item) {
|
||||
if ($item instanceof MarkupInterface) {
|
||||
$item = (string) $item;
|
||||
}
|
||||
});
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
use BaseAssertHelperTrait;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,66 +2,20 @@
|
||||
|
||||
namespace Drupal\simpletest;
|
||||
|
||||
use Drupal\block\Entity\Block;
|
||||
use Drupal\Tests\block\Traits\BlockCreationTrait as BaseBlockCreationTrait;
|
||||
|
||||
/**
|
||||
* Provides methods to create and place block with default settings.
|
||||
*
|
||||
* This trait is meant to be used only by test classes.
|
||||
*
|
||||
* @deprecated in Drupal 8.4.x. Will be removed before Drupal 9.0.0. Use
|
||||
* Drupal\Tests\AssertHelperTrait instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2884454
|
||||
*/
|
||||
trait BlockCreationTrait {
|
||||
|
||||
/**
|
||||
* Creates a block instance based on default settings.
|
||||
*
|
||||
* @param string $plugin_id
|
||||
* The plugin ID of the block type for this block instance.
|
||||
* @param array $settings
|
||||
* (optional) An associative array of settings for the block entity.
|
||||
* Override the defaults by specifying the key and value in the array, for
|
||||
* example:
|
||||
* @code
|
||||
* $this->drupalPlaceBlock('system_powered_by_block', array(
|
||||
* 'label' => t('Hello, world!'),
|
||||
* ));
|
||||
* @endcode
|
||||
* The following defaults are provided:
|
||||
* - label: Random string.
|
||||
* - ID: Random string.
|
||||
* - region: 'sidebar_first'.
|
||||
* - theme: The default theme.
|
||||
* - visibility: Empty array.
|
||||
*
|
||||
* @return \Drupal\block\Entity\Block
|
||||
* The block entity.
|
||||
*
|
||||
* @todo
|
||||
* Add support for creating custom block instances.
|
||||
*/
|
||||
protected function placeBlock($plugin_id, array $settings = []) {
|
||||
$config = \Drupal::configFactory();
|
||||
$settings += [
|
||||
'plugin' => $plugin_id,
|
||||
'region' => 'sidebar_first',
|
||||
'id' => strtolower($this->randomMachineName(8)),
|
||||
'theme' => $config->get('system.theme')->get('default'),
|
||||
'label' => $this->randomMachineName(8),
|
||||
'visibility' => [],
|
||||
'weight' => 0,
|
||||
];
|
||||
$values = [];
|
||||
foreach (['region', 'id', 'theme', 'plugin', 'weight', 'visibility'] as $key) {
|
||||
$values[$key] = $settings[$key];
|
||||
// Remove extra values that do not belong in the settings array.
|
||||
unset($settings[$key]);
|
||||
}
|
||||
foreach ($values['visibility'] as $id => $visibility) {
|
||||
$values['visibility'][$id]['id'] = $id;
|
||||
}
|
||||
$values['settings'] = $settings;
|
||||
$block = Block::create($values);
|
||||
$block->save();
|
||||
return $block;
|
||||
}
|
||||
use BaseBlockCreationTrait;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,52 +2,20 @@
|
||||
|
||||
namespace Drupal\simpletest;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\node\Traits\ContentTypeCreationTrait as BaseContentTypeCreationTrait;
|
||||
|
||||
/**
|
||||
* Provides methods to create content type from given values.
|
||||
*
|
||||
* This trait is meant to be used only by test classes.
|
||||
*
|
||||
* @deprecated in Drupal 8.4.x. Will be removed before Drupal 9.0.0. Use
|
||||
* Drupal\Tests\ContentTypeCreationTrait instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2884454
|
||||
*/
|
||||
trait ContentTypeCreationTrait {
|
||||
|
||||
/**
|
||||
* Creates a custom content type based on default settings.
|
||||
*
|
||||
* @param array $values
|
||||
* An array of settings to change from the defaults.
|
||||
* Example: 'type' => 'foo'.
|
||||
*
|
||||
* @return \Drupal\node\Entity\NodeType
|
||||
* Created content type.
|
||||
*/
|
||||
protected function createContentType(array $values = []) {
|
||||
// Find a non-existent random type name.
|
||||
if (!isset($values['type'])) {
|
||||
do {
|
||||
$id = strtolower($this->randomMachineName(8));
|
||||
} while (NodeType::load($id));
|
||||
}
|
||||
else {
|
||||
$id = $values['type'];
|
||||
}
|
||||
$values += [
|
||||
'type' => $id,
|
||||
'name' => $id,
|
||||
];
|
||||
$type = NodeType::create($values);
|
||||
$status = $type->save();
|
||||
node_add_body_field($type);
|
||||
|
||||
if ($this instanceof \PHPUnit_Framework_TestCase) {
|
||||
$this->assertSame($status, SAVED_NEW, (new FormattableMarkup('Created content type %type.', ['%type' => $type->id()]))->__toString());
|
||||
}
|
||||
else {
|
||||
$this->assertEqual($status, SAVED_NEW, (new FormattableMarkup('Created content type %type.', ['%type' => $type->id()]))->__toString());
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
use BaseContentTypeCreationTrait;
|
||||
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ class SimpletestResultsForm extends FormBase {
|
||||
*
|
||||
* @param array $form
|
||||
* The form to attach the results to.
|
||||
* @param array $test_results
|
||||
* @param array $results
|
||||
* The simpletest results.
|
||||
*
|
||||
* @return array
|
||||
|
||||
@@ -71,7 +71,7 @@ class SimpletestTestForm extends FormBase {
|
||||
$form['clean'] = [
|
||||
'#type' => 'fieldset',
|
||||
'#title' => $this->t('Clean test environment'),
|
||||
'#description' => $this->t('Remove tables with the prefix "simpletest" and temporary directories that are left over from tests that crashed. This is intended for developers when creating tests.'),
|
||||
'#description' => $this->t('Remove tables with the prefix "test" followed by digits and temporary directories that are left over from tests that crashed. This is intended for developers when creating tests.'),
|
||||
'#weight' => 200,
|
||||
];
|
||||
$form['clean']['op'] = [
|
||||
|
||||
@@ -20,22 +20,47 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Base class for integration tests.
|
||||
* Base class for functional integration tests.
|
||||
*
|
||||
* Tests extending this base class can access files and the database, but the
|
||||
* entire environment is initially empty. Drupal runs in a minimal mocked
|
||||
* environment, comparable to the one in the early installer.
|
||||
* This base class should be useful for testing some types of integrations which
|
||||
* don't require the overhead of a fully-installed Drupal instance, but which
|
||||
* have many dependencies on parts of Drupal which can't or shouldn't be mocked.
|
||||
*
|
||||
* The module/hook system is functional and operates on a fixed module list.
|
||||
* Additional modules needed in a test may be loaded and added to the fixed
|
||||
* module list.
|
||||
* This base class partially boots a fixture Drupal. The state of the fixture
|
||||
* Drupal is comparable to the state of a system during the early part of the
|
||||
* installation process.
|
||||
*
|
||||
* Tests extending this base class can access services and the database, but the
|
||||
* system is initially empty. This Drupal runs in a minimal mocked filesystem
|
||||
* which operates within vfsStream.
|
||||
*
|
||||
* Modules specified in the $modules property are added to the service container
|
||||
* for each test. The module/hook system is functional. Additional modules
|
||||
* needed in a test should override $modules. Modules specified in this way will
|
||||
* be added to those specified in superclasses.
|
||||
*
|
||||
* Unlike \Drupal\Tests\BrowserTestBase, the modules are not installed. They are
|
||||
* loaded such that their services and hooks are available, but the install
|
||||
* process has not been performed.
|
||||
*
|
||||
* Other modules can be made available in this way using
|
||||
* KernelTestBase::enableModules().
|
||||
*
|
||||
* Some modules can be brought into a fully-installed state using
|
||||
* KernelTestBase::installConfig(), KernelTestBase::installSchema(), and
|
||||
* KernelTestBase::installEntitySchema(). Alternately, tests which need modules
|
||||
* to be fully installed could inherit from \Drupal\Tests\BrowserTestBase.
|
||||
*
|
||||
* @see \Drupal\Tests\KernelTestBase::$modules
|
||||
* @see \Drupal\Tests\KernelTestBase::enableModules()
|
||||
* @see \Drupal\Tests\KernelTestBase::installConfig()
|
||||
* @see \Drupal\Tests\KernelTestBase::installEntitySchema()
|
||||
* @see \Drupal\Tests\KernelTestBase::installSchema()
|
||||
* @see \Drupal\Tests\BrowserTestBase
|
||||
*
|
||||
* @deprecated in Drupal 8.0.x, will be removed before Drupal 9.0.0. Use
|
||||
* \Drupal\KernelTests\KernelTestBase instead.
|
||||
*
|
||||
* @see \Drupal\simpletest\KernelTestBase::$modules
|
||||
* @see \Drupal\simpletest\KernelTestBase::enableModules()
|
||||
*
|
||||
* @ingroup testing
|
||||
*/
|
||||
abstract class KernelTestBase extends TestBase {
|
||||
@@ -121,7 +146,7 @@ abstract class KernelTestBase extends TestBase {
|
||||
$path = $this->siteDirectory . '/config_' . CONFIG_SYNC_DIRECTORY;
|
||||
$GLOBALS['config_directories'][CONFIG_SYNC_DIRECTORY] = $path;
|
||||
// Ensure the directory can be created and is writeable.
|
||||
if (!install_ensure_config_directory(CONFIG_SYNC_DIRECTORY)) {
|
||||
if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
|
||||
throw new \RuntimeException("Failed to create '" . CONFIG_SYNC_DIRECTORY . "' config directory $path");
|
||||
}
|
||||
// Provide the already resolved path for tests.
|
||||
@@ -454,7 +479,6 @@ EOD;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Installs the storage schema for a specific entity type.
|
||||
*
|
||||
|
||||
@@ -2,83 +2,20 @@
|
||||
|
||||
namespace Drupal\simpletest;
|
||||
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\Tests\node\Traits\NodeCreationTrait as BaseNodeCreationTrait;
|
||||
|
||||
/**
|
||||
* Provides methods to create node based on default settings.
|
||||
*
|
||||
* This trait is meant to be used only by test classes.
|
||||
*
|
||||
* @deprecated in Drupal 8.4.x. Will be removed before Drupal 9.0.0. Use
|
||||
* Drupal\Tests\NodeCreationTrait instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2884454
|
||||
*/
|
||||
trait NodeCreationTrait {
|
||||
|
||||
/**
|
||||
* Get a node from the database based on its title.
|
||||
*
|
||||
* @param string|\Drupal\Component\Render\MarkupInterface $title
|
||||
* A node title, usually generated by $this->randomMachineName().
|
||||
* @param $reset
|
||||
* (optional) Whether to reset the entity cache.
|
||||
*
|
||||
* @return \Drupal\node\NodeInterface
|
||||
* A node entity matching $title.
|
||||
*/
|
||||
public function getNodeByTitle($title, $reset = FALSE) {
|
||||
if ($reset) {
|
||||
\Drupal::entityTypeManager()->getStorage('node')->resetCache();
|
||||
}
|
||||
// Cast MarkupInterface objects to string.
|
||||
$title = (string) $title;
|
||||
$nodes = \Drupal::entityTypeManager()
|
||||
->getStorage('node')
|
||||
->loadByProperties(['title' => $title]);
|
||||
// Load the first node returned from the database.
|
||||
$returned_node = reset($nodes);
|
||||
return $returned_node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a node based on default settings.
|
||||
*
|
||||
* @param array $settings
|
||||
* (optional) An associative array of settings for the node, as used in
|
||||
* entity_create(). Override the defaults by specifying the key and value
|
||||
* in the array, for example:
|
||||
* @code
|
||||
* $this->drupalCreateNode(array(
|
||||
* 'title' => t('Hello, world!'),
|
||||
* 'type' => 'article',
|
||||
* ));
|
||||
* @endcode
|
||||
* The following defaults are provided:
|
||||
* - body: Random string using the default filter format:
|
||||
* @code
|
||||
* $settings['body'][0] = array(
|
||||
* 'value' => $this->randomMachineName(32),
|
||||
* 'format' => filter_default_format(),
|
||||
* );
|
||||
* @endcode
|
||||
* - title: Random string.
|
||||
* - type: 'page'.
|
||||
* - uid: The currently logged in user, or anonymous.
|
||||
*
|
||||
* @return \Drupal\node\NodeInterface
|
||||
* The created node entity.
|
||||
*/
|
||||
protected function createNode(array $settings = []) {
|
||||
// Populate defaults array.
|
||||
$settings += [
|
||||
'body' => [[
|
||||
'value' => $this->randomMachineName(32),
|
||||
'format' => filter_default_format(),
|
||||
]],
|
||||
'title' => $this->randomMachineName(8),
|
||||
'type' => 'page',
|
||||
'uid' => \Drupal::currentUser()->id(),
|
||||
];
|
||||
$node = Node::create($settings);
|
||||
$node->save();
|
||||
|
||||
return $node;
|
||||
}
|
||||
use BaseNodeCreationTrait;
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ use Drupal\Core\StreamWrapper\PublicStream;
|
||||
use Drupal\Core\Test\TestDatabase;
|
||||
use Drupal\Core\Test\TestSetupTrait;
|
||||
use Drupal\Core\Utility\Error;
|
||||
use Drupal\Tests\AssertHelperTrait as BaseAssertHelperTrait;
|
||||
use Drupal\Tests\ConfigTestTrait;
|
||||
use Drupal\Tests\RandomGeneratorTrait;
|
||||
use Drupal\Tests\SessionTestTrait;
|
||||
@@ -24,10 +25,10 @@ use Drupal\Tests\Traits\Core\GeneratePermutationsTrait;
|
||||
*/
|
||||
abstract class TestBase {
|
||||
|
||||
use BaseAssertHelperTrait;
|
||||
use TestSetupTrait;
|
||||
use SessionTestTrait;
|
||||
use RandomGeneratorTrait;
|
||||
use AssertHelperTrait;
|
||||
use GeneratePermutationsTrait;
|
||||
// For backwards compatibility switch the visbility of the methods to public.
|
||||
use ConfigTestTrait {
|
||||
|
||||
@@ -144,8 +144,8 @@ class TestDiscovery {
|
||||
* An array of tests keyed by the the group name.
|
||||
* @code
|
||||
* $groups['block'] => array(
|
||||
* 'Drupal\block\Tests\BlockTest' => array(
|
||||
* 'name' => 'Drupal\block\Tests\BlockTest',
|
||||
* 'Drupal\Tests\block\Functional\BlockTest' => array(
|
||||
* 'name' => 'Drupal\Tests\block\Functional\BlockTest',
|
||||
* 'description' => 'Tests block UI CRUD functionality.',
|
||||
* 'group' => 'block',
|
||||
* ),
|
||||
@@ -189,14 +189,17 @@ class TestDiscovery {
|
||||
// abstract class, trait or test fixture.
|
||||
continue;
|
||||
}
|
||||
// Skip this test class if it requires unavailable modules.
|
||||
// @todo PHPUnit skips tests with unmet requirements when executing a test
|
||||
// (instead of excluding them upfront). Refactor test runner to follow
|
||||
// that approach.
|
||||
// Skip this test class if it is a Simpletest-based test and requires
|
||||
// unavailable modules. TestDiscovery should not filter out module
|
||||
// requirements for PHPUnit-based test classes.
|
||||
// @todo Move this behavior to \Drupal\simpletest\TestBase so tests can be
|
||||
// marked as skipped, instead.
|
||||
// @see https://www.drupal.org/node/1273478
|
||||
if (!empty($info['requires']['module'])) {
|
||||
if (array_diff($info['requires']['module'], $this->availableExtensions['module'])) {
|
||||
continue;
|
||||
if ($info['type'] == 'Simpletest') {
|
||||
if (!empty($info['requires']['module'])) {
|
||||
if (array_diff($info['requires']['module'], $this->availableExtensions['module'])) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,7 +312,7 @@ class TestDiscovery {
|
||||
/**
|
||||
* Retrieves information about a test class for UI purposes.
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $classname
|
||||
* The test classname.
|
||||
* @param string $doc_comment
|
||||
* (optional) The class PHPDoc comment. If not passed in reflection will be
|
||||
|
||||
@@ -41,7 +41,10 @@ class TestServiceProvider implements ServiceProviderInterface, ServiceModifierIn
|
||||
foreach (['router.route_provider' => 'RouteProvider'] as $original_id => $class) {
|
||||
// While $container->get() does a recursive resolve, getDefinition() does
|
||||
// not, so do it ourselves.
|
||||
for ($id = $original_id; $container->hasAlias($id); $id = (string) $container->getAlias($id));
|
||||
// @todo Make the code more readable in
|
||||
// https://www.drupal.org/node/2911498.
|
||||
for ($id = $original_id; $container->hasAlias($id); $id = (string) $container->getAlias($id)) {
|
||||
}
|
||||
$definition = $container->getDefinition($id);
|
||||
$definition->clearTag('needs_destruction');
|
||||
$container->setDefinition("simpletest.$original_id", $definition);
|
||||
|
||||
@@ -87,7 +87,7 @@ class SimpleTestBrowserTest extends WebTestBase {
|
||||
$this->drupalLogout();
|
||||
|
||||
$system_path = $base_url . '/' . drupal_get_path('module', 'system');
|
||||
$HTTP_path = $system_path . '/tests/http.php/user/login';
|
||||
$http_path = $system_path . '/tests/http.php/user/login';
|
||||
$https_path = $system_path . '/tests/https.php/user/login';
|
||||
// Generate a valid simpletest User-Agent to pass validation.
|
||||
$this->assertTrue(preg_match('/test\d+/', $this->databasePrefix, $matches), 'Database prefix contains test prefix.');
|
||||
@@ -95,14 +95,14 @@ class SimpleTestBrowserTest extends WebTestBase {
|
||||
$this->additionalCurlOptions = [CURLOPT_USERAGENT => $test_ua];
|
||||
|
||||
// Test pages only available for testing.
|
||||
$this->drupalGet($HTTP_path);
|
||||
$this->drupalGet($http_path);
|
||||
$this->assertResponse(200, 'Requesting http.php with a legitimate simpletest User-Agent returns OK.');
|
||||
$this->drupalGet($https_path);
|
||||
$this->assertResponse(200, 'Requesting https.php with a legitimate simpletest User-Agent returns OK.');
|
||||
|
||||
// Now slightly modify the HMAC on the header, which should not validate.
|
||||
$this->additionalCurlOptions = [CURLOPT_USERAGENT => $test_ua . 'X'];
|
||||
$this->drupalGet($HTTP_path);
|
||||
$this->drupalGet($http_path);
|
||||
$this->assertResponse(403, 'Requesting http.php with a bad simpletest User-Agent fails.');
|
||||
$this->drupalGet($https_path);
|
||||
$this->assertResponse(403, 'Requesting https.php with a bad simpletest User-Agent fails.');
|
||||
@@ -110,7 +110,7 @@ class SimpleTestBrowserTest extends WebTestBase {
|
||||
// Use a real User-Agent and verify that the special files http.php and
|
||||
// https.php can't be accessed.
|
||||
$this->additionalCurlOptions = [CURLOPT_USERAGENT => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12'];
|
||||
$this->drupalGet($HTTP_path);
|
||||
$this->drupalGet($http_path);
|
||||
$this->assertResponse(403, 'Requesting http.php with a normal User-Agent fails.');
|
||||
$this->drupalGet($https_path);
|
||||
$this->assertResponse(403, 'Requesting https.php with a normal User-Agent fails.');
|
||||
|
||||
@@ -175,7 +175,7 @@ EOD;
|
||||
// along by the rethrow.
|
||||
assert(FALSE, 'Lorem Ipsum');
|
||||
}
|
||||
catch ( \AssertionError $e ) {
|
||||
catch (\AssertionError $e) {
|
||||
$this->assertEqual($e->getMessage(), 'Lorem Ipsum', 'Runtime assertions Enabled and running.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ class UiPhpUnitOutputTest extends WebTestBase {
|
||||
|
||||
// Check that there are <br> tags for the HTML output by
|
||||
// SimpletestUiPrinter.
|
||||
$this->assertEqual($output[18], 'HTML output was generated<br />');
|
||||
$this->assertEqual($output[19], 'HTML output was generated<br />');
|
||||
// Check that URLs are printed as HTML links.
|
||||
$this->assertIdentical(strpos($output[19], '<a href="http'), 0);
|
||||
$this->assertIdentical(strpos($output[20], '<a href="http'), 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
|
||||
namespace Drupal\simpletest;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\user\Entity\Role;
|
||||
use Drupal\user\Entity\User;
|
||||
use Drupal\user\RoleInterface;
|
||||
use Drupal\Tests\user\Traits\UserCreationTrait as BaseUserCreationTrait;
|
||||
|
||||
/**
|
||||
* Provides methods to create additional test users and switch the currently
|
||||
@@ -14,201 +10,14 @@ use Drupal\user\RoleInterface;
|
||||
*
|
||||
* This trait is meant to be used only by test classes extending
|
||||
* \Drupal\simpletest\TestBase.
|
||||
*
|
||||
* @deprecated in Drupal 8.4.x. Will be removed before Drupal 9.0.0. Use
|
||||
* Drupal\Tests\UserCreationTrait instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2884454
|
||||
*/
|
||||
trait UserCreationTrait {
|
||||
|
||||
/**
|
||||
* Switch the current logged in user.
|
||||
*
|
||||
* @param \Drupal\Core\Session\AccountInterface $account
|
||||
* The user account object.
|
||||
*/
|
||||
protected function setCurrentUser(AccountInterface $account) {
|
||||
\Drupal::currentUser()->setAccount($account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a user with a given set of permissions.
|
||||
*
|
||||
* @param array $permissions
|
||||
* Array of permission names to assign to user. Note that the user always
|
||||
* has the default permissions derived from the "authenticated users" role.
|
||||
* @param string $name
|
||||
* The user name.
|
||||
* @param bool $admin
|
||||
* (optional) Whether the user should be an administrator
|
||||
* with all the available permissions.
|
||||
*
|
||||
* @return \Drupal\user\Entity\User|false
|
||||
* A fully loaded user object with pass_raw property, or FALSE if account
|
||||
* creation fails.
|
||||
*/
|
||||
protected function createUser(array $permissions = [], $name = NULL, $admin = FALSE) {
|
||||
// Create a role with the given permission set, if any.
|
||||
$rid = FALSE;
|
||||
if ($permissions) {
|
||||
$rid = $this->createRole($permissions);
|
||||
if (!$rid) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a user assigned to that role.
|
||||
$edit = [];
|
||||
$edit['name'] = !empty($name) ? $name : $this->randomMachineName();
|
||||
$edit['mail'] = $edit['name'] . '@example.com';
|
||||
$edit['pass'] = user_password();
|
||||
$edit['status'] = 1;
|
||||
if ($rid) {
|
||||
$edit['roles'] = [$rid];
|
||||
}
|
||||
|
||||
if ($admin) {
|
||||
$edit['roles'][] = $this->createAdminRole();
|
||||
}
|
||||
|
||||
$account = User::create($edit);
|
||||
$account->save();
|
||||
|
||||
$this->assertTrue($account->id(), SafeMarkup::format('User created with name %name and pass %pass', ['%name' => $edit['name'], '%pass' => $edit['pass']]), 'User login');
|
||||
if (!$account->id()) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Add the raw password so that we can log in as this user.
|
||||
$account->pass_raw = $edit['pass'];
|
||||
// Support BrowserTestBase as well.
|
||||
$account->passRaw = $account->pass_raw;
|
||||
return $account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an administrative role.
|
||||
*
|
||||
* @param string $rid
|
||||
* (optional) The role ID (machine name). Defaults to a random name.
|
||||
* @param string $name
|
||||
* (optional) The label for the role. Defaults to a random string.
|
||||
* @param int $weight
|
||||
* (optional) The weight for the role. Defaults NULL so that entity_create()
|
||||
* sets the weight to maximum + 1.
|
||||
*
|
||||
* @return string
|
||||
* Role ID of newly created role, or FALSE if role creation failed.
|
||||
*/
|
||||
protected function createAdminRole($rid = NULL, $name = NULL, $weight = NULL) {
|
||||
$rid = $this->createRole([], $rid, $name, $weight);
|
||||
if ($rid) {
|
||||
/** @var \Drupal\user\RoleInterface $role */
|
||||
$role = Role::load($rid);
|
||||
$role->setIsAdmin(TRUE);
|
||||
$role->save();
|
||||
}
|
||||
return $rid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a role with specified permissions.
|
||||
*
|
||||
* @param array $permissions
|
||||
* Array of permission names to assign to role.
|
||||
* @param string $rid
|
||||
* (optional) The role ID (machine name). Defaults to a random name.
|
||||
* @param string $name
|
||||
* (optional) The label for the role. Defaults to a random string.
|
||||
* @param int $weight
|
||||
* (optional) The weight for the role. Defaults NULL so that entity_create()
|
||||
* sets the weight to maximum + 1.
|
||||
*
|
||||
* @return string
|
||||
* Role ID of newly created role, or FALSE if role creation failed.
|
||||
*/
|
||||
protected function createRole(array $permissions, $rid = NULL, $name = NULL, $weight = NULL) {
|
||||
// Generate a random, lowercase machine name if none was passed.
|
||||
if (!isset($rid)) {
|
||||
$rid = strtolower($this->randomMachineName(8));
|
||||
}
|
||||
// Generate a random label.
|
||||
if (!isset($name)) {
|
||||
// In the role UI role names are trimmed and random string can start or
|
||||
// end with a space.
|
||||
$name = trim($this->randomString(8));
|
||||
}
|
||||
|
||||
// Check the all the permissions strings are valid.
|
||||
if (!$this->checkPermissions($permissions)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Create new role.
|
||||
$role = Role::create([
|
||||
'id' => $rid,
|
||||
'label' => $name,
|
||||
]);
|
||||
if (isset($weight)) {
|
||||
$role->set('weight', $weight);
|
||||
}
|
||||
$result = $role->save();
|
||||
|
||||
$this->assertIdentical($result, SAVED_NEW, SafeMarkup::format('Created role ID @rid with name @name.', [
|
||||
'@name' => var_export($role->label(), TRUE),
|
||||
'@rid' => var_export($role->id(), TRUE),
|
||||
]), 'Role');
|
||||
|
||||
if ($result === SAVED_NEW) {
|
||||
// Grant the specified permissions to the role, if any.
|
||||
if (!empty($permissions)) {
|
||||
$this->grantPermissions($role, $permissions);
|
||||
$assigned_permissions = Role::load($role->id())->getPermissions();
|
||||
$missing_permissions = array_diff($permissions, $assigned_permissions);
|
||||
if (!$missing_permissions) {
|
||||
$this->pass(SafeMarkup::format('Created permissions: @perms', ['@perms' => implode(', ', $permissions)]), 'Role');
|
||||
}
|
||||
else {
|
||||
$this->fail(SafeMarkup::format('Failed to create permissions: @perms', ['@perms' => implode(', ', $missing_permissions)]), 'Role');
|
||||
}
|
||||
}
|
||||
return $role->id();
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given list of permission names is valid.
|
||||
*
|
||||
* @param array $permissions
|
||||
* The permission names to check.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the permissions are valid, FALSE otherwise.
|
||||
*/
|
||||
protected function checkPermissions(array $permissions) {
|
||||
$available = array_keys(\Drupal::service('user.permissions')->getPermissions());
|
||||
$valid = TRUE;
|
||||
foreach ($permissions as $permission) {
|
||||
if (!in_array($permission, $available)) {
|
||||
$this->fail(SafeMarkup::format('Invalid permission %permission.', ['%permission' => $permission]), 'Role');
|
||||
$valid = FALSE;
|
||||
}
|
||||
}
|
||||
return $valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grant permissions to a user role.
|
||||
*
|
||||
* @param \Drupal\user\RoleInterface $role
|
||||
* The ID of a user role to alter.
|
||||
* @param array $permissions
|
||||
* (optional) A list of permission names to grant.
|
||||
*/
|
||||
protected function grantPermissions(RoleInterface $role, array $permissions) {
|
||||
foreach ($permissions as $permission) {
|
||||
$role->grantPermission($permission);
|
||||
}
|
||||
$role->trustData()->save();
|
||||
}
|
||||
use BaseUserCreationTrait;
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\EventSubscriber\AjaxResponseSubscriber;
|
||||
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
@@ -18,8 +17,12 @@ use Drupal\Core\Test\FunctionalTestSetupTrait;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
use Drupal\Tests\EntityViewTrait;
|
||||
use Drupal\Tests\block\Traits\BlockCreationTrait as BaseBlockCreationTrait;
|
||||
use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
|
||||
use Drupal\Tests\node\Traits\NodeCreationTrait;
|
||||
use Drupal\Tests\Traits\Core\CronRunTrait;
|
||||
use Drupal\Tests\TestFileCreationTrait;
|
||||
use Drupal\Tests\user\Traits\UserCreationTrait;
|
||||
use Drupal\Tests\XdebugRequestTrait;
|
||||
use Zend\Diactoros\Uri;
|
||||
|
||||
@@ -37,7 +40,7 @@ abstract class WebTestBase extends TestBase {
|
||||
compareFiles as drupalCompareFiles;
|
||||
}
|
||||
use AssertPageCacheContextsAndTagsTrait;
|
||||
use BlockCreationTrait {
|
||||
use BaseBlockCreationTrait {
|
||||
placeBlock as drupalPlaceBlock;
|
||||
}
|
||||
use ContentTypeCreationTrait {
|
||||
@@ -389,69 +392,6 @@ abstract class WebTestBase extends TestBase {
|
||||
$this->rebuildAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parameters that will be used when Simpletest installs Drupal.
|
||||
*
|
||||
* @see install_drupal()
|
||||
* @see install_state_defaults()
|
||||
*
|
||||
* @return array
|
||||
* Array of parameters for use in install_drupal().
|
||||
*/
|
||||
protected function installParameters() {
|
||||
$connection_info = Database::getConnectionInfo();
|
||||
$driver = $connection_info['default']['driver'];
|
||||
$connection_info['default']['prefix'] = $connection_info['default']['prefix']['default'];
|
||||
unset($connection_info['default']['driver']);
|
||||
unset($connection_info['default']['namespace']);
|
||||
unset($connection_info['default']['pdo']);
|
||||
unset($connection_info['default']['init_commands']);
|
||||
// Remove database connection info that is not used by SQLite.
|
||||
if ($driver == 'sqlite') {
|
||||
unset($connection_info['default']['username']);
|
||||
unset($connection_info['default']['password']);
|
||||
unset($connection_info['default']['host']);
|
||||
unset($connection_info['default']['port']);
|
||||
}
|
||||
$parameters = [
|
||||
'interactive' => FALSE,
|
||||
'parameters' => [
|
||||
'profile' => $this->profile,
|
||||
'langcode' => 'en',
|
||||
],
|
||||
'forms' => [
|
||||
'install_settings_form' => [
|
||||
'driver' => $driver,
|
||||
$driver => $connection_info['default'],
|
||||
],
|
||||
'install_configure_form' => [
|
||||
'site_name' => 'Drupal',
|
||||
'site_mail' => 'simpletest@example.com',
|
||||
'account' => [
|
||||
'name' => $this->rootUser->name,
|
||||
'mail' => $this->rootUser->getEmail(),
|
||||
'pass' => [
|
||||
'pass1' => $this->rootUser->pass_raw,
|
||||
'pass2' => $this->rootUser->pass_raw,
|
||||
],
|
||||
],
|
||||
// \Drupal\Core\Render\Element\Checkboxes::valueCallback() requires
|
||||
// NULL instead of FALSE values for programmatic form submissions to
|
||||
// disable a checkbox.
|
||||
'enable_update_status_module' => NULL,
|
||||
'enable_update_status_emails' => NULL,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// If we only have one db driver available, we cannot set the driver.
|
||||
include_once DRUPAL_ROOT . '/core/includes/install.inc';
|
||||
if (count($this->getDatabaseTypes()) == 1) {
|
||||
unset($parameters['forms']['install_settings_form']['driver']);
|
||||
}
|
||||
return $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Preserve the original batch, and instantiate the test batch.
|
||||
*/
|
||||
@@ -479,21 +419,6 @@ abstract class WebTestBase extends TestBase {
|
||||
$batch = $this->originalBatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all supported database driver installer objects.
|
||||
*
|
||||
* This wraps drupal_get_database_types() for use without a current container.
|
||||
*
|
||||
* @return \Drupal\Core\Database\Install\Tasks[]
|
||||
* An array of available database driver installer objects.
|
||||
*/
|
||||
protected function getDatabaseTypes() {
|
||||
\Drupal::setContainer($this->originalContainer);
|
||||
$database_types = drupal_get_database_types();
|
||||
\Drupal::unsetContainer();
|
||||
return $database_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queues custom translations to be written to settings.php.
|
||||
*
|
||||
|
||||
+3
-1
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Drupal\Tests\simpletest\Unit;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* This test crashes PHP.
|
||||
*
|
||||
@@ -11,7 +13,7 @@ namespace Drupal\Tests\simpletest\Unit;
|
||||
*
|
||||
* @see \Drupal\Tests\simpletest\Unit\SimpletestPhpunitRunCommandTest::testSimpletestPhpUnitRunCommand()
|
||||
*/
|
||||
class SimpletestPhpunitRunCommandTestWillDie extends \PHPUnit_Framework_TestCase {
|
||||
class SimpletestPhpunitRunCommandTestWillDie extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* Performs the status specified by SimpletestPhpunitRunCommandTestWillDie.
|
||||
|
||||
@@ -5,8 +5,8 @@ package: Testing
|
||||
# version: VERSION
|
||||
# core: 8.x
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
@@ -7,8 +7,8 @@ package: Testing
|
||||
dependencies:
|
||||
- entity_test
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
@@ -4,15 +4,19 @@ namespace Drupal\Tests\simpletest\Unit;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\File\FileSystemInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Tests simpletest_run_phpunit_tests() handles PHPunit fatals correctly.
|
||||
*
|
||||
* We don't extend Drupal\Tests\UnitTestCase here because its $root property is
|
||||
* not static and we need it to be static here.
|
||||
*
|
||||
* @group simpletest
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class SimpletestPhpunitRunCommandTest extends \PHPUnit_Framework_TestCase {
|
||||
class SimpletestPhpunitRunCommandTest extends TestCase {
|
||||
|
||||
/**
|
||||
* Path to the app root.
|
||||
|
||||
@@ -348,8 +348,7 @@ EOF;
|
||||
$result = $test_discovery->getTestClasses(NULL, ['PHPUnit-Kernel']);
|
||||
$this->assertCount(2, $result);
|
||||
$this->assertEquals([
|
||||
'example' => [
|
||||
],
|
||||
'example' => [],
|
||||
'example2' => [
|
||||
'Drupal\Tests\test_module\Kernel\KernelExampleTest3' => [
|
||||
'name' => 'Drupal\Tests\test_module\Kernel\KernelExampleTest3',
|
||||
|
||||
Reference in New Issue
Block a user