updated core to 8.6.3
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Entity\Display\EntityDisplayInterface;
|
||||
use Drupal\Core\Entity\Entity\EntityFormDisplay;
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\field_layout\Display\EntityDisplayWithLayoutInterface;
|
||||
@@ -15,8 +16,10 @@ use Drupal\field_layout\Display\EntityDisplayWithLayoutInterface;
|
||||
*/
|
||||
function field_layout_install() {
|
||||
// Ensure each entity display has a layout.
|
||||
$entity_save = function (EntityDisplayWithLayoutInterface $entity) {
|
||||
$entity->ensureLayout()->save();
|
||||
$entity_save = function (EntityDisplayInterface $entity) {
|
||||
if ($entity instanceof EntityDisplayWithLayoutInterface) {
|
||||
$entity->ensureLayout()->save();
|
||||
}
|
||||
};
|
||||
array_map($entity_save, EntityViewDisplay::loadMultiple());
|
||||
array_map($entity_save, EntityFormDisplay::loadMultiple());
|
||||
@@ -31,8 +34,10 @@ function field_layout_install() {
|
||||
function field_layout_uninstall() {
|
||||
// Reset each entity display to use the one-column layout to best approximate
|
||||
// the absence of layouts.
|
||||
$entity_save = function (EntityDisplayWithLayoutInterface $entity) {
|
||||
$entity->setLayoutId('layout_onecol')->save();
|
||||
$entity_save = function (EntityDisplayInterface $entity) {
|
||||
if ($entity instanceof EntityDisplayWithLayoutInterface) {
|
||||
$entity->setLayoutId('layout_onecol')->save();
|
||||
}
|
||||
};
|
||||
array_map($entity_save, EntityViewDisplay::loadMultiple());
|
||||
array_map($entity_save, EntityFormDisplay::loadMultiple());
|
||||
|
||||
@@ -239,6 +239,40 @@ class FieldLayoutTest extends WebDriverTestBase {
|
||||
$this->assertSession()->pageTextContains('Blah: Test text');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests changing the formatter and region at the same time.
|
||||
*/
|
||||
public function testChangingFormatterAndRegion() {
|
||||
$assert_session = $this->assertSession();
|
||||
$page = $this->getSession()->getPage();
|
||||
|
||||
// Add the test field to the content region.
|
||||
$this->drupalGet('entity_test/structure/entity_test/display');
|
||||
$page->find('css', '#field-test-text .handle')->dragTo($page->find('css', '.region-content-message'));
|
||||
$assert_session->assertWaitOnAjaxRequest();
|
||||
$page->pressButton('Save');
|
||||
$assert_session->fieldValueEquals('fields[field_test_text][region]', 'content');
|
||||
$assert_session->fieldValueEquals('fields[field_test_text][type]', 'text_default');
|
||||
|
||||
// Switch the layout to two columns.
|
||||
$this->click('#edit-field-layouts');
|
||||
$page->selectFieldOption('field_layout', 'layout_twocol');
|
||||
$assert_session->assertWaitOnAjaxRequest();
|
||||
$page->pressButton('Save');
|
||||
$assert_session->fieldValueEquals('fields[field_test_text][region]', 'first');
|
||||
|
||||
// Change the formatter and move to another region.
|
||||
$page->selectFieldOption('fields[field_test_text][type]', 'text_trimmed');
|
||||
$assert_session->assertWaitOnAjaxRequest();
|
||||
$page->find('css', '#field-test-text .handle')->dragTo($page->find('css', '.region-second-message'));
|
||||
$assert_session->assertWaitOnAjaxRequest();
|
||||
$page->pressButton('Save');
|
||||
|
||||
// Assert that both the formatter and region change are persisted.
|
||||
$assert_session->fieldValueEquals('fields[field_test_text][region]', 'second');
|
||||
$assert_session->fieldValueEquals('fields[field_test_text][type]', 'text_trimmed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the region titles on the page.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\field_layout\Kernel;
|
||||
|
||||
use Drupal\Tests\layout_builder\Kernel\LayoutBuilderCompatibilityTestBase;
|
||||
|
||||
/**
|
||||
* @group field_layout
|
||||
*/
|
||||
class FieldLayoutUninstallTest extends LayoutBuilderCompatibilityTestBase {
|
||||
|
||||
/**
|
||||
* Ensures field layout can be uninstalled with layout builder enabled.
|
||||
*/
|
||||
public function testFieldLayoutUninstall() {
|
||||
// Setup user schema so user hook uninstall hook doesn't break.
|
||||
$this->installSchema('user', 'users_data');
|
||||
|
||||
// Setup layout builder and same displays.
|
||||
$this->installLayoutBuilder();
|
||||
|
||||
// Ensure install hook can handle displays without a layout.
|
||||
$this->container->get('module_installer')->install(['field_layout']);
|
||||
|
||||
// Ensure uninstall hook can handle displays without a layout.
|
||||
$this->container->get('module_installer')->uninstall(['field_layout']);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user