function DeleteActionTest::testDeleteAction

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

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

File

core/tests/Drupal/KernelTests/Core/Action/DeleteActionTest.php, line 72

Class

DeleteActionTest
@group Action

Namespace

Drupal\KernelTests\Core\Action

Code

public function testDeleteAction() {
    $entity = EntityTestMulRevPub::create([
        'name' => 'test',
    ]);
    $entity->save();
    $action = Action::create([
        'id' => 'entity_delete_action',
        'plugin' => 'entity:delete_action:entity_test_mulrevpub',
    ]);
    $action->save();
    $action->execute([
        $entity,
    ]);
    $this->assertArraySubset([
        'module' => [
            'entity_test',
        ],
    ], $action->getDependencies());
    
    /** @var \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store */
    $temp_store = \Drupal::service('tempstore.private');
    $store_entries = $temp_store->get('entity_delete_multiple_confirm')
        ->get($this->testUser
        ->id() . ':entity_test_mulrevpub');
    $this->assertArraySubset([
        $this->testUser
            ->id() => [
            'en' => 'en',
        ],
    ], $store_entries);
}

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