Core and composer updates

This commit is contained in:
Rob Davies 2017-07-03 16:47:07 +01:00
parent a82634bb98
commit 62cac30480
1118 changed files with 21770 additions and 6306 deletions

View file

@ -0,0 +1,44 @@
id: d7_theme_settings
label: D7 theme settings
migration_tags:
- Drupal 7
source:
plugin: d7_theme_settings
constants:
config_suffix: '.settings'
process:
# Build the configuration name from the variable name, i.e.
# theme_bartik_settings becomes bartik.settings.
theme_name:
-
plugin: explode
source: name
delimiter: _
-
plugin: extract
index:
- 1
configuration_name:
plugin: concat
source:
- '@theme_name'
- constants/config_suffix
toggle_logo: theme_settings/toggle_logo
toggle_name: value/toggle_name
toggle_slogan: value/toggle_slogan
toggle_node_user_picture: value/toggle_node_user_picture
toggle_comment_user_picture: value/toggle_comment_user_picture
toggle_comment_user_verification: value/toggle_comment_user_verification
toggle_favicon: value/toggle_favicon
default_logo: value/default_logo
logo_path: value/logo_path
logo_upload: value/logo_upload
default_favicon: value/default_favicon
favicon_path: value/favicon_path
favicon_mimetype: value/favicon_mimetype
# Ignore settings not present in Drupal 8.
# value/favicon_upload
# value/toggle_main_menu
# value/toggle_secondary_menu
destination:
plugin: d7_theme_settings

View file

@ -49,9 +49,7 @@ class StatusReportPage extends RenderElement {
}
}
}
$element['#general_info']['#' . $key] = $requirement;
unset($element['#requirements'][$key]);
break;
// Intentional fall-through.
case 'drupal':
case 'webserver':
@ -60,7 +58,9 @@ class StatusReportPage extends RenderElement {
case 'php':
case 'php_memory_limit':
$element['#general_info']['#' . $key] = $requirement;
unset($element['#requirements'][$key]);
if (isset($requirement['severity']) && $requirement['severity'] < REQUIREMENT_WARNING) {
unset($element['#requirements'][$key]);
}
break;
}
}

View file

@ -0,0 +1,94 @@
<?php
namespace Drupal\system\Plugin\migrate\destination\d7;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Row;
use Drupal\migrate\Plugin\migrate\destination\DestinationBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Persist theme settings to the config system.
*
* @MigrateDestination(
* id = "d7_theme_settings"
* )
*/
class ThemeSettings extends DestinationBase implements ContainerFactoryPluginInterface {
/**
* The configuration factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Constructs a theme settings destination object.
*
* @param array $configuration
* Plugin configuration.
* @param string $plugin_id
* The plugin ID.
* @param mixed $plugin_definition
* The plugin definition.
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* The current migration.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration factory.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, ConfigFactoryInterface $config_factory) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
$this->configFactory = $config_factory;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$migration,
$container->get('config.factory')
);
}
/**
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = []) {
$imported = FALSE;
$config = $this->configFactory->getEditable($row->getDestinationProperty('configuration_name'));
$theme_settings = $row->getDestination();
// Remove keys not in theme settings.
unset($theme_settings['configuration_name']);
unset($theme_settings['theme_name']);
if (isset($theme_settings)) {
theme_settings_convert_to_config($theme_settings, $config);
$config->save();
$imported = TRUE;
}
return $imported;
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['name']['type'] = 'string';
return $ids;
}
/**
* {@inheritdoc}
*/
public function fields(MigrationInterface $migration = NULL) {
// Theme settings vary by theme, so no specific fields are defined.
return [];
}
}

View file

@ -0,0 +1,44 @@
<?php
namespace Drupal\system\Plugin\migrate\source\d7;
use Drupal\migrate_drupal\Plugin\migrate\source\VariableMultiRow;
/**
* Drupal 7 system source from database.
*
* @MigrateSource(
* id = "d7_theme_settings",
* source_provider = "system"
* )
*/
class ThemeSettings extends VariableMultiRow {
/**
* {@inheritdoc}
*/
public function query() {
return $this->select('variable', 'v')
->fields('v', ['name', 'value'])
->condition('name', 'theme_%_settings', 'LIKE');
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'name' => $this->t('Theme settings variable for a theme.'),
'value' => $this->t('The theme settings variable value.'),
];
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['name']['type'] = 'string';
return $ids;
}
}

View file

