summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2018-06-22 19:13:40 (GMT)
committerwebchick2018-06-22 19:13:40 (GMT)
commit41c3a88e35dcc1c5c628769264922aa1e13d98be (patch)
tree3ac8de68337de0dd5795a8fa5cb1ed7299287a34
parentd4350e2b1ef7d92b9028dd302383955314b15a6c (diff)
Issue #2980864 by chr.fritsch, phenaproxima, marcoscano: Position of "published" checkbox varies by media type
-rw-r--r--core/profiles/standard/config/optional/core.entity_form_display.media.audio.default.yml8
-rw-r--r--core/profiles/standard/config/optional/core.entity_form_display.media.video.default.yml8
-rw-r--r--core/profiles/standard/tests/src/Functional/StandardTest.php34
3 files changed, 42 insertions, 8 deletions
diff --git a/core/profiles/standard/config/optional/core.entity_form_display.media.audio.default.yml b/core/profiles/standard/config/optional/core.entity_form_display.media.audio.default.yml
index b3f5f64..2897993 100644
--- a/core/profiles/standard/config/optional/core.entity_form_display.media.audio.default.yml
+++ b/core/profiles/standard/config/optional/core.entity_form_display.media.audio.default.yml
@@ -14,7 +14,7 @@ mode: default
content:
created:
type: datetime_timestamp
- weight: 3
+ weight: 10
region: content
settings: { }
third_party_settings: { }
@@ -35,7 +35,7 @@ content:
third_party_settings: { }
path:
type: path
- weight: 4
+ weight: 30
region: content
settings: { }
third_party_settings: { }
@@ -43,12 +43,12 @@ content:
type: boolean_checkbox
settings:
display_label: true
- weight: 5
+ weight: 100
region: content
third_party_settings: { }
uid:
type: entity_reference_autocomplete
- weight: 2
+ weight: 5
settings:
match_operator: CONTAINS
size: 60
diff --git a/core/profiles/standard/config/optional/core.entity_form_display.media.video.default.yml b/core/profiles/standard/config/optional/core.entity_form_display.media.video.default.yml
index 658648f..d0fa504 100644
--- a/core/profiles/standard/config/optional/core.entity_form_display.media.video.default.yml
+++ b/core/profiles/standard/config/optional/core.entity_form_display.media.video.default.yml
@@ -14,7 +14,7 @@ mode: default
content:
created:
type: datetime_timestamp
- weight: 3
+ weight: 10
region: content
settings: { }
third_party_settings: { }
@@ -35,7 +35,7 @@ content:
third_party_settings: { }
path:
type: path
- weight: 4
+ weight: 30
region: content
settings: { }
third_party_settings: { }
@@ -43,12 +43,12 @@ content:
type: boolean_checkbox
settings:
display_label: true
- weight: 5
+ weight: 100
region: content
third_party_settings: { }
uid:
type: entity_reference_autocomplete
- weight: 2
+ weight: 5
settings:
match_operator: CONTAINS
size: 60
diff --git a/core/profiles/standard/tests/src/Functional/StandardTest.php b/core/profiles/standard/tests/src/Functional/StandardTest.php
index 321c4bb..e91a192 100644
--- a/core/profiles/standard/tests/src/Functional/StandardTest.php
+++ b/core/profiles/standard/tests/src/Functional/StandardTest.php
@@ -2,6 +2,8 @@
namespace Drupal\Tests\standard\Functional;
+use Drupal\Component\Utility\Html;
+use Drupal\media\Entity\MediaType;
use Drupal\Tests\SchemaCheckTestTrait;
use Drupal\contact\Entity\ContactForm;
use Drupal\Core\Url;
@@ -219,6 +221,38 @@ class StandardTest extends BrowserTestBase {
$this->assertText('Archive');
$this->assertText('Restore to Draft');
$this->assertText('Restore');
+
+ \Drupal::service('module_installer')->install(['media']);
+ $role = Role::create([
+ 'id' => 'admin_media',
+ 'label' => 'Admin media',
+ ]);
+ $role->grantPermission('administer media');
+ $role->save();
+ $this->adminUser->addRole($role->id());
+ $this->adminUser->save();
+ $assert_session = $this->assertSession();
+ /** @var \Drupal\media\Entity\MediaType $media_type */
+ foreach (MediaType::loadMultiple() as $media_type) {
+ $media_type_machine_name = $media_type->id();
+ $this->drupalGet('media/add/' . $media_type_machine_name);
+ // Get the form element, and its HTML representation.
+ $form_selector = '#media-' . Html::cleanCssIdentifier($media_type_machine_name) . '-add-form';
+ $form = $assert_session->elementExists('css', $form_selector);
+ $form_html = $form->getOuterHtml();
+
+ // The name field should come before the source field, which should itself
+ // come before the vertical tabs.
+ $name_field = $assert_session->fieldExists('Name', $form)->getOuterHtml();
+ $test_source_field = $assert_session->fieldExists($media_type->getSource()->getSourceFieldDefinition($media_type)->getLabel(), $form)->getOuterHtml();
+ $vertical_tabs = $assert_session->elementExists('css', '.form-type-vertical-tabs', $form)->getOuterHtml();
+ $date_field = $assert_session->fieldExists('Date', $form)->getOuterHtml();
+ $published_checkbox = $assert_session->fieldExists('Published', $form)->getOuterHtml();
+ $this->assertTrue(strpos($form_html, $test_source_field) > strpos($form_html, $name_field));
+ $this->assertTrue(strpos($form_html, $vertical_tabs) > strpos($form_html, $test_source_field));
+ // The "Published" checkbox should be the last element.
+ $this->assertTrue(strpos($form_html, $published_checkbox) > strpos($form_html, $date_field));
+ }
}
}