You are here

protected function PathautoTestHelperTrait::createPattern in Pathauto 8

Creates a pathauto pattern.

Parameters

string $entity_type_id: The entity type.

string $pattern: The path pattern.

int $weight: (optional) The pattern weight.

Return value

\Drupal\pathauto\PathautoPatternInterface The created pattern.

19 calls to PathautoTestHelperTrait::createPattern()
PathautoBulkUpdateTest::setUp in tests/src/Functional/PathautoBulkUpdateTest.php
PathautoBulkUpdateTest::testBulkUpdate in tests/src/Functional/PathautoBulkUpdateTest.php
PathautoEnablingEntityTypesTest::testEnablingEntityTypes in tests/src/Functional/PathautoEnablingEntityTypesTest.php
A suite of tests to verify if the feature to enable and disable the ability to define alias patterns for a given entity type works. Test with the comment module, as it is not enabled by default.
PathautoEntityWithStringIdTest::setUp in tests/src/Kernel/PathautoEntityWithStringIdTest.php
PathautoKernelTest::setUp in tests/src/Kernel/PathautoKernelTest.php

... See full list

File

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

Class

PathautoTestHelperTrait
Helper test class with some added functions for testing.

Namespace

Drupal\Tests\pathauto\Functional

Code

protected function createPattern($entity_type_id, $pattern, $weight = 10) {
  $type = $entity_type_id == 'forum' ? 'forum' : 'canonical_entities:' . $entity_type_id;
  $pattern = PathautoPattern::create([
    'id' => mb_strtolower($this
      ->randomMachineName()),
    'type' => $type,
    'pattern' => $pattern,
    'weight' => $weight,
  ]);
  $pattern
    ->save();
  return $pattern;
}