@ -1,102 +0,0 @@
<?php
namespace Drupal\system\Tests\Ajax;
/**
* Performs tests on AJAX forms in cached pages.
*
* @group Ajax
*/
class AjaxFormPageCacheTest extends AjaxTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$config = $this->config('system.performance');
$config->set('cache.page.max_age', 300);
$config->save();
}
/**
* Return the build id of the current form.
*/
protected function getFormBuildId() {
$build_id_fields = $this->xpath('//input[@name="form_build_id"]');
$this->assertEqual(count($build_id_fields), 1, 'One form build id field on the page');
return (string) $build_id_fields[0]['value'];
}
/**
* Create a simple form, then submit the form via AJAX to change to it.
*/
public function testSimpleAJAXFormValue() {
$this->drupalGet('ajax_forms_test_get_form');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
$build_id_initial = $this->getFormBuildId();
$edit = ['select' => 'green'];
$commands = $this->drupalPostAjaxForm(NULL, $edit, 'select');
$build_id_first_ajax = $this->getFormBuildId();
$this->assertNotEqual($build_id_initial, $build_id_first_ajax, 'Build id is changed in the simpletest-DOM on first AJAX submission');
$expected = [
'command' => 'update_build_id',
'old' => $build_id_initial,
'new' => $build_id_first_ajax,
];
$this->assertCommand($commands, $expected, 'Build id change command issued on first AJAX submission');
$edit = ['select' => 'red'];
$commands = $this->drupalPostAjaxForm(NULL, $edit, 'select');
$build_id_second_ajax = $this->getFormBuildId();
$this->assertNotEqual($build_id_first_ajax, $build_id_second_ajax, 'Build id changes on subsequent AJAX submissions');
$expected = [
'command' => 'update_build_id',
'old' => $build_id_first_ajax,
'new' => $build_id_second_ajax,
];
$this->assertCommand($commands, $expected, 'Build id change command issued on subsequent AJAX submissions');
// Repeat the test sequence but this time with a page loaded from the cache.
$this->drupalGet('ajax_forms_test_get_form');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
$build_id_from_cache_initial = $this->getFormBuildId();
$this->assertEqual($build_id_initial, $build_id_from_cache_initial, 'Build id is the same as on the first request');
$edit = ['select' => 'green'];
$commands = $this->drupalPostAjaxForm(NULL, $edit, 'select');
$build_id_from_cache_first_ajax = $this->getFormBuildId();
$this->assertNotEqual($build_id_from_cache_initial, $build_id_from_cache_first_ajax, 'Build id is changed in the simpletest-DOM on first AJAX submission');
$this->assertNotEqual($build_id_first_ajax, $build_id_from_cache_first_ajax, 'Build id from first user is not reused');
$expected = [
'command' => 'update_build_id',
'old' => $build_id_from_cache_initial,
'new' => $build_id_from_cache_first_ajax,
];
$this->assertCommand($commands, $expected, 'Build id change command issued on first AJAX submission');
$edit = ['select' => 'red'];
$commands = $this->drupalPostAjaxForm(NULL, $edit, 'select');
$build_id_from_cache_second_ajax = $this->getFormBuildId();
$this->assertNotEqual($build_id_from_cache_first_ajax, $build_id_from_cache_second_ajax, 'Build id changes on subsequent AJAX submissions');
$expected = [
'command' => 'update_build_id',
'old' => $build_id_from_cache_first_ajax,
'new' => $build_id_from_cache_second_ajax,
];
$this->assertCommand($commands, $expected, 'Build id change command issued on subsequent AJAX submissions');
}
/**
* Tests a form that uses an #ajax callback.
*
* @see \Drupal\system\Tests\Ajax\ElementValidationTest::testAjaxElementValidation()
*/
public function testAjaxElementValidation() {
$edit = ['drivertext' => t('some dumb text')];
$this->drupalPostAjaxForm('ajax_validation_test', $edit, 'drivertext');
}
}

View file

@ -57,7 +57,7 @@ function system_requirements($phase) {
$enabled_modules = \Drupal::moduleHandler()->getModuleList();
foreach ($enabled_modules as $module => $data) {
$info = system_get_info('module', $module);
if ($info['package'] === 'Core (Experimental)') {
if (isset($info['package']) && $info['package'] === 'Core (Experimental)') {
$experimental[$module] = $info['name'];
}
}

View file

@ -0,0 +1,24 @@
<?php
namespace Drupal\entity_test\Entity;
/**
* Test entity class with no bundle.
*
* @ContentEntityType(
* id = "entity_test_no_bundle",
* label = @Translation("Entity Test without bundle"),
* base_table = "entity_test_no_bundle",
* entity_keys = {
* "id" = "id",
* "revision" = "revision_id",
* },
* admin_permission = "administer entity_test content",
* links = {
* "add-form" = "/entity_test_no_bundle/add",
* },
* )
*/
class EntityTestNoBundle extends EntityTest {
}

View file

@ -0,0 +1,28 @@
<?php
namespace Drupal\entity_test\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase;
/**
* Plugin implementation of the 'entity_reference_custom_cache_tag' formatter.
*
* @FieldFormatter(
* id = "entity_reference_custom_cache_tag",
* label = @Translation("Custom cache tag"),
* field_types = {
* "entity_reference"
* }
* )
*/
class EntityTestReferenceCustomCacheTagFormatter extends EntityReferenceFormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
return ['#cache' => ['tags' => ['custom_cache_tag']]];
}
}

View file

