You are here

public function PathautoTestHelperTrait::assertAlias in Pathauto 8

2 calls to PathautoTestHelperTrait::assertAlias()
PathautoLocaleTest::testLanguagePatterns in tests/src/FunctionalJavascript/PathautoLocaleTest.php
Test that patterns work on multilingual content.
PathautoTestHelperTrait::assertEntityAlias in tests/src/Functional/PathautoTestHelperTrait.php

File

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

Class

PathautoTestHelperTrait
Helper test class with some added functions for testing.

Namespace

Drupal\Tests\pathauto\Functional

Code

public function assertAlias($source, $expected_alias, $langcode = Language::LANGCODE_NOT_SPECIFIED) {
  \Drupal::service('path_alias.manager')
    ->cacheClear($source);
  $entity_type_manager = \Drupal::entityTypeManager();
  if ($entity_type_manager
    ->hasDefinition('path_alias')) {
    $entity_type_manager
      ->getStorage('path_alias')
      ->resetCache();
  }
  $this
    ->assertEquals($expected_alias, \Drupal::service('path_alias.manager')
    ->getAliasByPath($source, $langcode), t("Alias for %source with language '@language' is correct.", [
    '%source' => $source,
    '@language' => $langcode,
  ]));
}