public function CommentActionsTest::testCommentDefaultConfigActions in Drupal 10
Same name and namespace in other branches
- 9 core/modules/comment/tests/src/Kernel/CommentActionsTest.php \Drupal\Tests\comment\Kernel\CommentActionsTest::testCommentDefaultConfigActions()
Tests comment module's default config actions.
See also
\Drupal\Core\Entity\Form\DeleteMultipleForm::submitForm()
\Drupal\Core\Action\Plugin\Action\DeleteAction
\Drupal\Core\Action\Plugin\Action\Derivative\EntityDeleteActionDeriver
\Drupal\Core\Action\Plugin\Action\PublishAction
\Drupal\Core\Action\Plugin\Action\SaveAction
File
- core/
modules/ comment/ tests/ src/ Kernel/ CommentActionsTest.php, line 104
Class
- CommentActionsTest
- Tests actions provided by the Comment module.
Namespace
Drupal\Tests\comment\KernelCode
public function testCommentDefaultConfigActions() {
$this
->assertTrue($this->comment
->isNew());
$action = Action::load('comment_save_action');
$action
->execute([
$this->comment,
]);
$this
->assertFalse($this->comment
->isNew());
$this
->assertTrue($this->comment
->isPublished());
// Tests comment unpublish.
$action = Action::load('comment_unpublish_action');
$action
->execute([
$this->comment,
]);
$this
->assertFalse($this->comment
->isPublished(), 'Comment was unpublished');
$this
->assertSame([
'module' => [
'comment',
],
], $action
->getDependencies());
// Tests comment publish.
$action = Action::load('comment_publish_action');
$action
->execute([
$this->comment,
]);
$this
->assertTrue($this->comment
->isPublished(), 'Comment was published');
$action = Action::load('comment_delete_action');
$action
->execute([
$this->comment,
]);
/** @var \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store */
$temp_store = $this->container
->get('tempstore.private');
$account_id = $this->container
->get('current_user')
->id();
$store_entries = $temp_store
->get('entity_delete_multiple_confirm')
->get($account_id . ':comment');
$this
->assertSame([
$account_id => [
'en' => 'en',
],
], $store_entries);
}