diff --git a/core/modules/field_layout/field_layout.install b/core/modules/field_layout/field_layout.install index f2502a9..456054e 100644 --- a/core/modules/field_layout/field_layout.install +++ b/core/modules/field_layout/field_layout.install @@ -18,8 +18,8 @@ function field_layout_install() { $entity_save = function (EntityInterface $entity) { $entity->save(); }; - array_walk(EntityViewDisplay::loadMultiple(), $entity_save); - array_walk(EntityFormDisplay::loadMultiple(), $entity_save); + array_map($entity_save, EntityViewDisplay::loadMultiple()); + array_map($entity_save, EntityFormDisplay::loadMultiple()); // Invalidate the render cache since all content will now have a layout. Cache::invalidateTags(['rendered']); diff --git a/core/modules/field_layout/tests/src/Functional/FieldLayoutTest.php b/core/modules/field_layout/tests/src/Functional/FieldLayoutTest.php new file mode 100644 index 0000000..45f228e --- /dev/null +++ b/core/modules/field_layout/tests/src/Functional/FieldLayoutTest.php @@ -0,0 +1,76 @@ +createContentType([ + 'type' => 'article', + ]); + $this->createNode([ + 'type' => 'article', + 'title' => 'The node title', + 'body' => [[ + 'value' => 'The node body', + ]], + ]); + $this->drupalLogin($this->drupalCreateUser([ + 'access administration pages', + 'administer content types', + 'administer nodes', + 'administer node fields', + 'administer node display', + 'administer node form display', + 'view the administration theme', + ])); + } + + /** + * Tests an entity type that has fields shown by default. + */ + public function testNodeView() { + // By default, the default layout is used. + $this->drupalGet('node/1'); + $this->assertSession()->elementExists('css', '.field-layout--default'); + $this->assertSession()->elementExists('css', '.field-layout-region--content .field--name-body'); + + $this->drupalGet('admin/structure/types/manage/article/display'); + $this->assertEquals(['Content', 'Disabled'], $this->getRegionTitles()); + $this->assertSession()->optionExists('fields[body][region]', 'content'); + } + + /** + * Gets the region titles on the page. + * + * @return string[] + * An array of region titles. + */ + protected function getRegionTitles() { + $region_titles = []; + $region_title_elements = $this->getSession()->getPage()->findAll('css', '.region-title td'); + /** @var \Behat\Mink\Element\NodeElement[] $region_title_elements */ + foreach ($region_title_elements as $region_title_element) { + $region_titles[] = $region_title_element->getText(); + } + return $region_titles; + } + +} diff --git a/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php b/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php index 04d0810..131c2b5 100644 --- a/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php +++ b/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php @@ -15,7 +15,7 @@ class FieldLayoutTest extends JavascriptTestBase { /** * {@inheritdoc} */ - public static $modules = ['field_layout', 'field_ui', 'node', 'field_layout_test']; + public static $modules = ['field_layout', 'field_ui', 'field_layout_test']; /** * {@inheritdoc} @@ -23,16 +23,6 @@ class FieldLayoutTest extends JavascriptTestBase { protected function setUp() { parent::setUp(); - $this->createContentType([ - 'type' => 'article', - ]); - $this->createNode([ - 'type' => 'article', - 'title' => 'The node title', - 'body' => [[ - 'value' => 'The node body', - ]], - ]); $entity = EntityTest::create([ 'name' => 'The name for this entity', 'field_test_text' => [[ @@ -42,11 +32,6 @@ protected function setUp() { $entity->save(); $this->drupalLogin($this->drupalCreateUser([ 'access administration pages', - 'administer content types', - 'administer nodes', - 'administer node fields', - 'administer node display', - 'administer node form display', 'view test entity', 'administer entity_test content', 'administer entity_test fields', @@ -207,20 +192,6 @@ public function testEntityView() { } /** - * Tests an entity type that has fields shown by default. - */ - public function testNodeView() { - // By default, the default layout is used. - $this->drupalGet('node/1'); - $this->assertSession()->elementExists('css', '.field-layout--default'); - $this->assertSession()->elementExists('css', '.field-layout-region--content .field--name-body'); - - $this->drupalGet('admin/structure/types/manage/article/display'); - $this->assertEquals(['Content', 'Disabled'], $this->getRegionTitles()); - $this->assertSession()->optionExists('fields[body][region]', 'content'); - } - - /** * Gets the region titles on the page. * * @return string[]