function PublishActionTest::testPublishAction

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Action/PublishActionTest.php \Drupal\KernelTests\Core\Action\PublishActionTest::testPublishAction()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Action/PublishActionTest.php \Drupal\KernelTests\Core\Action\PublishActionTest::testPublishAction()
  3. 11.x 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 48

Class

PublishActionTest
@group Action

Namespace

Drupal\KernelTests\Core\Action

Code

public function testPublishAction() : void {
    $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());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.