Skip to content
Snippets Groups Projects
Unverified Commit 85fa773d authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2975217 by Sam152, Berdir, Wim Leers, alexpott: Update the default...

Issue #2975217 by Sam152, Berdir, Wim Leers, alexpott: Update the default comment entity owner to the current user
parent ba9eff6b
No related branches found
No related tags found
No related merge requests found
......@@ -323,13 +323,6 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
return $fields;
}
/**
* {@inheritdoc}
*/
public static function getDefaultEntityOwner() {
return 0;
}
/**
* {@inheritdoc}
*/
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\comment\Kernel;
use Drupal\comment\Entity\Comment;
use Drupal\comment\Entity\CommentType;
use Drupal\Core\Database\Database;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
......@@ -9,6 +10,7 @@
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\user\Traits\UserCreationTrait;
/**
* Tests integration of comment with other components.
......@@ -17,6 +19,8 @@
*/
class CommentIntegrationTest extends KernelTestBase {
use UserCreationTrait;
/**
* {@inheritdoc}
*/
......@@ -31,11 +35,13 @@ protected function setUp() {
$this->installEntitySchema('user');
$this->installEntitySchema('comment');
$this->installSchema('dblog', ['watchdog']);
$this->installSchema('system', ['sequences']);
// Create a new 'comment' comment-type.
CommentType::create([
'id' => 'comment',
'label' => $this->randomString(),
'target_entity_type_id' => 'entity_test',
])->save();
}
......@@ -134,4 +140,21 @@ public function testViewMode() {
$this->assertTrue($host_display->get('hidden')[$field_name]);
}
/**
* Test the default owner of comment entities.
*/
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());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment