Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -12,11 +12,11 @@ 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>',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,11 +42,11 @@ class WysiwygEditor extends InPlaceEditorBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAttachments() {
|
||||
return array(
|
||||
'library' => array(
|
||||
return [
|
||||
'library' => [
|
||||
'quickedit_test/not-existing-wysiwyg',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,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.
|
||||
|
@ -84,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'));
|
||||
|
||||
|
@ -92,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.
|
||||
|
@ -129,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.
|
||||
|
@ -98,21 +98,21 @@ class MetadataGeneratorTest extends QuickEditTestBase {
|
|||
// 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.
|
||||
|
@ -164,14 +164,14 @@ class MetadataGeneratorTest extends QuickEditTestBase {
|
|||
// 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;
|
||||
}
|
||||
|
|
Reference in a new issue