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%2FExtraFieldUpdatePathTest.php;fp=web%2Fcore%2Fmodules%2Flayout_builder%2Ftests%2Fsrc%2FFunctional%2FUpdate%2FExtraFieldUpdatePathTest.php;h=43474c26b15227b03057a86e5d54fce3db6123a6;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/layout_builder/tests/src/Functional/Update/ExtraFieldUpdatePathTest.php b/web/core/modules/layout_builder/tests/src/Functional/Update/ExtraFieldUpdatePathTest.php new file mode 100644 index 000000000..43474c26b --- /dev/null +++ b/web/core/modules/layout_builder/tests/src/Functional/Update/ExtraFieldUpdatePathTest.php @@ -0,0 +1,53 @@ +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-extra.php', + ]; + } + + /** + * Tests the upgrade path for Layout Builder extra fields. + */ + public function testRunUpdates() { + // The default view mode has Layout Builder enabled. + $data = EntityViewDisplay::load('node.article.default')->toArray(); + $this->assertArrayHasKey('third_party_settings', $data); + $this->assertArrayNotHasKey('sections', $data['third_party_settings']['layout_builder']); + + // The teaser view mode does not have Layout Builder enabled. + $data = EntityViewDisplay::load('node.article.teaser')->toArray(); + $this->assertArrayNotHasKey('third_party_settings', $data); + + $this->runUpdates(); + + // The extra links have been added. + $data = EntityViewDisplay::load('node.article.default')->toArray(); + $components = $data['third_party_settings']['layout_builder']['sections'][0]->getComponents(); + $component = reset($components); + $this->assertSame('extra_field_block:node:article:links', $component->getPluginId()); + + // No extra links have been added. + $data = EntityViewDisplay::load('node.article.teaser')->toArray(); + $this->assertArrayNotHasKey('third_party_settings', $data); + } + +}