updated core and modules

This commit is contained in:
Bachir Soussi Chiadmi
2017-09-09 16:27:51 +02:00
parent 027aa99b32
commit 41863f872c
7810 changed files with 318922 additions and 83631 deletions
@@ -5,8 +5,8 @@ description: 'Support module for the Quick Edit module tests.'
package: Testing
# version: VERSION
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233790
datestamp: 1502903957
@@ -12,9 +12,22 @@ use Drupal\Core\Entity\EntityInterface;
*/
function quickedit_test_quickedit_render_field(EntityInterface $entity, $field_name, $view_mode_id, $langcode) {
$entity = \Drupal::entityManager()->getTranslationFromContext($entity, $langcode);
return array(
return [
'#prefix' => '<div class="quickedit-test-wrapper">',
'field' => $entity->get($field_name)->view($view_mode_id),
'#suffix' => '</div>',
);
];
}
/**
* Implements hook_field_formatter_info_alter().
*
* @see quickedit_field_formatter_info_alter()
* @see editor_field_formatter_info_alter()
*/
function quickedit_test_field_formatter_info_alter(&$info) {
// Update \Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter's
// annotation to indicate that it supports the 'wysiwyg' in-place editor
// provided by this module.
$info['text_default']['quickedit'] = ['editor' => 'wysiwyg'];
}
@@ -10,7 +10,6 @@ use Drupal\quickedit\Plugin\InPlaceEditorBase;
*
* @InPlaceEditor(
* id = "wysiwyg",
* alternativeTo = {"plain_text"}
* )
*/
class WysiwygEditor extends InPlaceEditorBase {
@@ -28,12 +27,7 @@ class WysiwygEditor extends InPlaceEditorBase {
// This editor is compatible with formatted ("rich") text fields; but only
// if there is a currently active text format and that text format is the
// 'full_html' text format.
elseif (in_array($field_definition->getType(), array('text', 'text_long', 'text_with_summary'), TRUE)) {
if ($items[0]->format === 'full_html') {
return TRUE;
}
return FALSE;
}
return $items[0]->format === 'full_html';
}
/**
@@ -48,11 +42,11 @@ class WysiwygEditor extends InPlaceEditorBase {
* {@inheritdoc}
*/
public function getAttachments() {
return array(
'library' => array(
return [
'library' => [
'quickedit_test/not-existing-wysiwyg',
),
);
],
];
}
}
@@ -37,7 +37,9 @@ class EditorSelectionTest extends QuickEditTestBase {
* Returns the in-place editor that Quick Edit selects.
*/
protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'default') {
$entity = entity_load('entity_test', $entity_id, TRUE);
$storage = $this->container->get('entity_type.manager')->getStorage('entity_test');
$storage->resetCache([$entity_id]);
$entity = $storage->load($entity_id);
$items = $entity->get($field_name);
$options = entity_get_display('entity_test', 'entity_test', $view_mode)->getComponent($field_name);
return $this->editorSelector->getEditor($options['type'], $items);
@@ -51,13 +53,13 @@ class EditorSelectionTest extends QuickEditTestBase {
$this->createFieldWithStorage(
$field_name, 'string', 1, 'Simple text field',
// Instance settings.
array(),
[],
// Widget type & settings.
'string_textfield',
array('size' => 42),
['size' => 42],
// 'default' formatter type & settings.
'string',
array()
[]
);
// Create an entity with values for this text field.
@@ -82,7 +84,7 @@ class EditorSelectionTest extends QuickEditTestBase {
*/
public function testTextWysiwyg() {
// Enable edit_test module so that the 'wysiwyg' editor becomes available.
$this->enableModules(array('quickedit_test'));
$this->enableModules(['quickedit_test']);
$this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
$this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
@@ -90,13 +92,13 @@ class EditorSelectionTest extends QuickEditTestBase {
$this->createFieldWithStorage(
$field_name, 'text', 1, 'Long text field',
// Instance settings.
array(),
[],
// Widget type & settings.
'text_textarea',
array('size' => 42),
['size' => 42],
// 'default' formatter type & settings.
'text_default',
array()
[]
);
// Create an entity with values for this text field.
@@ -127,13 +129,13 @@ class EditorSelectionTest extends QuickEditTestBase {
$this->createFieldWithStorage(
$field_name, 'integer', 1, 'Simple number field',
// Instance settings.
array(),
[],
// Widget type & settings.
'number',
array(),
[],
// 'default' formatter type & settings.
'number_integer',
array()
[]
);
// Create an entity with values for this text field.
@@ -18,7 +18,7 @@ class MetadataGeneratorTest extends QuickEditTestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('quickedit_test');
public static $modules = ['quickedit_test'];
/**
* The manager for editor plugins.
@@ -66,26 +66,26 @@ class MetadataGeneratorTest extends QuickEditTestBase {
$this->createFieldWithStorage(
$field_1_name, 'string', 1, $field_1_label,
// Instance settings.
array(),
[],
// Widget type & settings.
'string_textfield',
array('size' => 42),
['size' => 42],
// 'default' formatter type & settings.
'string',
array()
[]
);
$field_2_name = 'field_nr';
$field_2_label = 'Simple number field';
$this->createFieldWithStorage(
$field_2_name, 'integer', 1, $field_2_label,
// Instance settings.
array(),
[],
// Widget type & settings.
'number',
array(),
[],
// 'default' formatter type & settings.
'number_integer',
array()
[]
);
// Create an entity with values for this text field.
@@ -93,26 +93,26 @@ class MetadataGeneratorTest extends QuickEditTestBase {
$entity->{$field_1_name}->value = 'Test';
$entity->{$field_2_name}->value = 42;
$entity->save();
$entity = entity_load('entity_test', $entity->id());
$entity = EntityTest::load($entity->id());
// Verify metadata for field 1.
$items_1 = $entity->get($field_1_name);
$metadata_1 = $this->metadataGenerator->generateFieldMetadata($items_1, 'default');
$expected_1 = array(
$expected_1 = [
'access' => TRUE,
'label' => 'Plain text field',
'editor' => 'plain_text',
);
];
$this->assertEqual($expected_1, $metadata_1, 'The correct metadata is generated for the first field.');
// Verify metadata for field 2.
$items_2 = $entity->get($field_2_name);
$metadata_2 = $this->metadataGenerator->generateFieldMetadata($items_2, 'default');
$expected_2 = array(
$expected_2 = [
'access' => TRUE,
'label' => 'Simple number field',
'editor' => 'form',
);
];
$this->assertEqual($expected_2, $metadata_2, 'The correct metadata is generated for the second field.');
}
@@ -134,24 +134,24 @@ class MetadataGeneratorTest extends QuickEditTestBase {
$this->createFieldWithStorage(
$field_name, 'text', 1, $field_label,
// Instance settings.
array(),
[],
// Widget type & settings.
'text_textfield',
array('size' => 42),
['size' => 42],
// 'default' formatter type & settings.
'text_default',
array()
[]
);
// Create a text format.
$full_html_format = FilterFormat::create(array(
$full_html_format = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
'weight' => 1,
'filters' => array(
'filter_htmlcorrector' => array('status' => 1),
),
));
'filters' => [
'filter_htmlcorrector' => ['status' => 1],
],
]);
$full_html_format->save();
// Create an entity with values for this rich text field.
@@ -159,19 +159,19 @@ class MetadataGeneratorTest extends QuickEditTestBase {
$entity->{$field_name}->value = 'Test';
$entity->{$field_name}->format = 'full_html';
$entity->save();
$entity = entity_load('entity_test', $entity->id());
$entity = EntityTest::load($entity->id());
// Verify metadata.
$items = $entity->get($field_name);
$metadata = $this->metadataGenerator->generateFieldMetadata($items, 'default');
$expected = array(
$expected = [
'access' => TRUE,
'label' => 'Rich text field',
'editor' => 'wysiwyg',
'custom' => array(
'custom' => [
'format' => 'full_html'
),
);
],
];
$this->assertEqual($expected, $metadata); //, 'The correct metadata (including custom metadata) is generated.');
}
@@ -37,11 +37,11 @@ abstract class QuickEditTestBase extends KernelTestBase {
protected function setUp() {
parent::setUp();
$this->fields = new \ArrayObject(array(), \ArrayObject::ARRAY_AS_PROPS);
$this->fields = new \ArrayObject([], \ArrayObject::ARRAY_AS_PROPS);
$this->installEntitySchema('user');
$this->installEntitySchema('entity_test');
$this->installConfig(array('field', 'filter'));
$this->installConfig(['field', 'filter']);
}
/**
@@ -67,12 +67,12 @@ abstract class QuickEditTestBase extends KernelTestBase {
*/
protected function createFieldWithStorage($field_name, $type, $cardinality, $label, $field_settings, $widget_type, $widget_settings, $formatter_type, $formatter_settings) {
$field_storage = $field_name . '_field_storage';
$this->fields->$field_storage = FieldStorageConfig::create(array(
$this->fields->$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => $type,
'cardinality' => $cardinality,
));
]);
$this->fields->$field_storage->save();
$field = $field_name . '_field';
@@ -87,18 +87,18 @@ abstract class QuickEditTestBase extends KernelTestBase {
$this->fields->$field->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($field_name, array(
->setComponent($field_name, [
'type' => $widget_type,
'settings' => $widget_settings,
))
])
->save();
entity_get_display('entity_test', 'entity_test', 'default')
->setComponent($field_name, array(
->setComponent($field_name, [
'label' => 'above',
'type' => $formatter_type,
'settings' => $formatter_settings
))
])
->save();
}
@@ -43,11 +43,11 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
* @see \Drupal\Tests\edit\Unit\quickedit\Access\EditEntityFieldAccessCheckTest::testAccess()
*/
public function providerTestAccess() {
$data = array();
$data[] = array(TRUE, TRUE, AccessResult::allowed());
$data[] = array(FALSE, TRUE, AccessResult::neutral());
$data[] = array(TRUE, FALSE, AccessResult::neutral());
$data[] = array(FALSE, FALSE, AccessResult::neutral());
$data = [];
$data[] = [TRUE, TRUE, AccessResult::allowed()];
$data[] = [FALSE, TRUE, AccessResult::neutral()];
$data[] = [TRUE, FALSE, AccessResult::neutral()];
$data[] = [FALSE, FALSE, AccessResult::neutral()];
return $data;
}
@@ -108,15 +108,15 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
* Provides test data for testAccessForbidden.
*/
public function providerTestAccessForbidden() {
$data = array();
$data = [];
// Tests the access method without a field_name.
$data[] = array(NULL, LanguageInterface::LANGCODE_NOT_SPECIFIED);
$data[] = [NULL, LanguageInterface::LANGCODE_NOT_SPECIFIED];
// Tests the access method with a non-existent field.
$data[] = array('not_valid', LanguageInterface::LANGCODE_NOT_SPECIFIED);
$data[] = ['not_valid', LanguageInterface::LANGCODE_NOT_SPECIFIED];
// Tests the access method without a langcode.
$data[] = array('valid', NULL);
$data[] = ['valid', NULL];
// Tests the access method with an invalid langcode.
$data[] = array('valid', 'xx-lolspeak');
$data[] = ['valid', 'xx-lolspeak'];
return $data;
}
@@ -132,16 +132,16 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
$entity->expects($this->any())
->method('hasTranslation')
->will($this->returnValueMap(array(
array(LanguageInterface::LANGCODE_NOT_SPECIFIED, TRUE),
array('xx-lolspeak', FALSE),
)));
->will($this->returnValueMap([
[LanguageInterface::LANGCODE_NOT_SPECIFIED, TRUE],
['xx-lolspeak', FALSE],
]));
$entity->expects($this->any())
->method('hasField')
->will($this->returnValueMap(array(
array('valid', TRUE),
array('not_valid', FALSE),
)));
->will($this->returnValueMap([
['valid', TRUE],
['not_valid', FALSE],
]));
return $entity;
}