diff -u b/core/modules/node/node.module b/core/modules/node/node.module --- b/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -383,7 +383,7 @@ } /** - * Configures the authored on and authored by base field for a node type. + * Configures the authored on and authored by base fields for a node type. * * @param \Drupal\node\NodeTypeInterface $type * A node type object. @@ -407,11 +407,11 @@ // Try loading the display from configuration. $display = EntityViewDisplay::load('node.' . $type->id() . '.' . $view_mode_name); - // If not found, create a fresh display object. We do not preemptively create - // new entity_view_display configuration entries for each existing entity type - // and bundle whenever a new view mode becomes available. Instead, - // configuration entries are only created when a display object is explicitly - // configured and saved. + // If not found, create a fresh display object. We do not preemptively + // create new entity_view_display configuration entries for each existing + // entity type and bundle whenever a new view mode becomes available. + // Instead, configuration entries are only created when a display object is + // explicitly configured and saved. if (!$display) { $display = EntityViewDisplay::create([ 'targetEntityType' => 'node', diff -u b/core/modules/node/tests/src/Functional/NodeCreationTest.php b/core/modules/node/tests/src/Functional/NodeCreationTest.php --- b/core/modules/node/tests/src/Functional/NodeCreationTest.php +++ b/core/modules/node/tests/src/Functional/NodeCreationTest.php @@ -73,6 +73,7 @@ // creation date. $node_type = NodeType::load('page'); $node_type->setDisplaySubmitted(TRUE); + $node_type->save(); // Verify that pages do show submitted information after requiring them. $this->drupalGet('node/' . $node->id()); reverted: --- b/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php +++ a/core/tests/Drupal/KernelTests/Config/DefaultConfigTest.php @@ -95,10 +95,10 @@ foreach ($optional_config_storage->listAll() as $config_name) { $data = $optional_config_storage->read($config_name); if (isset($data['dependencies']['module'])) { + $modules_to_install = array_merge($modules_to_install, $data['dependencies']['module']); - $modules_to_install = array_merge($data['dependencies']['module'], $modules_to_install); } if (isset($data['dependencies']['theme'])) { + $themes_to_install = array_merge($themes_to_install, $data['dependencies']['theme']); - $themes_to_install = array_merge($data['dependencies']['theme'], $themes_to_install); } } $module_installer->install(array_unique($modules_to_install)); only in patch2: unchanged: --- a/core/modules/node/content_types.js +++ b/core/modules/node/content_types.js @@ -45,17 +45,6 @@ return vals.join(', '); }); - $context.find('#edit-display').drupalSetSummary(function (context) { - var vals = []; - var $editContext = $(context); - $editContext.find('input:checked').next('label').each(function () { - vals.push(Drupal.checkPlain($(this).text())); - }); - if (!$editContext.find('#edit-display-submitted').is(':checked')) { - vals.unshift(Drupal.t("Don't display post information")); - } - return vals.join(', '); - }); } }; only in patch2: unchanged: --- a/core/modules/node/tests/src/Functional/NodePostSettingsTest.php +++ b/core/modules/node/tests/src/Functional/NodePostSettingsTest.php @@ -1,6 +1,7 @@ drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type')); + $page_type = NodeType::load('page'); + $page_type->setDisplaySubmitted(TRUE); + $page_type->save(); // Create a node. $edit = []; @@ -40,9 +41,8 @@ public function testPagePostInfo() { $node->delete(); // Set "Basic page" content type to display post information. - $edit = []; - $edit['display_submitted'] = FALSE; - $this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type')); + $page_type->setDisplaySubmitted(FALSE); + $page_type->save(); // Create a node. $edit = []; only in patch2: unchanged: --- /dev/null +++ b/core/modules/system/src/Tests/Update/UpdateNodeTypeTest.php @@ -0,0 +1,74 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz', + ]; + } + + /** + * Tests that authored on / by base fields are created correctly. + */ + public function testNodeTypeSetDisplaySubmitted() { + // First, let's confirm that the article node type displays the + // authored by / on information. + $article_type = NodeType::load('article'); + $this->assertTrue($article_type->displaySubmitted(), t('The node type article displays the content author and creation date.')); + + // Confirm that the current article view modes don't have the + // authored on / by base fields configuration. + foreach (['teaser', 'default'] as $view_mode) { + $config = $this->config('core.entity_view_display.node.article.' . $view_mode)->get('data'); + $this->assertFalse(isset($config['content']['created']), t('The authored on (created) base field does not exist in the article !view_mode view mode.', array('!view_mode' => $view_mode))); + $this->assertFalse(isset($config['content']['uid']), t('The authored by (uid) base field does not exist in the article !view_mode view mode.', array('!view_mode' => $view_mode))); + } + + // Second, let's confirm that the page node type doesn't display the + // authored by / on information. + $page_type = NodeType::load('page'); + $this->assertFalse($page_type->displaySubmitted(), t('The node type page does not display the content author and creation date.')); + + // Confirm that the current page view modes don't have the + // authored on / by base fields configuration. + foreach (['teaser', 'default'] as $view_mode) { + $config = $this->config('core.entity_view_display.node.page.' . $view_mode)->get('data'); + $this->assertFalse(isset($config['content']['created']), t('The authored on (created) base field does not exist in the page !view_mode view mode.', array('!view_mode' => $view_mode))); + $this->assertFalse(isset($config['content']['uid']), t('The authored by (uid) base field does not exist in the page !view_mode view mode.', array('!view_mode' => $view_mode))); + } + + $this->runUpdates(); + + // Confirm that the updates added the authored on / by base fields to the + // view mode configuration. + foreach (['teaser', 'default'] as $view_mode) { + $config = $this->config('core.entity_view_display.node.article.' . $view_mode)->get('data'); + $this->assertTrue(isset($config['content']['created']), t('The authored on (created) base field exists in the article !view_mode view mode.', array('!view_mode' => $view_mode))); + $this->assertTrue(isset($config['content']['uid']), t('The authored by (uid) base field exists in the article !view_mode view mode.', array('!view_mode' => $view_mode))); + $this->assertEqual($config['content']['created']['region'], 'content', t('The authored on (created) base field appears in the content region of the article !view_mode view mode.', array('!view_mode' => $view_mode))); + $this->assertEqual($config['content']['uid']['region'], 'content', t('The authored by (uid) base field appears in the content region of the article !view_mode view mode.', array('!view_mode' => $view_mode))); + } + // Confirm that the updates added the authored on / by base fields to the + // view mode configuration. + foreach (['teaser', 'default'] as $view_mode) { + $config = $this->config('core.entity_view_display.node.page.' . $view_mode)->get('data'); + $this->assertTrue(isset($config['content']['created']), t('The authored on (created) base field exists in the page !view_mode view mode.', array('!view_mode' => $view_mode))); + $this->assertTrue(isset($config['content']['uid']), t('The authored by (uid) base field exists in the page !view_mode view mode.', array('!view_mode' => $view_mode))); + $this->assertTrue($config['hidden']['created'], t('The authored on (created) base field is hidden in the page !view_mode view mode.', array('!view_mode' => $view_mode))); + $this->assertTrue($config['hidden']['uid'], t('The authored by (uid) base field is hidden in the page !view_mode view mode.', array('!view_mode' => $view_mode))); + } + } +}