You are here

public function SaveActionTest::testSaveAction in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Action/SaveActionTest.php \Drupal\KernelTests\Core\Action\SaveActionTest::testSaveAction()
  2. 10 core/tests/Drupal/KernelTests/Core/Action/SaveActionTest.php \Drupal\KernelTests\Core\Action\SaveActionTest::testSaveAction()

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

File

core/tests/Drupal/KernelTests/Core/Action/SaveActionTest.php, line 47

Class

SaveActionTest
@group Action

Namespace

Drupal\KernelTests\Core\Action

Code

public function testSaveAction() {
  $entity = EntityTestMulChanged::create([
    'name' => 'test',
  ]);
  $entity
    ->save();
  $saved_time = $entity
    ->getChangedTime();
  $action = Action::create([
    'id' => 'entity_save_action',
    'plugin' => 'entity:save_action:entity_test_mul_changed',
  ]);
  $action
    ->save();
  $action
    ->execute([
    $entity,
  ]);
  $this
    ->assertNotSame($saved_time, $entity
    ->getChangedTime());
  $this
    ->assertArraySubset([
    'module' => [
      'entity_test',
    ],
  ], $action
    ->getDependencies());
}