You are here

public function PublishActionTest::testPublishAction in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Action/PublishActionTest.php \Drupal\KernelTests\Core\Action\PublishActionTest::testPublishAction()
  2. 9 core/tests/Drupal/KernelTests/Core/Action/PublishActionTest.php \Drupal\KernelTests\Core\Action\PublishActionTest::testPublishAction()

@covers \Drupal\Core\Action\Plugin\Action\PublishAction::execute

File

core/tests/Drupal/KernelTests/Core/Action/PublishActionTest.php, line 46

Class

PublishActionTest
@group Action

Namespace

Drupal\KernelTests\Core\Action

Code

public function testPublishAction() {
  $entity = EntityTestMulRevPub::create([
    'name' => 'test',
  ]);
  $entity
    ->setUnpublished()
    ->save();
  $action = Action::create([
    'id' => 'entity_publish_action',
    'plugin' => 'entity:publish_action:entity_test_mulrevpub',
  ]);
  $action
    ->save();
  $this
    ->assertFalse($entity
    ->isPublished());
  $action
    ->execute([
    $entity,
  ]);
  $this
    ->assertTrue($entity
    ->isPublished());
  $this
    ->assertSame([
    'module' => [
      'entity_test',
    ],
  ], $action
    ->getDependencies());
}