function PublishActionTest::testUnpublishAction

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Action/PublishActionTest.php \Drupal\KernelTests\Core\Action\PublishActionTest::testUnpublishAction()
  2. 10 core/tests/Drupal/KernelTests/Core/Action/PublishActionTest.php \Drupal\KernelTests\Core\Action\PublishActionTest::testUnpublishAction()
  3. 11.x core/tests/Drupal/KernelTests/Core/Action/PublishActionTest.php \Drupal\KernelTests\Core\Action\PublishActionTest::testUnpublishAction()

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

File

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

Class

PublishActionTest
@group Action

Namespace

Drupal\KernelTests\Core\Action

Code

public function testUnpublishAction() {
    $entity = EntityTestMulRevPub::create([
        'name' => 'test',
    ]);
    $entity->setPublished()
        ->save();
    $action = Action::create([
        'id' => 'entity_unpublish_action',
        'plugin' => 'entity:unpublish_action:entity_test_mulrevpub',
    ]);
    $action->save();
    $this->assertTrue($entity->isPublished());
    $action->execute([
        $entity,
    ]);
    $this->assertFalse($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.