You are here

protected function PathAliasTestTrait::assertPathAliasNotExists in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Traits/Core/PathAliasTestTrait.php \Drupal\Tests\Traits\Core\PathAliasTestTrait::assertPathAliasNotExists()

Asserts that a path alias does not exist in the storage.

Parameters

string $alias: The path alias.

string|null $langcode: (optional) The language code of the path alias.

string|null $path: (optional) The system path of the path alias.

string|null $message: (optional) A message to display with the assertion.

1 call to PathAliasTestTrait::assertPathAliasNotExists()
PathLanguageTest::testAliasTranslation in core/modules/path/tests/src/Functional/PathLanguageTest.php
Test alias functionality through the admin interfaces.

File

core/tests/Drupal/Tests/Traits/Core/PathAliasTestTrait.php, line 98

Class

PathAliasTestTrait
Provides methods to create and assert path_alias entities.

Namespace

Drupal\Tests\Traits\Core

Code

protected function assertPathAliasNotExists($alias, $langcode = NULL, $path = NULL, $message = NULL) {
  $query = \Drupal::entityTypeManager()
    ->getStorage('path_alias')
    ->getQuery();
  $query
    ->condition('alias', $alias, '=');
  if ($langcode) {
    $query
      ->condition('langcode', $langcode, '=');
  }
  if ($path) {
    $query
      ->condition('path', $path, '=');
  }
  $query
    ->count();
  $this
    ->assertFalse((bool) $query
    ->execute(), $message);
}