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

@ -32,24 +32,27 @@ field.formatter.settings.daterange_default:
label: 'Date range default display format settings'
mapping:
separator:
type: string
type: label
label: 'Separator'
translation context: 'Date range separator'
field.formatter.settings.daterange_plain:
type: field.formatter.settings.datetime_plain
label: 'Date range plain display format settings'
mapping:
separator:
type: string
type: label
label: 'Separator'
translation context: 'Date range separator'
field.formatter.settings.daterange_custom:
type: field.formatter.settings.datetime_custom
label: 'Date range custom display format settings'
mapping:
separator:
type: string
type: label
label: 'Separator'
translation context: 'Date range separator'
field.widget.settings.daterange_datelist:
type: mapping

View file

@ -0,0 +1,22 @@
<?php
/**
* @file
* Post-update functions for Datetime Range module.
*/
/**
* @addtogroup updates-8.2.x
* @{
*/
/**
* Clear caches to ensure schema changes are read.
*/
function datetime_range_post_update_translatable_separator() {
// Empty post-update hook to cause a cache rebuild.
}
/**
* @} End of "addtogroup updates-8.2.x".
*/

View file

@ -58,13 +58,12 @@ class DateRangeDefaultFormatter extends DateTimeDefaultFormatter {
}
else {
$elements[$delta] = $this->buildDateWithIsoAttribute($start_date);
}
if (!empty($item->_attributes)) {
$elements[$delta]['#attributes'] += $item->_attributes;
// Unset field item attributes since they have been included in the
// formatter output and should not be rendered in the field template.
unset($item->_attributes);
if (!empty($item->_attributes)) {
$elements[$delta]['#attributes'] += $item->_attributes;
// Unset field item attributes since they have been included in the
// formatter output and should not be rendered in the field template.
unset($item->_attributes);
}
}
}
}

View file

@ -140,6 +140,11 @@ class DateRangeFieldTest extends DateTestBase {
]));
$this->assertText(' THESEPARATOR ', 'Found proper separator');
// Verify that hook_entity_prepare_view can add attributes.
// @see entity_test_entity_prepare_view()
$this->drupalGet('entity_test/' . $id);
$this->assertFieldByXPath('//div[@data-field-item-attr="foobar"]');
// Verify that the plain formatter works.
$this->displayOptions['type'] = 'daterange_plain';
$this->displayOptions['settings'] = $this->defaultSettings;
@ -203,6 +208,11 @@ class DateRangeFieldTest extends DateTestBase {
]));
$this->assertNoText(' THESEPARATOR ', 'Separator not found on page');
// Verify that hook_entity_prepare_view can add attributes.
// @see entity_test_entity_prepare_view()
$this->drupalGet('entity_test/' . $id);
$this->assertFieldByXPath('//time[@data-field-item-attr="foobar"]');
$this->displayOptions['type'] = 'daterange_plain';
$this->displayOptions['settings'] = $this->defaultSettings;
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
@ -289,6 +299,11 @@ class DateRangeFieldTest extends DateTestBase {
$this->assertFieldByXPath('//time[@datetime="' . $end_expected_iso . '"]', $end_expected, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $end_expected, '%expected_iso' => $end_expected_iso]));
$this->assertText(' THESEPARATOR ', 'Found proper separator');
// Verify that hook_entity_prepare_view can add attributes.
// @see entity_test_entity_prepare_view()
$this->drupalGet('entity_test/' . $id);
$this->assertFieldByXPath('//div[@data-field-item-attr="foobar"]');
// Verify that the plain formatter works.
$this->displayOptions['type'] = 'daterange_plain';
$this->displayOptions['settings'] = $this->defaultSettings;
@ -360,6 +375,11 @@ class DateRangeFieldTest extends DateTestBase {
$this->assertFieldByXPath('//time[@datetime="' . $start_expected_iso . '"]', $start_expected, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $start_expected, '%expected_iso' => $start_expected_iso]));
$this->assertNoText(' THESEPARATOR ', 'Separator not found on page');
// Verify that hook_entity_prepare_view can add attributes.
// @see entity_test_entity_prepare_view()
$this->drupalGet('entity_test/' . $id);
$this->assertFieldByXPath('//time[@data-field-item-attr="foobar"]');
$this->displayOptions['type'] = 'daterange_plain';
$this->displayOptions['settings'] = $this->defaultSettings;
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
@ -440,6 +460,11 @@ class DateRangeFieldTest extends DateTestBase {
$this->assertFieldByXPath('//time[@datetime="' . $end_expected_iso . '"]', $end_expected, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $end_expected, '%expected_iso' => $end_expected_iso]));
$this->assertText(' THESEPARATOR ', 'Found proper separator');
// Verify that hook_entity_prepare_view can add attributes.
// @see entity_test_entity_prepare_view()
$this->drupalGet('entity_test/' . $id);
$this->assertFieldByXPath('//div[@data-field-item-attr="foobar"]');
// Verify that the plain formatter works.
$this->displayOptions['type'] = 'daterange_plain';
$this->displayOptions['settings'] = $this->defaultSettings;
@ -513,6 +538,11 @@ class DateRangeFieldTest extends DateTestBase {
$this->assertFieldByXPath('//time[@datetime="' . $end_expected_iso . '"]', $end_expected, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => 'long', '%expected' => $end_expected, '%expected_iso' => $end_expected_iso]));
$this->assertText(' THESEPARATOR ', 'Found proper separator');
// Verify that hook_entity_prepare_view can add attributes.
// @see entity_test_entity_prepare_view()
$this->drupalGet('entity_test/' . $id);
$this->assertFieldByXPath('//div[@data-field-item-attr="foobar"]');
$this->displayOptions['type'] = 'daterange_plain';
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)

