You are here

protected function PathautoTestHelperTrait::addBundleCondition in Pathauto 8

Add a bundle condition to a pathauto pattern.

Parameters

\Drupal\pathauto\PathautoPatternInterface $pattern: The pattern.

string $entity_type: The entity type ID.

string $bundle: The bundle.

2 calls to PathautoTestHelperTrait::addBundleCondition()
PathautoKernelTest::testPatternLoadByEntity in tests/src/Kernel/PathautoKernelTest.php
Test pathauto_pattern_load_by_entity().
PathautoKernelTest::testTaxonomyPattern in tests/src/Kernel/PathautoKernelTest.php
Tests aliases on taxonomy terms.

File

tests/src/Functional/PathautoTestHelperTrait.php, line 58

Class

PathautoTestHelperTrait
Helper test class with some added functions for testing.

Namespace

Drupal\Tests\pathauto\Functional

Code

protected function addBundleCondition(PathautoPatternInterface $pattern, $entity_type, $bundle) {
  $plugin_id = $entity_type == 'node' ? 'node_type' : 'entity_bundle:' . $entity_type;
  $pattern
    ->addSelectionCondition([
    'id' => $plugin_id,
    'bundles' => [
      $bundle => $bundle,
    ],
    'negate' => FALSE,
    'context_mapping' => [
      $entity_type => $entity_type,
    ],
  ]);
}