function ActionTest::testNoTypeAction

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/src/Kernel/Action/ActionTest.php \Drupal\Tests\system\Kernel\Action\ActionTest::testNoTypeAction()

Tests no type specified action.

File

core/modules/system/tests/src/Kernel/Action/ActionTest.php, line 109

Class

ActionTest
Tests action plugins.

Namespace

Drupal\Tests\system\Kernel\Action

Code

public function testNoTypeAction() : void {
  // Create an action config entity using the action_test_no_type plugin.
  $action = Action::create([
    'id' => 'action_test_no_type_action',
    'label' => 'Test Action with No Type',
    'plugin' => 'action_test_no_type',
  ]);
  $action->save();
  // Reload the action to ensure it's saved correctly.
  $action = Action::load('action_test_no_type_action');
  // Assert that the action was saved and loaded correctly.
  $this->assertNotNull($action, 'The action config entity was saved and loaded correctly.');
  $this->assertSame('action_test_no_type_action', $action->id(), 'The action ID is correct.');
  $this->assertSame('Test Action with No Type', $action->label(), 'The action label is correct.');
  $this->assertNull($action->getType(), 'The action type is correctly set to NULL.');
}

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