@ -35,6 +35,18 @@ class TestForm extends FormBase {
'#default_value' => 'Test name',
];
$form['checkbox_enabled'] = [
'#type' => 'checkbox',
'#title' => 'Checkbox enabled',
'#default_value' => TRUE,
];
$form['checkbox_disabled'] = [
'#type' => 'checkbox',
'#title' => 'Checkbox disabled',
'#default_value' => FALSE,
];
$form['description'] = [
'#type' => 'textfield',
'#title' => 'Description',

View file

@ -1,15 +1,15 @@
<?php
namespace Drupal\system\Tests\Batch;
namespace Drupal\Tests\system\Functional\Batch;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the content of the progress page.
*
* @group Batch
*/
class PageTest extends WebTestBase {
class PageTest extends BrowserTestBase {
/**
* Modules to enable.

View file

@ -1,16 +1,16 @@
<?php
namespace Drupal\system\Tests\Batch;
namespace Drupal\Tests\system\Functional\Batch;
use Drupal\Core\Url;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests batch processing in form and non-form workflow.
*
* @group Batch
*/
class ProcessingTest extends WebTestBase {
class ProcessingTest extends BrowserTestBase {
/**
* Modules to enable.

View file

@ -5,6 +5,7 @@ namespace Drupal\Tests\system\Functional\System;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
use Drupal\system\SystemRequirements;
use Symfony\Component\CssSelector\CssSelectorConverter;
/**
* Tests output on the status overview page.
@ -89,6 +90,15 @@ class StatusTest extends BrowserTestBase {
$this->drupalGet('admin/reports/status/php');
$this->assertResponse(200, 'The phpinfo page is reachable.');
// Check if cron error is displayed in errors section
$cron_last_run = \Drupal::state()->get('system.cron_last');
\Drupal::state()->set('system.cron_last', 0);
$this->drupalGet('admin/reports/status');
$css_selector_converter = new CssSelectorConverter();
$xpath = $css_selector_converter->toXPath('details.system-status-report__entry') . '//div[contains(text(), "Cron has not run recently")]';
$this->assertNotEmpty($this->xpath($xpath), 'Cron has not run recently error is being displayed.');
\Drupal::state()->set('system.cron_last', $cron_last_run);
}
}

View file

@ -0,0 +1,59 @@
<?php
namespace Drupal\Tests\system\Kernel\Migrate\d7;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
* Tests migration of Theme settings variables to configuration.
*
* @group system
*/
class MigrateThemeSettingsTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Install bartik theme.
\Drupal::service('theme_handler')->install(['bartik']);
// Install seven theme.
\Drupal::service('theme_handler')->install(['seven']);
$this->executeMigration('d7_theme_settings');
}
/**
* Tests migration of theme settings to variables to configuration.
*/
public function testMigrateThemeSettings() {
$config = $this->config('bartik.settings');
$this->assertSame('', $config->get('favicon.path'));
$this->assertTrue($config->get('favicon.use_default'));
$this->assertTrue($config->get('features.comment_user_picture'));
$this->assertTrue($config->get('features.comment_user_verification'));
$this->assertTrue($config->get('features.favicon'));
$this->assertTrue($config->get('features.node_user_picture'));
$this->assertFalse($config->get('features.logo'));
$this->assertTrue($config->get('features.name'));
$this->assertTrue($config->get('features.slogan'));
$this->assertSame('public://gnu.png', $config->get('logo.path'));
$this->assertFalse($config->get('logo.use_default'));
$config = $this->config('seven.settings');
$this->assertSame('', $config->get('favicon.path'));
$this->assertTrue($config->get('favicon.use_default'));
$this->assertFalse($config->get('features.comment_user_picture'));
$this->assertTrue($config->get('features.comment_user_verification'));
$this->assertTrue($config->get('features.favicon'));
$this->assertTrue($config->get('features.node_user_picture'));
$this->assertFalse($config->get('features.logo'));
$this->assertTrue($config->get('features.name'));
$this->assertTrue($config->get('features.slogan'));
$this->assertSame('', $config->get('logo.path'));
$this->assertTrue($config->get('logo.use_default'));
}
}

View file

@ -0,0 +1,65 @@
<?php
namespace Drupal\Tests\system\Kernel\Plugin\migrate\source\d7;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests D7 theme settings source plugin.
*
* @covers Drupal\system\Plugin\migrate\source\d7\ThemeSettings
*
* @group system
*/
class ThemeSettingsTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['system', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$value = [
'toggle_logo' => 1,
'toggle_name' => 1,
'toggle_slogan' => 1,
'toggle_node_user_picture' => 1,
'toggle_comment_user_picture' => 1,
'toggle_comment_user_verification' => 1,
'toggle_favicon' => 1,
'toggle_main_menu' => 1,
'toggle_secondary_menu' => 1,
'default_logo' => 1,
'logo_path' => ' ',
'logo_upload' => ' ',
'default_favicon' => 1,
'favicon_path' => ' ',
'favicon_upload' => ' ',
'scheme' => 'firehouse',
];
$tests[0]['source_data']['variable'] = [
[
'name' => 'theme_bartik_settings',
'value' => serialize($value),
],
];
// The expected results are nearly identical to the source data.
$tests[0]['expected_data'] = [
[
'name' => 'theme_bartik_settings',
'value' => $value,
],
];
return $tests;
}
}