// Tests that comments that used the Drupal 7 Title module and that have
// their subject replaced by a real field are correctly migrated.
$comment = Comment::load(2); $this->assertInstanceOf(Comment::class, $comment);
// Check that the hostname is empty by default.
$comment = Comment::create(['comment_type' => 'foo']); $this->assertEquals('', $comment->getHostname());
\Drupal::configFactory() ->getEditable('comment.settings') ->set('log_ip_addresses', TRUE) ->save(TRUE); // Check that the hostname was set correctly.
$comment = Comment::create(['comment_type' => 'foo']); $this->assertEquals('203.0.113.1', $comment->getHostname()); }
$comment = Comment::load(2); $this->assertSame('The response to the second comment.', $comment->subject->value); $this->assertSame('3', $comment->pid->target_id); $this->assertSame('203.0.113.2', $comment->getHostname());