Update to Drupal 8.2.2. For more information, see https://www.drupal.org/project/drupal/releases/8.2.2

This commit is contained in:
Pantheon Automation 2016-11-02 11:43:31 -07:00 committed by Greg Anderson
parent 23ffed3665
commit 507b45a0ed
378 changed files with 11434 additions and 5542 deletions

View file

@ -23,7 +23,7 @@ class AjaxTestController {
public static function dialogContents() {
// This is a regular render array; the keys do not have special meaning.
$content = array(
'#title' => 'AJAX Dialog contents',
'#title' => '<em>AJAX Dialog & contents</em>',
'content' => array(
'#markup' => 'Example message',
),

View file

@ -93,7 +93,7 @@ class AjaxTestDialogForm extends FormBase {
protected function dialog($is_modal = FALSE) {
$content = AjaxTestController::dialogContents();
$response = new AjaxResponse();
$title = $this->t('AJAX Dialog contents');
$title = $this->t('AJAX Dialog & contents');
// Attach the library necessary for using the Open(Modal)DialogCommand and
// set the attachments for this Ajax response.

View file

@ -0,0 +1,34 @@
<?php
namespace Drupal\condition_test\Plugin\Condition;
use Drupal\Core\Condition\ConditionPluginBase;
/**
* Provides a condition that has a no existing context.
*
* @Condition(
* id = "condition_test_no_existing_type",
* label = @Translation("No existing type"),
* context = {
* "no_existing_type" = @ContextDefinition("no_existing_type", label = @Translation("No existing type")),
* }
* )
*/
class ConditionTestNoExistingType extends ConditionPluginBase {
/**
* {@inheritdoc}
*/
public function evaluate() {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function summary() {
return $this->t('Condition that requires a non-existent context.');
}
}

View file

@ -674,14 +674,25 @@ function _entity_test_record_hooks($hook, $data) {
* Implements hook_entity_prepare_view().
*/
function entity_test_entity_prepare_view($entity_type, array $entities, array $displays) {
// Add a dummy field item attribute on field_test_text if it exists.
if ($entity_type == 'entity_test') {
foreach ($entities as $entity) {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
// Add a dummy field item attribute on field_test_text if it exists.
if ($entity->hasField('field_test_text') && $displays[$entity->bundle()]->getComponent('field_test_text')) {
foreach ($entity->get('field_test_text') as $item) {
$item->_attributes += array('data-field-item-attr' => 'foobar');
}
}
// Add a dummy field item attribute on daterange fields if they exist.
$fields = $entity->getFieldDefinitions();
foreach ($fields as $field) {
if ($field->getType() === 'daterange') {
$item = $entity->get($field->getName());
$item->_attributes += array('data-field-item-attr' => 'foobar');
}
}
}
}
}

View file

@ -358,6 +358,14 @@ form_test.label:
requirements:
_access: 'TRUE'
form_test.machine_name:
path: '/form-test/machine-name'
defaults:
_form: '\Drupal\form_test\Form\FormTestMachineNameForm'
_title: 'Machine name fields'
requirements:
_access: 'TRUE'
form_test.state_persistence:
path: '/form-test/state-persist'
defaults:

View file

@ -0,0 +1,63 @@
<?php
namespace Drupal\form_test\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
/**
* Form constructor for testing #type 'machine_name' elements.
*/
class FormTestMachineNameForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'form_test_machine_name';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['machine_name_1_label'] = [
'#type' => 'textfield',
'#title' => 'Machine name 1 label',
];
$form['machine_name_1'] = [
'#type' => 'machine_name',
'#title' => 'Machine name 1',
'#description' => 'A machine name.',
'#machine_name' => [
'source' => ['machine_name_1_label']
],
];
$form['machine_name_2_label'] = [
'#type' => 'textfield',
'#title' => 'Machine name 2 label',
];
$form['machine_name_2'] = [
'#type' => 'machine_name',
'#title' => 'Machine name 2',
'#description' => 'Another machine name.',
'#machine_name' => [
'source' => ['machine_name_2_label']
],
];
$form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state->setResponse(new JsonResponse($form_state->getValues()));
}
}

View file

@ -3,3 +3,7 @@
<div>link via the linkgenerator: {{ link('register', test_url_attribute, {'id': 'kitten'}) }}</div>
<div>link via the linkgenerator: {{ link('register', 'route:user.register', {'id': 'kitten'}) }}</div>
<div>link via the linkgenerator: {{ link('register', 'route:user.register', attributes) }}</div>
{% set title %}<span>register</span>{% endset %}
<div>link via the linkgenerator: {{ link(title, test_url) }}</div>
{% set title %}<span>register</span><svg></svg>{% endset %}
<div>link via the linkgenerator: {{ link(title, test_url) }}</div>

View file

@ -0,0 +1,36 @@
<?php
namespace Drupal\Tests\system\Kernel\Form;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\CssSelector\CssSelectorConverter;
/**
* Tests for form_element_label theme hook.
*
* @group Form
*/
class FormElementLabelTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['system'];
/**
* Ensures that attributes can be placed for form element label.
*/
public function testAttributes() {
$render_array = [
'#type' => 'label',
'#attributes' => ['class' => ['kitten']],
'#title' => 'Kittens',
'#title_display' => 'above',
];
$css_selector_converter = new CssSelectorConverter();
$this->render($render_array);
$elements = $this->xpath($css_selector_converter->toXPath('.kitten'));
$this->assertCount(1, $elements);
}
}

View file

@ -0,0 +1,39 @@
<?php
namespace Drupal\Tests\system\Kernel\Installer;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests that we handle the absence of a module dependency during install.
*
* @group Installer
*/
class InstallerMissingDependenciesTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['system'];
/**
* Verifies that the exception message in the profile step is correct.
*/
public function testSetUpWithMissingDependencies() {
// Prime the drupal_get_filename() static cache with the location of the
// testing profile as it is not the currently active profile and we don't
// yet have any cached way to retrieve its location.
// @todo Remove as part of https://www.drupal.org/node/2186491
drupal_get_filename('profile', 'testing_missing_dependencies', 'core/profiles/testing_missing_dependencies/testing_missing_dependencies.info.yml');
$info = drupal_verify_profile([
'parameters' => ['profile' => 'testing_missing_dependencies'],
'profile_info' => install_profile_info('testing_missing_dependencies'),
]);
$message = $info['required_modules']['description']->render();
$this->assertContains('Missing_module1', $message);
$this->assertContains('Missing_module2', $message);
}
}

View file

@ -1,6 +1,6 @@
<?php
namespace Drupal\Tests\system\Kernel\Migrate;
namespace Drupal\Tests\system\Kernel\Migrate\d6;
use Drupal\Core\Database\Database;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
@ -18,7 +18,7 @@ class MigrateMenuTest extends MigrateDrupal6TestBase {
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('menu');
$this->executeMigration('d6_menu');
}
/**
@ -26,12 +26,12 @@ class MigrateMenuTest extends MigrateDrupal6TestBase {
*/
public function testMenu() {
$navigation_menu = Menu::load('navigation');
$this->assertIdentical('navigation', $navigation_menu->id());
$this->assertIdentical('Navigation', $navigation_menu->label());
$this->assertSame('navigation', $navigation_menu->id());
$this->assertSame('Navigation', $navigation_menu->label());
$expected = <<<EOT
The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.
EOT;
$this->assertIdentical($expected, $navigation_menu->getDescription());
$this->assertSame($expected, $navigation_menu->getDescription());
// Test that we can re-import using the ConfigEntityBase destination.
Database::getConnection('default', 'migrate')
@ -40,14 +40,14 @@ EOT;
->condition('menu_name', 'navigation')
->execute();
$migration = $this->getMigration('menu');
$migration = $this->getMigration('d6_menu');
\Drupal::database()
->truncate($migration->getIdMap()->mapTableName())
->execute();
$this->executeMigration($migration);
$navigation_menu = Menu::load('navigation');
$this->assertIdentical('Home Navigation', $navigation_menu->label());
$this->assertSame('Home Navigation', $navigation_menu->label());
}
}

View file

@ -0,0 +1,68 @@
<?php
namespace Drupal\Tests\system\Kernel\Migrate\d7;
use Drupal\Core\Database\Database;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\system\Entity\Menu;
/**
* Upgrade menus to system.menu.*.yml.
*
* @group migrate_drupal_7
*/
class MigrateMenuTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d7_menu');
}
/**
* Asserts various aspects of a menu.
*
* @param $id
* The menu ID.
* @param $label
* The menu label.
* @param $description
* The menu description.
*/
protected function assertEntity($id, $label, $description) {
$navigation_menu = Menu::load($id);
$this->assertSame($id, $navigation_menu->id());
$this->assertSame($label, $navigation_menu->label());
$this->assertSame($description, $navigation_menu->getDescription());
}
/**
* Tests the Drupal 7 menu to Drupal 8 migration.
*/
public function testMenu() {
$this->assertEntity('main', 'Main menu', 'The <em>Main</em> menu is used on many sites to show the major sections of the site, often in a top navigation bar.');
$this->assertEntity('admin', 'Management', 'The <em>Management</em> menu contains links for administrative tasks.');
$this->assertEntity('menu-test-menu', 'Test Menu', 'Test menu description.');
$this->assertEntity('tools', 'Navigation', 'The <em>Navigation</em> menu contains links intended for site visitors. Links are added to the <em>Navigation</em> menu automatically by some modules.');
$this->assertEntity('account', 'User menu', 'The <em>User</em> menu contains links related to the user\'s account, as well as the \'Log out\' link.');
// Test that we can re-import using the ConfigEntityBase destination.
Database::getConnection('default', 'migrate')
->update('menu_custom')
->fields(array('title' => 'Home Navigation'))
->condition('menu_name', 'navigation')
->execute();
$migration = $this->getMigration('d7_menu');
\Drupal::database()
->truncate($migration->getIdMap()->mapTableName())
->execute();
$this->executeMigration($migration);
$navigation_menu = Menu::load('tools');
$this->assertSame('Home Navigation', $navigation_menu->label());
}
}

