X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Flayout_builder%2Ftests%2Fsrc%2FFunctional%2FUpdate%2FLayoutBuilderEnableUpdatePathTest.php;fp=web%2Fcore%2Fmodules%2Flayout_builder%2Ftests%2Fsrc%2FFunctional%2FUpdate%2FLayoutBuilderEnableUpdatePathTest.php;h=5577539359ddf4b65fb08bdeed1c633d19bd7670;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/layout_builder/tests/src/Functional/Update/LayoutBuilderEnableUpdatePathTest.php b/web/core/modules/layout_builder/tests/src/Functional/Update/LayoutBuilderEnableUpdatePathTest.php new file mode 100644 index 000000000..557753935 --- /dev/null +++ b/web/core/modules/layout_builder/tests/src/Functional/Update/LayoutBuilderEnableUpdatePathTest.php @@ -0,0 +1,86 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.4.0.bare.standard.php.gz', + __DIR__ . '/../../../fixtures/update/layout-builder.php', + __DIR__ . '/../../../fixtures/update/layout-builder-enable.php', + ]; + } + + /** + * Tests the upgrade path for enabling Layout Builder. + */ + public function testRunUpdates() { + $assert_session = $this->assertSession(); + + $expected = [ + 'sections' => [ + [ + 'layout_id' => 'layout_onecol', + 'layout_settings' => [], + 'components' => [ + 'some-uuid' => [ + 'uuid' => 'some-uuid', + 'region' => 'content', + 'configuration' => [ + 'id' => 'system_powered_by_block', + ], + 'additional' => [], + 'weight' => 0, + ], + ], + ], + ], + ]; + $this->assertLayoutBuilderSettings($expected, 'block_content', 'basic', 'default'); + $this->assertLayoutBuilderSettings(NULL, 'node', 'page', 'default'); + + $this->runUpdates(); + + // The display with existing sections is enabled while the other is not. + $expected['enabled'] = TRUE; + $this->assertLayoutBuilderSettings($expected, 'block_content', 'basic', 'default'); + $this->assertLayoutBuilderSettings(NULL, 'node', 'page', 'default'); + + $this->drupalLogin($this->rootUser); + $this->drupalGet('admin/structure/block/block-content/manage/basic/display'); + $assert_session->checkboxChecked('layout[enabled]'); + $this->drupalGet('admin/structure/types/manage/page/display'); + $assert_session->checkboxNotChecked('layout[enabled]'); + } + + /** + * Asserts the Layout Builder settings for a given display. + * + * @param mixed $expected + * The expected value. + * @param string $entity_type_id + * The entity type ID. + * @param string $bundle + * The bundle. + * @param string $view_mode + * The view mode. + */ + protected function assertLayoutBuilderSettings($expected, $entity_type_id, $bundle, $view_mode) { + $this->assertEquals($expected, \Drupal::config("core.entity_view_display.$entity_type_id.$bundle.$view_mode")->get('third_party_settings.layout_builder')); + } + +}