upgrades core to 8.4.2
This commit is contained in:
@@ -61,11 +61,22 @@ class BatchController implements ContainerInjectionInterface {
|
||||
return $output;
|
||||
}
|
||||
elseif (isset($output)) {
|
||||
$title = isset($output['#title']) ? $output['#title'] : NULL;
|
||||
$page = [
|
||||
'#type' => 'page',
|
||||
'#title' => $title,
|
||||
'#show_messages' => FALSE,
|
||||
'content' => $output,
|
||||
];
|
||||
|
||||
// Also inject title as a page header (if available).
|
||||
if ($title) {
|
||||
$page['header'] = [
|
||||
'#type' => 'page_title',
|
||||
'#title' => $title,
|
||||
];
|
||||
}
|
||||
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,18 @@ use Drupal\Core\Controller\ControllerBase;
|
||||
*/
|
||||
class Http4xxController extends ControllerBase {
|
||||
|
||||
/**
|
||||
* The default 4xx error content.
|
||||
*
|
||||
* @return array
|
||||
* A render array containing the message to display for 4xx errors.
|
||||
*/
|
||||
public function on4xx() {
|
||||
return [
|
||||
'#markup' => $this->t('A client error happened'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The default 401 content.
|
||||
*
|
||||
|
||||
@@ -14,18 +14,23 @@ use Drupal\Core\Session\AccountInterface;
|
||||
*/
|
||||
class DateFormatAccessControlHandler extends EntityAccessControlHandler {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $viewLabelOperation = TRUE;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
||||
// There are no restrictions on viewing a date format.
|
||||
if ($operation == 'view') {
|
||||
// There are no restrictions on viewing the label of a date format.
|
||||
if ($operation === 'view label') {
|
||||
return AccessResult::allowed();
|
||||
}
|
||||
// Locked date formats cannot be updated or deleted.
|
||||
elseif (in_array($operation, ['update', 'delete'])) {
|
||||
if ($entity->isLocked()) {
|
||||
return AccessResult::forbidden()->addCacheableDependency($entity);
|
||||
return AccessResult::forbidden('The DateFormat config entity is locked.')->addCacheableDependency($entity);
|
||||
}
|
||||
else {
|
||||
return parent::checkAccess($entity, $operation, $account)->addCacheableDependency($entity);
|
||||
|
||||
@@ -16,6 +16,7 @@ use Drupal\Core\Form\ConfigFormBaseTrait;
|
||||
* Configure cron settings for this site.
|
||||
*/
|
||||
class CronForm extends FormBase {
|
||||
|
||||
use ConfigFormBaseTrait;
|
||||
|
||||
/**
|
||||
@@ -42,7 +43,7 @@ class CronForm extends FormBase {
|
||||
/**
|
||||
* The module handler service.
|
||||
*
|
||||
* @var \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
|
||||
* @var \Drupal\Core\Extension\ModuleHandlerInterface
|
||||
*/
|
||||
protected $moduleHandler;
|
||||
|
||||
@@ -104,6 +105,7 @@ class CronForm extends FormBase {
|
||||
$form['run'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Run cron'),
|
||||
'#submit' => ['::runCron'],
|
||||
];
|
||||
$status = '<p>' . $this->t('Last run: %time ago.', ['%time' => $this->dateFormatter->formatTimeDiffSince($this->state->get('system.cron_last'))]) . '</p>';
|
||||
$form['status'] = [
|
||||
@@ -112,7 +114,7 @@ class CronForm extends FormBase {
|
||||
|
||||
$cron_url = $this->url('system.cron', ['key' => $this->state->get('system.cron_key')], ['absolute' => TRUE]);
|
||||
$form['cron_url'] = [
|
||||
'#markup' => '<p>' . t('To run cron from outside the site, go to <a href=":cron">@cron</a>', [':cron' => $cron_url, '@cron' => $cron_url]) . '</p>',
|
||||
'#markup' => '<p>' . t('To run cron from outside the site, go to <a href=":cron" class="system-cron-settings__link">@cron</a>', [':cron' => $cron_url, '@cron' => $cron_url]) . '</p>',
|
||||
];
|
||||
|
||||
if (!$this->moduleHandler->moduleExists('automated_cron')) {
|
||||
@@ -131,7 +133,7 @@ class CronForm extends FormBase {
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Detailed cron logging'),
|
||||
'#default_value' => $this->config('system.cron')->get('logging'),
|
||||
'#description' => 'Run times of individual cron jobs will be written to watchdog',
|
||||
'#description' => $this->t('Run times of individual cron jobs will be written to watchdog'),
|
||||
];
|
||||
|
||||
$form['actions']['#type'] = 'actions';
|
||||
@@ -145,22 +147,25 @@ class CronForm extends FormBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs cron and reloads the page.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$this->config('system.cron')
|
||||
->set('logging', $form_state->getValue('logging'))
|
||||
->save();
|
||||
drupal_set_message(t('The configuration options have been saved.'));
|
||||
}
|
||||
|
||||
// Run cron manually from Cron form.
|
||||
/**
|
||||
* Form submission handler for running cron manually.
|
||||
*/
|
||||
public function runCron(array &$form, FormStateInterface $form_state) {
|
||||
if ($this->cron->run()) {
|
||||
drupal_set_message(t('Cron ran successfully.'));
|
||||
drupal_set_message($this->t('Cron ran successfully.'));
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t('Cron run failed.'), 'error');
|
||||
drupal_set_message($this->t('Cron run failed.'), 'error');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ class DateFormatDeleteForm extends EntityDeleteForm {
|
||||
public function getQuestion() {
|
||||
return t('Are you sure you want to delete the format %name : %format?', [
|
||||
'%name' => $this->entity->label(),
|
||||
'%format' => $this->dateFormatter->format(REQUEST_TIME, $this->entity->id())]
|
||||
);
|
||||
'%format' => $this->dateFormatter->format(REQUEST_TIME, $this->entity->id()),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -125,10 +125,10 @@ class FileSystemForm extends ConfigFormBase {
|
||||
$period[0] = t('Never');
|
||||
$form['temporary_maximum_age'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => t('Delete orphaned files after'),
|
||||
'#title' => t('Delete temporary files after'),
|
||||
'#default_value' => $config->get('temporary_maximum_age'),
|
||||
'#options' => $period,
|
||||
'#description' => t('Orphaned files are not referenced from any content but remain in the file system and may appear in administrative listings. <strong>Warning:</strong> If enabled, orphaned files will be permanently deleted and may not be recoverable.'),
|
||||
'#description' => t('Temporary files are not referenced, but are in the file system and therefore may show up in administrative lists. <strong>Warning:</strong> If enabled, temporary files will be permanently deleted and may not be recoverable.'),
|
||||
];
|
||||
|
||||
return parent::buildForm($form, $form_state);
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace Drupal\system\Form;
|
||||
use Drupal\Core\Asset\AssetCollectionOptimizerInterface;
|
||||
use Drupal\Core\Form\ConfigFormBase;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Cache\CacheBackendInterface;
|
||||
use Drupal\Core\Datetime\DateFormatterInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
@@ -15,13 +14,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
*/
|
||||
class PerformanceForm extends ConfigFormBase {
|
||||
|
||||
/**
|
||||
* The render cache bin.
|
||||
*
|
||||
* @var \Drupal\Core\Cache\CacheBackendInterface
|
||||
*/
|
||||
protected $renderCache;
|
||||
|
||||
/**
|
||||
* The date formatter service.
|
||||
*
|
||||
@@ -48,7 +40,6 @@ class PerformanceForm extends ConfigFormBase {
|
||||
*
|
||||
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
|
||||
* The factory for configuration objects.
|
||||
* @param \Drupal\Core\Cache\CacheBackendInterface $render_cache
|
||||
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
|
||||
* The date formatter service.
|
||||
* @param \Drupal\Core\Asset\AssetCollectionOptimizerInterface $css_collection_optimizer
|
||||
@@ -56,10 +47,9 @@ class PerformanceForm extends ConfigFormBase {
|
||||
* @param \Drupal\Core\Asset\AssetCollectionOptimizerInterface $js_collection_optimizer
|
||||
* The JavaScript asset collection optimizer service.
|
||||
*/
|
||||
public function __construct(ConfigFactoryInterface $config_factory, CacheBackendInterface $render_cache, DateFormatterInterface $date_formatter, AssetCollectionOptimizerInterface $css_collection_optimizer, AssetCollectionOptimizerInterface $js_collection_optimizer) {
|
||||
public function __construct(ConfigFactoryInterface $config_factory, DateFormatterInterface $date_formatter, AssetCollectionOptimizerInterface $css_collection_optimizer, AssetCollectionOptimizerInterface $js_collection_optimizer) {
|
||||
parent::__construct($config_factory);
|
||||
|
||||
$this->renderCache = $render_cache;
|
||||
$this->dateFormatter = $date_formatter;
|
||||
$this->cssCollectionOptimizer = $css_collection_optimizer;
|
||||
$this->jsCollectionOptimizer = $js_collection_optimizer;
|
||||
@@ -71,7 +61,6 @@ class PerformanceForm extends ConfigFormBase {
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('config.factory'),
|
||||
$container->get('cache.render'),
|
||||
$container->get('date.formatter'),
|
||||
$container->get('asset.css.collection_optimizer'),
|
||||
$container->get('asset.js.collection_optimizer')
|
||||
@@ -168,10 +157,6 @@ class PerformanceForm extends ConfigFormBase {
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$this->cssCollectionOptimizer->deleteAll();
|
||||
$this->jsCollectionOptimizer->deleteAll();
|
||||
// This form allows page compression settings to be changed, which can
|
||||
// invalidate cached pages in the render cache, so it needs to be cleared on
|
||||
// form submit.
|
||||
$this->renderCache->deleteAll();
|
||||
|
||||
$this->config('system.performance')
|
||||
->set('cache.page.max_age', $form_state->getValue('page_cache_maximum_age'))
|
||||
|
||||
@@ -65,7 +65,7 @@ class RegionalForm extends ConfigFormBase {
|
||||
$system_date = $this->config('system.date');
|
||||
|
||||
// Date settings:
|
||||
$zones = system_time_zones();
|
||||
$zones = system_time_zones(NULL, TRUE);
|
||||
|
||||
$form['locale'] = [
|
||||
'#type' => 'details',
|
||||
|
||||
@@ -324,9 +324,21 @@ class ThemeSettingsForm extends ConfigFormBase {
|
||||
// Process the theme and all its base themes.
|
||||
foreach ($theme_keys as $theme) {
|
||||
// Include the theme-settings.php file.
|
||||
$filename = DRUPAL_ROOT . '/' . $themes[$theme]->getPath() . '/theme-settings.php';
|
||||
if (file_exists($filename)) {
|
||||
require_once $filename;
|
||||
$theme_path = drupal_get_path('theme', $theme);
|
||||
$theme_settings_file = $theme_path . '/theme-settings.php';
|
||||
$theme_file = $theme_path . '/' . $theme . '.theme';
|
||||
$filenames = [$theme_settings_file, $theme_file];
|
||||
foreach ($filenames as $filename) {
|
||||
if (file_exists($filename)) {
|
||||
require_once $filename;
|
||||
|
||||
// The file must be required for the cached form too.
|
||||
$files = $form_state->getBuildInfo()['files'];
|
||||
if (!in_array($filename, $files)) {
|
||||
$files[] = $filename;
|
||||
}
|
||||
$form_state->addBuildInfo('files', $files);
|
||||
}
|
||||
}
|
||||
|
||||
// Call theme-specific settings.
|
||||
|
||||
@@ -14,17 +14,23 @@ use Drupal\Core\Session\AccountInterface;
|
||||
*/
|
||||
class MenuAccessControlHandler extends EntityAccessControlHandler {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $viewLabelOperation = TRUE;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
||||
if ($operation === 'view') {
|
||||
// There are no restrictions on viewing the label of a date format.
|
||||
if ($operation === 'view label') {
|
||||
return AccessResult::allowed();
|
||||
}
|
||||
// Locked menus could not be deleted.
|
||||
elseif ($operation == 'delete') {
|
||||
elseif ($operation === 'delete') {
|
||||
if ($entity->isLocked()) {
|
||||
return AccessResult::forbidden()->addCacheableDependency($entity);
|
||||
return AccessResult::forbidden('The Menu config entity is locked.')->addCacheableDependency($entity);
|
||||
}
|
||||
else {
|
||||
return parent::checkAccess($entity, $operation, $account)->addCacheableDependency($entity);
|
||||
|
||||
@@ -11,6 +11,7 @@ use Drupal\Core\Controller\TitleResolverInterface;
|
||||
use Drupal\Core\Link;
|
||||
use Drupal\Core\ParamConverter\ParamNotConvertedException;
|
||||
use Drupal\Core\Path\CurrentPathStack;
|
||||
use Drupal\Core\Path\PathMatcherInterface;
|
||||
use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
|
||||
use Drupal\Core\Routing\RequestContext;
|
||||
use Drupal\Core\Routing\RouteMatch;
|
||||
@@ -79,6 +80,20 @@ class PathBasedBreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
||||
*/
|
||||
protected $currentUser;
|
||||
|
||||
/**
|
||||
* The current path service.
|
||||
*
|
||||
* @var \Drupal\Core\Path\CurrentPathStack
|
||||
*/
|
||||
protected $currentPath;
|
||||
|
||||
/**
|
||||
* The patch matcher service.
|
||||
*
|
||||
* @var \Drupal\Core\Path\PathMatcherInterface
|
||||
*/
|
||||
protected $pathMatcher;
|
||||
|
||||
/**
|
||||
* Constructs the PathBasedBreadcrumbBuilder.
|
||||
*
|
||||
@@ -98,8 +113,10 @@ class PathBasedBreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
||||
* The current user object.
|
||||
* @param \Drupal\Core\Path\CurrentPathStack $current_path
|
||||
* The current path.
|
||||
* @param \Drupal\Core\Path\PathMatcherInterface $path_matcher
|
||||
* The path matcher service.
|
||||
*/
|
||||
public function __construct(RequestContext $context, AccessManagerInterface $access_manager, RequestMatcherInterface $router, InboundPathProcessorInterface $path_processor, ConfigFactoryInterface $config_factory, TitleResolverInterface $title_resolver, AccountInterface $current_user, CurrentPathStack $current_path) {
|
||||
public function __construct(RequestContext $context, AccessManagerInterface $access_manager, RequestMatcherInterface $router, InboundPathProcessorInterface $path_processor, ConfigFactoryInterface $config_factory, TitleResolverInterface $title_resolver, AccountInterface $current_user, CurrentPathStack $current_path, PathMatcherInterface $path_matcher = NULL) {
|
||||
$this->context = $context;
|
||||
$this->accessManager = $access_manager;
|
||||
$this->router = $router;
|
||||
@@ -108,6 +125,7 @@ class PathBasedBreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
||||
$this->titleResolver = $title_resolver;
|
||||
$this->currentUser = $current_user;
|
||||
$this->currentPath = $current_path;
|
||||
$this->pathMatcher = $path_matcher ?: \Drupal::service('path.matcher');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,6 +142,15 @@ class PathBasedBreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
||||
$breadcrumb = new Breadcrumb();
|
||||
$links = [];
|
||||
|
||||
// Add the url.path.parent cache context. This code ignores the last path
|
||||
// part so the result only depends on the path parents.
|
||||
$breadcrumb->addCacheContexts(['url.path.parent']);
|
||||
|
||||
// Do not display a breadcrumb on the frontpage.
|
||||
if ($this->pathMatcher->isFrontPage()) {
|
||||
return $breadcrumb;
|
||||
}
|
||||
|
||||
// General path-based breadcrumbs. Use the actual request path, prior to
|
||||
// resolving path aliases, so the breadcrumb can be defined by simply
|
||||
// creating a hierarchy of path aliases.
|
||||
@@ -136,9 +163,6 @@ class PathBasedBreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
||||
// /user is just a redirect, so skip it.
|
||||
// @todo Find a better way to deal with /user.
|
||||
$exclude['/user'] = TRUE;
|
||||
// Add the url.path.parent cache context. This code ignores the last path
|
||||
// part so the result only depends on the path parents.
|
||||
$breadcrumb->addCacheContexts(['url.path.parent']);
|
||||
while (count($path_elements) > 1) {
|
||||
array_pop($path_elements);
|
||||
// Copy the path elements for up-casting.
|
||||
@@ -160,12 +184,10 @@ class PathBasedBreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
||||
$links[] = new Link($title, $url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if ($path && '/' . $path != $front) {
|
||||
// Add the Home link, except for the front page.
|
||||
$links[] = Link::createFromRoute($this->t('Home'), '<front>');
|
||||
}
|
||||
// Add the Home link.
|
||||
$links[] = Link::createFromRoute($this->t('Home'), '<front>');
|
||||
|
||||
return $breadcrumb->setLinks(array_reverse($links));
|
||||
}
|
||||
|
||||
@@ -147,6 +147,25 @@ class SystemMenuBlock extends BlockBase implements ContainerFactoryPluginInterfa
|
||||
$parameters->setMaxDepth(min($level + $depth - 1, $this->menuTree->maxDepth()));
|
||||
}
|
||||
|
||||
// For menu blocks with start level greater than 1, only show menu items
|
||||
// from the current active trail. Adjust the root according to the current
|
||||
// position in the menu in order to determine if we can show the subtree.
|
||||
if ($level > 1) {
|
||||
if (count($parameters->activeTrail) >= $level) {
|
||||
// Active trail array is child-first. Reverse it, and pull the new menu
|
||||
// root based on the parent of the configured start level.
|
||||
$menu_trail_ids = array_reverse(array_values($parameters->activeTrail));
|
||||
$menu_root = $menu_trail_ids[$level - 1];
|
||||
$parameters->setRoot($menu_root)->setMinDepth(1);
|
||||
if ($depth > 0) {
|
||||
$parameters->setMaxDepth(min($level - 1 + $depth - 1, $this->menuTree->maxDepth()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
$tree = $this->menuTree->load($menu_name, $parameters);
|
||||
$manipulators = [
|
||||
['callable' => 'menu.default_tree_manipulators:checkAccess'],
|
||||
|
||||
@@ -45,7 +45,7 @@ class Rotate extends GDImageToolkitOperationBase {
|
||||
// Validate or set background color argument.
|
||||
if (!empty($arguments['background'])) {
|
||||
// Validate the background color: Color::hexToRgb does so for us.
|
||||
$background = Color::hexToRgb($arguments['background']) + [ 'alpha' => 0 ];
|
||||
$background = Color::hexToRgb($arguments['background']) + ['alpha' => 0];
|
||||
}
|
||||
else {
|
||||
// Background color is not specified: use transparent white as background.
|
||||
|
||||
@@ -9,7 +9,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "menu",
|
||||
* source_provider = "menu"
|
||||
* source_module = "menu"
|
||||
* )
|
||||
*/
|
||||
class Menu extends DrupalSqlBase {
|
||||
|
||||
@@ -9,7 +9,7 @@ use Drupal\migrate_drupal\Plugin\migrate\source\VariableMultiRow;
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_theme_settings",
|
||||
* source_provider = "system"
|
||||
* source_module = "system"
|
||||
* )
|
||||
*/
|
||||
class ThemeSettings extends VariableMultiRow {
|
||||
|
||||
@@ -25,7 +25,7 @@ class SystemConfigSubscriber implements EventSubscriberInterface {
|
||||
/**
|
||||
* Constructs the SystemConfigSubscriber.
|
||||
*
|
||||
* @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder
|
||||
* @param \Drupal\Core\Routing\RouteBuilderInterface $router_builder
|
||||
* The router builder service.
|
||||
*/
|
||||
public function __construct(RouteBuilderInterface $router_builder) {
|
||||
|
||||
@@ -110,7 +110,7 @@ class SystemManager {
|
||||
|
||||
// Check run-time requirements and status information.
|
||||
$requirements = $this->moduleHandler->invokeAll('requirements', ['runtime']);
|
||||
uasort($requirements, function($a, $b) {
|
||||
uasort($requirements, function ($a, $b) {
|
||||
if (!isset($a['weight'])) {
|
||||
if (!isset($b['weight'])) {
|
||||
return strcasecmp($a['title'], $b['title']);
|
||||
|
||||
@@ -124,7 +124,7 @@ class CommandsTest extends AjaxTestBase {
|
||||
* Regression test: Settings command exists regardless of JS aggregation.
|
||||
*/
|
||||
public function testAttachedSettings() {
|
||||
$assert = function($message) {
|
||||
$assert = function ($message) {
|
||||
$response = new AjaxResponse();
|
||||
$response->setAttachments([
|
||||
'library' => ['core/drupalSettings'],
|
||||
|
||||
@@ -175,10 +175,12 @@ class DialogTest extends AjaxTestBase {
|
||||
'edit-preview' => [
|
||||
'callback' => '::preview',
|
||||
'event' => 'click',
|
||||
'url' => Url::fromRoute('ajax_test.dialog_form', [], ['query' => [
|
||||
'url' => Url::fromRoute('ajax_test.dialog_form', [], [
|
||||
'query' => [
|
||||
MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal',
|
||||
FormBuilderInterface::AJAX_FORM_REQUEST => TRUE,
|
||||
]])->toString(),
|
||||
],
|
||||
])->toString(),
|
||||
'dialogType' => 'ajax',
|
||||
'submit' => [
|
||||
'_triggering_element_name' => 'op',
|
||||
|
||||
@@ -44,7 +44,7 @@ class MultiFormTest extends AjaxTestBase {
|
||||
->save();
|
||||
|
||||
// Log in a user who can create 'page' nodes.
|
||||
$this->drupalLogin ($this->drupalCreateUser(['create page content']));
|
||||
$this->drupalLogin($this->drupalCreateUser(['create page content']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@ class ErrorContainer extends Container {
|
||||
public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE) {
|
||||
if ($id === 'http_kernel') {
|
||||
// Enforce a recoverable error.
|
||||
$callable = function(ErrorContainer $container) {
|
||||
$callable = function (ErrorContainer $container) {
|
||||
};
|
||||
$callable(1);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,12 @@ use Drupal\Core\Url;
|
||||
* Provides test assertions for testing page-level cache contexts & tags.
|
||||
*
|
||||
* Can be used by test classes that extend \Drupal\simpletest\WebTestBase.
|
||||
*
|
||||
* @deprecated Scheduled for removal in Drupal 9.0.0. Use
|
||||
* \Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait
|
||||
* instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2896632
|
||||
*/
|
||||
trait AssertPageCacheContextsAndTagsTrait {
|
||||
|
||||
@@ -91,7 +97,7 @@ trait AssertPageCacheContextsAndTagsTrait {
|
||||
// Assert page cache item + expected cache tags.
|
||||
$cid_parts = [$url->setAbsolute()->toString(), 'html'];
|
||||
$cid = implode(':', $cid_parts);
|
||||
$cache_entry = \Drupal::cache('render')->get($cid);
|
||||
$cache_entry = \Drupal::cache('page')->get($cid);
|
||||
sort($cache_entry->tags);
|
||||
$this->assertEqual($cache_entry->tags, $expected_tags);
|
||||
$this->debugCacheTags($cache_entry->tags, $expected_tags);
|
||||
|
||||
@@ -69,7 +69,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
* @return \Drupal\Core\Cache\CacheBackendInterface
|
||||
* Cache backend to test.
|
||||
*/
|
||||
protected abstract function createCacheBackend($bin);
|
||||
abstract protected function createCacheBackend($bin);
|
||||
|
||||
/**
|
||||
* Allows specific implementation to change the environment before a test run.
|
||||
@@ -303,9 +303,11 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
$reference = [
|
||||
'test3',
|
||||
'test7',
|
||||
'test21', // Cid does not exist.
|
||||
// Cid does not exist.
|
||||
'test21',
|
||||
'test6',
|
||||
'test19', // Cid does not exist until added before second getMultiple().
|
||||
// Cid does not exist until added before second getMultiple().
|
||||
'test19',
|
||||
'test2',
|
||||
];
|
||||
|
||||
@@ -443,13 +445,16 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
$backend->set('test7', 17);
|
||||
|
||||
$backend->delete('test1');
|
||||
$backend->delete('test23'); // Nonexistent key should not cause an error.
|
||||
// Nonexistent key should not cause an error.
|
||||
$backend->delete('test23');
|
||||
$backend->deleteMultiple([
|
||||
'test3',
|
||||
'test5',
|
||||
'test7',
|
||||
'test19', // Nonexistent key should not cause an error.
|
||||
'test21', // Nonexistent key should not cause an error.
|
||||
// Nonexistent key should not cause an error.
|
||||
'test19',
|
||||
// Nonexistent key should not cause an error.
|
||||
'test21',
|
||||
]);
|
||||
|
||||
// Test if expected keys have been deleted.
|
||||
|
||||
@@ -54,7 +54,7 @@ abstract class PageCacheTagsTestBase extends WebTestBase {
|
||||
$absolute_url = $url->setAbsolute()->toString();
|
||||
$cid_parts = [$absolute_url, 'html'];
|
||||
$cid = implode(':', $cid_parts);
|
||||
$cache_entry = \Drupal::cache('render')->get($cid);
|
||||
$cache_entry = \Drupal::cache('page')->get($cid);
|
||||
sort($cache_entry->tags);
|
||||
$tags = array_unique($tags);
|
||||
sort($tags);
|
||||
|
||||
@@ -168,7 +168,7 @@ class UrlTest extends WebTestBase {
|
||||
$l = \Drupal::l('foo', Url::fromUri('https://www.drupal.org'));
|
||||
|
||||
// Test a renderable array passed to the link generator.
|
||||
$renderer->executeInRenderContext(new RenderContext(), function() use ($renderer, $l) {
|
||||
$renderer->executeInRenderContext(new RenderContext(), function () use ($renderer, $l) {
|
||||
$renderable_text = ['#markup' => 'foo'];
|
||||
$l_renderable_text = \Drupal::l($renderable_text, Url::fromUri('https://www.drupal.org'));
|
||||
$this->assertEqual($l_renderable_text, $l);
|
||||
|
||||
@@ -14,4 +14,4 @@ namespace Drupal\system\Tests\Database;
|
||||
* @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead
|
||||
* use \Drupal\Tests\system\Functional\Database\FakeRecord.
|
||||
*/
|
||||
class FakeRecord { }
|
||||
class FakeRecord {}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Drupal\system\Tests\Form;
|
||||
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\system\Functional\Form\StubForm;
|
||||
|
||||
/**
|
||||
* Tests the tableselect form element for expected behavior.
|
||||
@@ -92,7 +93,7 @@ class ElementsTableSelectTest extends WebTestBase {
|
||||
// The first two body rows should each have 5 table cells: One for the
|
||||
// radio, one cell in the first column, one cell in the second column,
|
||||
// and two cells in the third column which has colspan 2.
|
||||
for ( $i = 0; $i <= 1; $i++) {
|
||||
for ($i = 0; $i <= 1; $i++) {
|
||||
$this->assertEqual(count($table_body[0]->tr[$i]->td), 5, format_string('There are five cells in row @row.', ['@row' => $i]));
|
||||
}
|
||||
// The third row should have 3 cells, one for the radio, one spanning the
|
||||
|
||||
@@ -28,7 +28,7 @@ class StorageTest extends WebTestBase {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalLogin ($this->drupalCreateUser());
|
||||
$this->drupalLogin($this->drupalCreateUser());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,7 +89,7 @@ class TriggeringElementTest extends WebTestBase {
|
||||
// Ensure that the triggering element was not set to the restricted button.
|
||||
// Do this with both a negative and positive assertion, because negative
|
||||
// assertions alone can be brittle. See testNoButtonInfoInPost() for why the
|
||||
//triggering element gets set to 'button2'.
|
||||
// triggering element gets set to 'button2'.
|
||||
$this->assertNoText('The clicked button is button1.', '$form_state->getTriggeringElement() not set to a restricted button.');
|
||||
$this->assertText('The clicked button is button2.', '$form_state->getTriggeringElement() not set to a restricted button.');
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ use Drupal\Core\Site\Settings;
|
||||
use Drupal\simpletest\InstallerTestBase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
|
||||
/**
|
||||
* Tests distribution profile support with existing settings.
|
||||
*
|
||||
|
||||
@@ -25,6 +25,10 @@ class InstallerTest extends InstallerTestBase {
|
||||
$this->assertRaw(t('Congratulations, you installed @drupal!', [
|
||||
'@drupal' => drupal_install_profile_distribution_name(),
|
||||
]));
|
||||
|
||||
// Ensure that the timezone is correct for sites under test after installing
|
||||
// interactively.
|
||||
$this->assertEqual($this->config('system.date')->get('timezone.default'), 'Australia/Sydney');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,11 +2,16 @@
|
||||
|
||||
namespace Drupal\system\Tests\Menu;
|
||||
|
||||
@trigger_error(__NAMESPACE__ . '\AssertBreadcrumbTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\system\Functional\Menu\AssertBreadcrumbTrait', E_USER_DEPRECATED);
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Core\Url;
|
||||
|
||||
/**
|
||||
* Provides test assertions for verifying breadcrumbs.
|
||||
*
|
||||
* @deprecated Scheduled for removal in Drupal 9.0.0.
|
||||
* Use \Drupal\Tests\system\Functional\Menu\AssertBreadcrumbTrait instead.
|
||||
*/
|
||||
trait AssertBreadcrumbTrait {
|
||||
|
||||
|
||||
@@ -2,10 +2,15 @@
|
||||
|
||||
namespace Drupal\system\Tests\Menu;
|
||||
|
||||
@trigger_error(__NAMESPACE__ . '\AssertMenuActiveTrailTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\system\Functional\Menu\AssertMenuActiveTrailTrait', E_USER_DEPRECATED);
|
||||
|
||||
use Drupal\Core\Url;
|
||||
|
||||
/**
|
||||
* Provides test assertions for verifying the active menu trail.
|
||||
*
|
||||
* @deprecated Scheduled for removal in Drupal 9.0.0.
|
||||
* Use \Drupal\Tests\system\Functional\Menu\AssertMenuActiveTrailTrait instead.
|
||||
*/
|
||||
trait AssertMenuActiveTrailTrait {
|
||||
|
||||
|
||||
@@ -2,8 +2,16 @@
|
||||
|
||||
namespace Drupal\system\Tests\Menu;
|
||||
|
||||
@trigger_error(__NAMESPACE__ . '\MenuTestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\BrowserTestBase', E_USER_DEPRECATED);
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Base class for Menu tests.
|
||||
*
|
||||
* @deprecated Scheduled for removal in Drupal 9.0.0.
|
||||
* Use \Drupal\Tests\BrowserTestBase instead.
|
||||
*/
|
||||
abstract class MenuTestBase extends WebTestBase {
|
||||
|
||||
use AssertBreadcrumbTrait;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\system\Tests\Module;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
||||
/**
|
||||
@@ -90,6 +91,16 @@ class DependencyTest extends ModuleTestBase {
|
||||
$this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests failing PHP version requirements.
|
||||
*/
|
||||
public function testIncompatiblePhpVersionDependency() {
|
||||
$this->drupalGet('admin/modules');
|
||||
$this->assertRaw('This module requires PHP version 6502.* and is incompatible with PHP version ' . phpversion() . '.', 'User is informed when the PHP dependency requirement of a module is not met.');
|
||||
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_incompatible_php_version_test][enable]"]');
|
||||
$this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests enabling a module that depends on a module which fails hook_requirements().
|
||||
*/
|
||||
|
||||
@@ -275,7 +275,7 @@ class InstallUninstallTest extends ModuleTestBase {
|
||||
$all_update_functions = $post_update_registry->getPendingUpdateFunctions();
|
||||
$empty_result = TRUE;
|
||||
foreach ($all_update_functions as $function) {
|
||||
list($function_module, ) = explode('_post_update_', $function);
|
||||
list($function_module,) = explode('_post_update_', $function);
|
||||
if ($module === $function_module) {
|
||||
$empty_result = FALSE;
|
||||
break;
|
||||
|
||||
@@ -90,8 +90,10 @@ abstract class ModuleTestBase extends WebTestBase {
|
||||
* @param string $module
|
||||
* The name of the module.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if configuration has been installed, FALSE otherwise.
|
||||
* @return bool|null
|
||||
* TRUE if configuration has been installed, FALSE otherwise. Returns NULL
|
||||
* if the module configuration directory does not exist or does not contain
|
||||
* any configuration files.
|
||||
*/
|
||||
public function assertModuleConfig($module) {
|
||||
$module_config_dir = drupal_get_path('module', $module) . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
|
||||
|
||||
@@ -282,7 +282,8 @@ class SessionTest extends WebTestBase {
|
||||
/**
|
||||
* Reset the cookie file so that it refers to the specified user.
|
||||
*
|
||||
* @param $uid User id to set as the active session.
|
||||
* @param $uid
|
||||
* User id to set as the active session.
|
||||
*/
|
||||
public function sessionReset($uid = 0) {
|
||||
// Close the internal browser.
|
||||
|
||||
@@ -105,9 +105,19 @@ class CronRunTest extends WebTestBase {
|
||||
// the time will start at 1 January 1970.
|
||||
$this->assertNoText('years');
|
||||
|
||||
$this->drupalPostForm(NULL, [], t('Save configuration'));
|
||||
$this->assertText(t('The configuration options have been saved.'));
|
||||
$cron_last = time() - 200;
|
||||
\Drupal::state()->set('system.cron_last', $cron_last);
|
||||
|
||||
$this->drupalPostForm(NULL, [], 'Save configuration');
|
||||
$this->assertText('The configuration options have been saved.');
|
||||
$this->assertUrl('admin/config/system/cron');
|
||||
|
||||
// Check that cron does not run when saving the configuration form.
|
||||
$this->assertEqual($cron_last, \Drupal::state()->get('system.cron_last'), 'Cron does not run when saving the configuration form.');
|
||||
|
||||
// Check that cron runs when triggered manually.
|
||||
$this->drupalPostForm(NULL, [], 'Run cron');
|
||||
$this->assertTrue($cron_last < \Drupal::state()->get('system.cron_last'), 'Cron runs when triggered manually.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,8 +34,9 @@ class FloodTest extends WebTestBase {
|
||||
$window_expired = -1;
|
||||
$name = 'flood_test_cleanup';
|
||||
|
||||
// Register expired event.
|
||||
$flood = \Drupal::flood();
|
||||
$this->assertTrue($flood->isAllowed($name, $threshold));
|
||||
// Register expired event.
|
||||
$flood->register($name, $window_expired);
|
||||
// Verify event is not allowed.
|
||||
$this->assertFalse($flood->isAllowed($name, $threshold));
|
||||
@@ -62,6 +63,7 @@ class FloodTest extends WebTestBase {
|
||||
|
||||
$request_stack = \Drupal::service('request_stack');
|
||||
$flood = new MemoryBackend($request_stack);
|
||||
$this->assertTrue($flood->isAllowed($name, $threshold));
|
||||
// Register expired event.
|
||||
$flood->register($name, $window_expired);
|
||||
// Verify event is not allowed.
|
||||
@@ -90,6 +92,7 @@ class FloodTest extends WebTestBase {
|
||||
$connection = \Drupal::service('database');
|
||||
$request_stack = \Drupal::service('request_stack');
|
||||
$flood = new DatabaseBackend($connection, $request_stack);
|
||||
$this->assertTrue($flood->isAllowed($name, $threshold));
|
||||
// Register expired event.
|
||||
$flood->register($name, $window_expired);
|
||||
// Verify event is not allowed.
|
||||
|
||||
@@ -30,7 +30,7 @@ class FrontPageTest extends WebTestBase {
|
||||
parent::setUp();
|
||||
|
||||
// Create admin user, log in admin user, and create one node.
|
||||
$this->drupalLogin ($this->drupalCreateUser([
|
||||
$this->drupalLogin($this->drupalCreateUser([
|
||||
'access content',
|
||||
'administer site configuration',
|
||||
]));
|
||||
|
||||
@@ -113,9 +113,9 @@ class PageTitleTest extends WebTestBase {
|
||||
$this->assertEqual('Test dynamic title', (string) $result[0]);
|
||||
|
||||
// Set some custom translated strings.
|
||||
$this->addCustomTranslations('en', ['' => [
|
||||
'Static title' => 'Static title translated'
|
||||
]]);
|
||||
$this->addCustomTranslations('en', [
|
||||
'' => ['Static title' => 'Static title translated'],
|
||||
]);
|
||||
$this->writeCustomTranslations();
|
||||
|
||||
// Ensure that the title got translated.
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Drupal\system\Tests\System;
|
||||
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Drupal\system\Tests\Update;
|
||||
|
||||
@trigger_error(__NAMESPACE__ . '\DbUpdatesTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Use \Drupal\FunctionalTests\Update\DbUpdatesTrait instead. See https://www.drupal.org/node/2896640.', E_USER_DEPRECATED);
|
||||
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Drupal\Core\Url;
|
||||
|
||||
@@ -10,6 +12,10 @@ use Drupal\Core\Url;
|
||||
* pending db updates through the Update UI.
|
||||
*
|
||||
* This should be used only by classes extending \Drupal\simpletest\WebTestBase.
|
||||
*
|
||||
* @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0.
|
||||
* Use \Drupal\FunctionalTests\Update\DbUpdatesTrait.
|
||||
* @see https://www.drupal.org/node/2896640
|
||||
*/
|
||||
trait DbUpdatesTrait {
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Drupal\system\Tests\Update;
|
||||
|
||||
@trigger_error(__NAMESPACE__ . '\UpdatePathTestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Use \Drupal\FunctionalTests\Update\UpdatePathTestBase instead. See https://www.drupal.org/node/2896640.', E_USER_DEPRECATED);
|
||||
|
||||
use Drupal\Component\Utility\Crypt;
|
||||
use Drupal\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Core\Database\Database;
|
||||
@@ -34,6 +36,10 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*
|
||||
* @ingroup update_api
|
||||
*
|
||||
* @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0.
|
||||
* Use \Drupal\FunctionalTests\Update\UpdatePathTestBase.
|
||||
* @see https://www.drupal.org/node/2896640
|
||||
*
|
||||
* @see hook_update_N()
|
||||
*/
|
||||
abstract class UpdatePathTestBase extends WebTestBase {
|
||||
@@ -237,10 +243,14 @@ abstract class UpdatePathTestBase extends WebTestBase {
|
||||
}
|
||||
// The site might be broken at the time so logging in using the UI might
|
||||
// not work, so we use the API itself.
|
||||
drupal_rewrite_settings(['settings' => ['update_free_access' => (object) [
|
||||
'value' => TRUE,
|
||||
'required' => TRUE,
|
||||
]]]);
|
||||
drupal_rewrite_settings([
|
||||
'settings' => [
|
||||
'update_free_access' => (object) [
|
||||
'value' => TRUE,
|
||||
'required' => TRUE,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->drupalGet($this->updateUrl);
|
||||
$this->clickLink(t('Continue'));
|
||||
|
||||
Reference in New Issue
Block a user