View file

@ -0,0 +1,47 @@
<?php
namespace Drupal\Tests\system\Kernel\Plugin\migrate\source;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests menu source plugin.
*
* @covers Drupal\system\Plugin\migrate\source\Menu
*
* @group system
*/
class MenuTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['system', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$tests[0]['source_data']['menu_custom'] = [
[
'menu_name' => 'menu-name-1',
'title' => 'menu custom value 1',
'description' => 'menu custom description value 1',
],
[
'menu_name' => 'menu-name-2',
'title' => 'menu custom value 2',
'description' => 'menu custom description value 2',
],
];
// The expected results are identical to the source data.
$tests[0]['expected_data'] = $tests[0]['source_data']['menu_custom'];
return $tests;
}
}

View file

@ -1,44 +0,0 @@
<?php
namespace Drupal\Tests\system\Unit\Plugin\migrate\source;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests menu source plugin.
*
* @group system
*/
class MenuTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\system\Plugin\migrate\source\Menu';
protected $migrationConfiguration = array(
'id' => 'test',
'source' => array(
'plugin' => 'menu',
),
);
protected $expectedResults = array(
array(
'menu_name' => 'menu-name-1',
'title' => 'menu custom value 1',
'description' => 'menu custom description value 1',
),
array(
'menu_name' => 'menu-name-2',
'title' => 'menu custom value 2',
'description' => 'menu custom description value 2',
),
);
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->databaseContents['menu_custom'] = $this->expectedResults;
parent::setUp();
}
}