You are here

public function PathautoTestHelperTrait::assertEntityPattern in Pathauto 8

1 call to PathautoTestHelperTrait::assertEntityPattern()
PathautoKernelTest::testTaxonomyPattern in tests/src/Kernel/PathautoKernelTest.php
Tests aliases on taxonomy terms.

File

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

Class

PathautoTestHelperTrait
Helper test class with some added functions for testing.

Namespace

Drupal\Tests\pathauto\Functional

Code

public function assertEntityPattern($entity_type, $bundle, $langcode, $expected) {
  $values = [
    'langcode' => $langcode,
    \Drupal::entityTypeManager()
      ->getDefinition($entity_type)
      ->getKey('bundle') => $bundle,
  ];
  $entity = \Drupal::entityTypeManager()
    ->getStorage($entity_type)
    ->create($values);
  $pattern = \Drupal::service('pathauto.generator')
    ->getPatternByEntity($entity);
  $this
    ->assertSame($expected, $pattern
    ->getPattern());
}