setHomepage example

->set('log_ip_addresses', TRUE)
      ->save(TRUE);

    // Create a node and a comment.     $node = $this->drupalCreateNode(['type' => 'article', 'title' => '<script>alert("123")</script>']);
    $parent_comment = $this->postComment($node$this->randomMachineName()$this->randomMachineName(), TRUE);

    // Post a reply to the comment.     $this->drupalGet('comment/reply/node/' . $node->id() . '/comment/' . $parent_comment->id());
    $child_comment = $this->postComment(NULL, $this->randomMachineName()$this->randomMachineName());
    $comment = Comment::load($child_comment->id());
    $comment->setHomepage('http://example.org/');

    // Add HTML to ensure that sanitation of some fields tested directly.     $comment->setSubject('<blink>Blinking Comment</blink>');

    // Generate and test tokens.     $tests = [];
    $tests['[comment:cid]'] = $comment->id();
    $tests['[comment:hostname]'] = $comment->getHostname();
    $tests['[comment:author]'] = Html::escape($comment->getAuthorName());
    $tests['[comment:mail]'] = $this->adminUser->getEmail();
    $tests['[comment:homepage]'] = UrlHelper::filterBadProtocol($comment->getHomepage());
    
Home | Imprint | This part of the site doesn't use cookies.