Commit 56550826 authored by Gábor Hojtsy's avatar Gábor Hojtsy

Issue #3019202 by g_miric, seanB, xjm, Wim Leers, phenaproxima, marcoscano:...

Issue #3019202 by g_miric, seanB, xjm, Wim Leers, phenaproxima, marcoscano: Rename "File" media type to "Document"
parent 76fa7e95
......@@ -80,10 +80,10 @@ public function testFileMediaRevision() {
$uri = 'temporary://foo.txt';
file_put_contents($uri, $this->randomString(128));
$this->createMediaType('file', ['id' => 'file', 'new_revision' => TRUE]);
$this->createMediaType('file', ['id' => 'document', 'new_revision' => TRUE]);
// Create a media item.
$this->drupalGet('/media/add/file');
$this->drupalGet('/media/add/document');
$page = $this->getSession()->getPage();
$page->fillField('Name', 'Foobar');
$page->attachFileToField('File', $this->container->get('file_system')->realpath($uri));
......
......@@ -109,8 +109,8 @@ public function testMediaDisplay() {
$test_filename = $this->randomMachineName() . '.txt';
$test_filepath = 'public://' . $test_filename;
file_put_contents($test_filepath, $this->randomMachineName());
$this->drupalGet("media/add/file");
$page->attachFileToField("files[field_media_file_0]", \Drupal::service('file_system')->realpath($test_filepath));
$this->drupalGet("media/add/document");
$page->attachFileToField("files[field_media_document_0]", \Drupal::service('file_system')->realpath($test_filepath));
$result = $assert_session->waitForButton('Remove');
$this->assertNotEmpty($result);
$page->pressButton('Save');
......@@ -122,10 +122,10 @@ public function testMediaDisplay() {
$assert_session->elementTextContains('css', 'h1', $test_filename);
// Here we expect to see only the linked filename.
// Assert only one element in the content region.
$this->assertSame(1, count($page->findAll('css', 'article.media--type-file > div')));
$this->assertSame(1, count($page->findAll('css', 'article.media--type-document > div')));
// Assert the file link is present, and its text matches the filename.
$assert_session->elementExists('css', 'article.media--type-file .field--name-field-media-file a');
$link = $page->find('css', 'article.media--type-file .field--name-field-media-file a');
$assert_session->elementExists('css', 'article.media--type-document .field--name-field-media-document a');
$link = $page->find('css', 'article.media--type-document .field--name-field-media-document a');
$this->assertSame($test_filename, $link->getText());
// Create a node type "page" to use as host entity.
......
......@@ -56,11 +56,11 @@ public function testMediaSources() {
'settings' => [
'handler_settings' => [
'target_bundles' => [
'audio' => 'audio',
'document' => 'document',
'image' => 'image',
'video' => 'video',
'remote_video' => 'remote_video',
'audio' => 'audio',
'file' => 'file',
'video' => 'video',
],
],
],
......@@ -75,7 +75,7 @@ public function testMediaSources() {
])->save();
$this->audioTest();
$this->fileTest();
$this->documentTest();
$this->imageTest();
$this->remoteVideoTest();
$this->videoTest();
......@@ -260,12 +260,12 @@ protected function imageTest() {
}
/**
* Test the standard profile configuration for media type 'file'.
* Test the standard profile configuration for media type 'document'.
*/
protected function fileTest() {
protected function documentTest() {
$assert_session = $this->assertSession();
$page = $this->getSession()->getPage();
$source_field_id = 'field_media_file';
$source_field_id = 'field_media_document';
// Create 2 test files.
$test_filename = $this->randomMachineName() . '.txt';
......@@ -276,7 +276,7 @@ protected function fileTest() {
file_put_contents($test_filepath_updated, $this->randomMachineName());
// Check if the name field is properly hidden on the media form.
$this->drupalGet('media/add/file');
$this->drupalGet('media/add/document');
$assert_session->fieldNotExists('name');
// Check if the source field is available.
......@@ -314,11 +314,11 @@ protected function fileTest() {
// Here we expect to see only the linked filename. Assert only one element
// in the content region.
$assert_session->elementsCount('css', 'article.media--type-file > *', 1);
$assert_session->elementsCount('css', 'article.media--type-document > *', 1);
// Assert the file link is present in the media element and its text matches
// the filename.
$link_element = $assert_session->elementExists('css', 'article.media--type-file .field--name-field-media-file a');
$link_element = $assert_session->elementExists('css', 'article.media--type-document .field--name-field-media-document a');
$this->assertSame($test_filename, $link_element->getText());
// Assert the media name is updated through the field mapping when changing
......@@ -340,11 +340,11 @@ protected function fileTest() {
// Again we expect to see only the linked filename. Assert only one element
// in the content region.
$assert_session->elementsCount('css', 'article.media--type-file > *', 1);
$assert_session->elementsCount('css', 'article.media--type-document > *', 1);
// Assert the file link is present in the media element and its text matches
// the updated filename.
$link_element = $assert_session->elementExists('css', 'article.media--type-file .field--name-field-media-file a');
$link_element = $assert_session->elementExists('css', 'article.media--type-document .field--name-field-media-document a');
$this->assertSame($test_filename_updated, $link_element->getText());
}
......
......@@ -3,16 +3,16 @@ status: true
dependencies:
config:
- core.entity_form_mode.media.media_library
- field.field.media.file.field_media_file
- media.type.file
id: media.file.media_library
- field.field.media.document.field_media_document
- media.type.document
id: media.document.media_library
targetEntityType: media
bundle: file
bundle: document
mode: media_library
content: { }
hidden:
created: true
field_media_file: true
field_media_document: true
name: true
path: true
status: true
......
......@@ -3,14 +3,14 @@ status: true
dependencies:
config:
- core.entity_view_mode.media.media_library
- field.field.media.file.field_media_file
- field.field.media.document.field_media_document
- image.style.thumbnail
- media.type.file
- media.type.document
module:
- image
id: media.file.media_library
id: media.document.media_library
targetEntityType: media
bundle: file
bundle: document
mode: media_library
content:
thumbnail:
......@@ -24,6 +24,6 @@ content:
third_party_settings: { }
hidden:
created: true
field_media_file: true
field_media_document: true
name: true
uid: true
......@@ -54,7 +54,7 @@ protected function setUp() {
]);
// Create some media types to validate against.
$this->createMediaType('file', ['id' => 'file']);
$this->createMediaType('file', ['id' => 'document']);
$this->createMediaType('image', ['id' => 'image']);
$this->createMediaType('video_file', ['id' => 'video']);
}
......@@ -64,7 +64,7 @@ protected function setUp() {
*/
public function testMethods() {
$opener_id = 'test';
$allowed_media_type_ids = ['file', 'image'];
$allowed_media_type_ids = ['document', 'image'];
$selected_media_type_id = 'image';
$remaining_slots = 2;
......@@ -118,7 +118,7 @@ public function providerCreate() {
// Assert no exception is thrown when we add the parameters as expected.
$test_data['valid parameters'] = [
'test',
['file', 'image'],
['document', 'image'],
'image',
2,
];
......@@ -126,7 +126,7 @@ public function providerCreate() {
// Assert an exception is thrown when the opener ID parameter is empty.
$test_data['empty opener ID'] = [
'',
['file', 'image'],
['document', 'image'],
'image',
2,
'The opener ID parameter is required and must be a string.',
......@@ -135,21 +135,21 @@ public function providerCreate() {
// valid string.
$test_data['integer opener ID'] = [
1,
['file', 'image'],
['document', 'image'],
'image',
2,
'The opener ID parameter is required and must be a string.',
];
$test_data['boolean opener ID'] = [
TRUE,
['file', 'image'],
['document', 'image'],
'image',
2,
'The opener ID parameter is required and must be a string.',
];
$test_data['spaces opener ID'] = [
' ',
['file', 'image'],
['document', 'image'],
'image',
2,
'The opener ID parameter is required and must be a string.',
......@@ -192,7 +192,7 @@ public function providerCreate() {
// Assert an exception is thrown when the selected type parameter is empty.
$test_data['empty selected type'] = [
'test',
['file', 'image'],
['document', 'image'],
'',
2,
'The selected type parameter is required and must be a string.',
......@@ -201,21 +201,21 @@ public function providerCreate() {
// valid string.
$test_data['numeric selected type'] = [
'test',
['file', 'image'],
['document', 'image'],
1,
2,
'The selected type parameter is required and must be a string.',
];
$test_data['boolean selected type'] = [
'test',
['file', 'image'],
['document', 'image'],
TRUE,
2,
'The selected type parameter is required and must be a string.',
];
$test_data['spaces selected type'] = [
'test',
['file', 'image'],
['document', 'image'],
' ',
2,
'The selected type parameter is required and must be a string.',
......@@ -224,7 +224,7 @@ public function providerCreate() {
// the list of allowed types.
$test_data['non-present selected type'] = [
'test',
['file', 'image'],
['document', 'image'],
'video',
2,
'The selected type parameter must be present in the list of allowed types.',
......@@ -234,7 +234,7 @@ public function providerCreate() {
// empty.
$test_data['empty remaining slots'] = [
'test',
['file', 'image'],
['document', 'image'],
'image',
'',
'The remaining slots parameter is required and must be numeric.',
......@@ -243,14 +243,14 @@ public function providerCreate() {
// not numeric.
$test_data['string remaining slots'] = [
'test',
['file', 'image'],
['document', 'image'],
'image',
'fail',
'The remaining slots parameter is required and must be numeric.',
];
$test_data['boolean remaining slots'] = [
'test',
['file', 'image'],
['document', 'image'],
'image',
TRUE,
'The remaining slots parameter is required and must be numeric.',
......
......@@ -2,14 +2,14 @@ langcode: en
status: true
dependencies:
config:
- field.field.media.file.field_media_file
- media.type.file
- field.field.media.document.field_media_document
- media.type.document
module:
- file
- path
id: media.file.default
id: media.document.default
targetEntityType: media
bundle: file
bundle: document
mode: default
content:
created:
......@@ -18,7 +18,7 @@ content:
region: content
settings: { }
third_party_settings: { }
field_media_file:
field_media_document:
settings:
progress_indicator: throbber
third_party_settings: { }
......
......@@ -2,16 +2,16 @@ langcode: en
status: true
dependencies:
config:
- field.field.media.file.field_media_file
- media.type.file
- field.field.media.document.field_media_document
- media.type.document
module:
- file
id: media.file.default
id: media.document.default
targetEntityType: media
bundle: file
bundle: document
mode: default
content:
field_media_file:
field_media_document:
label: visually_hidden
settings: { }
third_party_settings: { }
......
......@@ -2,18 +2,18 @@ langcode: en
status: true
dependencies:
config:
- field.storage.media.field_media_file
- media.type.file
- field.storage.media.field_media_document
- media.type.document
enforced:
module:
- media
module:
- file
id: media.file.field_media_file
field_name: field_media_file
id: media.document.field_media_document
field_name: field_media_document
entity_type: media
bundle: file
label: File
bundle: document
label: Document
description: ''
required: true
translatable: true
......
......@@ -7,8 +7,8 @@ dependencies:
module:
- file
- media
id: media.field_media_file
field_name: field_media_file
id: media.field_media_document
field_name: field_media_document
entity_type: media
type: file
settings:
......
langcode: en
status: true
dependencies: { }
id: file
label: File
description: "Use local files for reusable media."
id: document
label: Document
description: "An uploaded file or document, such as a PDF."
source: file
queue_thumbnail_downloads: false
new_revision: true
source_configuration:
source_field: field_media_file
source_field: field_media_document
field_map:
name: name
......@@ -2,13 +2,13 @@ langcode: en
status: true
dependencies:
config:
- field.field.media.file.field_media_file
- media.type.file
- field.field.media.document.field_media_document
- media.type.document
module:
- file
id: media.file.default
id: media.document.default
targetEntityType: media
bundle: file
bundle: document
mode: default
content:
created:
......@@ -17,7 +17,7 @@ content:
region: content
settings: { }
third_party_settings: { }
field_media_file:
field_media_document:
settings:
progress_indicator: throbber
third_party_settings: { }
......
......@@ -2,16 +2,16 @@ langcode: en
status: true
dependencies:
config:
- field.field.media.file.field_media_file
- media.type.file
- field.field.media.document.field_media_document
- media.type.document
module:
- file
id: media.file.default
id: media.document.default
targetEntityType: media
bundle: file
bundle: document
mode: default
content:
field_media_file:
field_media_document:
label: visually_hidden
settings: { }
third_party_settings: { }
......
......@@ -2,18 +2,18 @@ langcode: en
status: true
dependencies:
config:
- field.storage.media.field_media_file
- media.type.file
- field.storage.media.field_media_document
- media.type.document
enforced:
module:
- media
module:
- file
id: media.file.field_media_file
field_name: field_media_file
id: media.document.field_media_document
field_name: field_media_document
entity_type: media
bundle: file
label: File
bundle: document
label: Document
description: ''
required: true
translatable: true
......
......@@ -7,8 +7,8 @@ dependencies:
module:
- file
- media
id: media.field_media_file
field_name: field_media_file
id: media.field_media_document
field_name: field_media_document
entity_type: media
type: file
settings:
......
langcode: en
status: true
dependencies: { }
id: file
label: File
description: "Use local files for reusable media."
id: document
label: Document
description: "An uploaded file or document, such as a PDF."
source: file
queue_thumbnail_downloads: false
new_revision: true
source_configuration:
source_field: field_media_file
source_field: field_media_document
field_map:
name: name
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment