public function CommentIntegrationTest::testCommentDefaultOwner in Drupal 8
Same name and namespace in other branches
- 9 core/modules/comment/tests/src/Kernel/CommentIntegrationTest.php \Drupal\Tests\comment\Kernel\CommentIntegrationTest::testCommentDefaultOwner()
 - 10 core/modules/comment/tests/src/Kernel/CommentIntegrationTest.php \Drupal\Tests\comment\Kernel\CommentIntegrationTest::testCommentDefaultOwner()
 
Test the default owner of comment entities.
File
- core/
modules/ comment/ tests/ src/ Kernel/ CommentIntegrationTest.php, line 152  
Class
- CommentIntegrationTest
 - Tests integration of comment with other components.
 
Namespace
Drupal\Tests\comment\KernelCode
public function testCommentDefaultOwner() {
  $comment = Comment::create([
    'comment_type' => 'comment',
  ]);
  $this
    ->assertEquals(0, $comment
    ->getOwnerId());
  $user = $this
    ->createUser();
  $this->container
    ->get('current_user')
    ->setAccount($user);
  $comment = Comment::create([
    'comment_type' => 'comment',
  ]);
  $this
    ->assertEquals($user
    ->id(), $comment
    ->getOwnerId());
}