From 02c173eb9daa31e86c60d4324cab0dcff68ce06d Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Thu, 4 Dec 2014 22:23:10 +0000 Subject: [PATCH] Issue #2379595 by ricovandevin, tibbsa: node_help() broken for node add/edit form --- core/modules/node/node.module | 2 +- core/modules/node/src/Tests/NodeHelpTest.php | 81 ++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 core/modules/node/src/Tests/NodeHelpTest.php diff --git a/core/modules/node/node.module b/core/modules/node/node.module index e9112b19e27b..c6cce777f323 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -121,7 +121,7 @@ function node_help($route_name, RouteMatchInterface $route_match) { case 'entity.node.edit_form': $node = $route_match->getParameter('node'); - $type = $node->getType(); + $type = NodeType::load($node->getType()); return (!empty($type->help) ? Xss::filterAdmin($type->help) : ''); case 'node.add': diff --git a/core/modules/node/src/Tests/NodeHelpTest.php b/core/modules/node/src/Tests/NodeHelpTest.php new file mode 100644 index 000000000000..99658f87cc6d --- /dev/null +++ b/core/modules/node/src/Tests/NodeHelpTest.php @@ -0,0 +1,81 @@ +drupalCreateUser(array( + 'administer content types', + 'administer nodes', + 'bypass node access', + )); + + $this->drupalLogin($admin_user); + $this->drupalPlaceBlock('system_help_block'); + + $this->testType = 'type'; + $this->testText = t('Help text to find on node forms.'); + + // Create content type. + $this->drupalCreateContentType(array( + 'type' => $this->testType, + 'help' => $this->testText, + )); + } + + /** + * Verifies that help text appears on node add/edit forms. + */ + public function testNodeShowHelpText() { + // Check the node add form. + $this->drupalGet('node/add/' . $this->testType); + $this->assertResponse(200); + $this->assertText($this->testText); + + // Create node and check the node edit form. + $node = $this->drupalCreateNode(array('type' => $this->testType)); + $this->drupalGet('node/' . $node->id() . '/edit'); + $this->assertResponse(200); + $this->assertText($this->testText); + } +}