function ConfigActionTest::testDuplicateShorthandActionIds

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Config/Action/ConfigActionTest.php \Drupal\KernelTests\Core\Config\Action\ConfigActionTest::testDuplicateShorthandActionIds()

See also

\Drupal\Core\Config\Action\ConfigActionManager::getShorthandActionIdsForEntityType()

File

core/tests/Drupal/KernelTests/Core/Config/Action/ConfigActionTest.php, line 296

Class

ConfigActionTest
Tests the config action system.

Namespace

Drupal\KernelTests\Core\Config\Action

Code

public function testDuplicateShorthandActionIds() : void {
  $this->enableModules([
    'config_action_duplicate_test',
  ]);
  /** @var \Drupal\Core\Config\Action\ConfigActionManager $manager */
  $manager = $this->container
    ->get('plugin.manager.config_action');
  $this->expectException(DuplicateConfigActionIdException::class);
  $this->expectExceptionMessage("The plugins 'entity_method:config_test.dynamic:setProtectedProperty' and 'config_action_duplicate_test:config_test.dynamic:setProtectedProperty' both resolve to the same shorthand action ID for the 'config_test' entity type");
  $manager->applyAction('createIfNotExists', 'config_test.dynamic.action_test', [
    'label' => 'Action test',
    'protected_property' => '',
  ]);
}

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