function EntityCloneConfigActionTest::testCloneWithWildcards

Tests wildcard support, which allows positional tokens in the clone's ID.

File

core/tests/Drupal/KernelTests/Core/Recipe/EntityCloneConfigActionTest.php, line 98

Class

EntityCloneConfigActionTest
@covers \Drupal\Core\Config\Action\Plugin\ConfigAction\EntityClone[[api-linebreak]] @group Recipe

Namespace

Drupal\KernelTests\Core\Recipe

Code

public function testCloneWithWildcards() : void {
  $this->container
    ->get(ModuleInstallerInterface::class)
    ->install([
    'node',
  ]);
  $this->createContentType([
    'type' => 'alpha',
  ]);
  $this->createContentType([
    'type' => 'beta',
  ]);
  /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
  $display_repository = $this->container
    ->get(EntityDisplayRepositoryInterface::class);
  // Create the default view displays for each node type.
  $display_repository->getViewDisplay('node', 'alpha')
    ->save();
  $display_repository->getViewDisplay('node', 'beta')
    ->save();
  // Ensure the `rss` displays don't exist yet.
  $this->assertTrue($display_repository->getViewDisplay('node', 'alpha', 'rss')
    ->isNew());
  $this->assertTrue($display_repository->getViewDisplay('node', 'beta', 'rss')
    ->isNew());
  // Use the action to clone the default view displays to the `rss` view mode.
  /** @var \Drupal\Core\Config\Action\ConfigActionManager $manager */
  $manager = $this->container
    ->get('plugin.manager.config_action');
  $manager->applyAction('cloneAs', 'core.entity_view_display.node.*.default', 'node.%.rss');
  $this->assertFalse($display_repository->getViewDisplay('node', 'alpha', 'rss')
    ->isNew());
  $this->assertFalse($display_repository->getViewDisplay('node', 'beta', 'rss')
    ->isNew());
}

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