View file

@ -0,0 +1,131 @@
<?php
namespace Drupal\Tests\datetime_range\Kernel;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Core\Language\Language;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\KernelTests\KernelTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
/**
* Test to ensure the datetime range separator is translatable.
*
* @group datetime
*/
class SeparatorTranslationTest extends KernelTestBase {
/**
* A field storage to use in this test class.
*
* @var \Drupal\field\Entity\FieldStorageConfig
*/
protected $fieldStorage;
/**
* The field used in this test class.
*
* @var \Drupal\field\Entity\FieldConfig
*/
protected $field;
/**
* {@inheritdoc}
*/
public static $modules = [
'datetime',
'datetime_range',
'entity_test',
'field',
'language',
'system',
'user',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('entity_test');
$this->installEntitySchema('user');
$this->installConfig(['system']);
$this->installSchema('system', ['sequences', 'key_value']);
// Add a datetime range field.
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => Unicode::strtolower($this->randomMachineName()),
'entity_type' => 'entity_test',
'type' => 'daterange',
'settings' => ['datetime_type' => DateTimeItem::DATETIME_TYPE_DATE],
]);
$this->fieldStorage->save();
$this->field = FieldConfig::create([
'field_storage' => $this->fieldStorage,
'bundle' => 'entity_test',
'required' => TRUE,
]);
$this->field->save();
$display_options = [
'type' => 'daterange_default',
'label' => 'hidden',
'settings' => [
'format_type' => 'fallback',
'separator' => 'UNTRANSLATED',
],
];
EntityViewDisplay::create([
'targetEntityType' => $this->field->getTargetEntityTypeId(),
'bundle' => $this->field->getTargetBundle(),
'mode' => 'default',
'status' => TRUE,
])->setComponent($this->fieldStorage->getName(), $display_options)
->save();
}
/**
* Tests the translation of the range separator.
*/
public function testSeparatorTranslation() {
// Create an entity.
$entity = EntityTest::create([
'name' => $this->randomString(),
$this->fieldStorage->getName() => [
'value' => '2016-09-20',
'end_value' => '2016-09-21',
],
]);
// Verify the untranslated separator.
$display = EntityViewDisplay::collectRenderDisplay($entity, 'default');
$build = $display->build($entity);
$output = $this->container->get('renderer')->renderRoot($build);
$this->verbose($output);
$this->assertContains('UNTRANSLATED', (string) $output);
// Translate the separator.
ConfigurableLanguage::createFromLangcode('nl')->save();
/** @var \Drupal\language\ConfigurableLanguageManagerInterface $language_manager */
$language_manager = $this->container->get('language_manager');
$language_manager->getLanguageConfigOverride('nl', 'core.entity_view_display.entity_test.entity_test.default')
->set('content.' . $this->fieldStorage->getName() . '.settings.separator', 'NL_TRANSLATED!')
->save();
$this->container->get('language.config_factory_override')
->setLanguage(new Language(['id' => 'nl']));
$this->container->get('cache_tags.invalidator')->invalidateTags($entity->getCacheTags());
$display = EntityViewDisplay::collectRenderDisplay($entity, 'default');
$build = $display->build($entity);
$output = $this->container->get('renderer')->renderRoot($build);
$this->verbose($output);
$this->assertContains('NL_TRANSLATED!', (string) $output);
}
}