You are here

public function PathautoKernelTest::setUp in Pathauto 8

Overrides KernelTestBase::setUp

File

tests/src/Kernel/PathautoKernelTest.php, line 44

Class

PathautoKernelTest
Unit tests for Pathauto functions.

Namespace

Drupal\Tests\pathauto\Kernel

Code

public function setUp() {
  parent::setup();
  $this
    ->installEntitySchema('user');
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('taxonomy_term');
  if ($this->container
    ->get('entity_type.manager')
    ->hasDefinition('path_alias')) {
    $this
      ->installEntitySchema('path_alias');
  }
  $this
    ->installConfig([
    'pathauto',
    'taxonomy',
    'system',
    'node',
  ]);
  ConfigurableLanguage::createFromLangcode('fr')
    ->save();
  $this
    ->installSchema('node', [
    'node_access',
  ]);
  $this
    ->installSchema('system', [
    'sequences',
  ]);
  $type = NodeType::create([
    'type' => 'page',
  ]);
  $type
    ->save();
  node_add_body_field($type);
  $this->nodePattern = $this
    ->createPattern('node', '/content/[node:title]');
  $this->userPattern = $this
    ->createPattern('user', '/users/[user:name]');
  \Drupal::service('router.builder')
    ->rebuild();
  $this->currentUser = User::create([
    'name' => $this
      ->randomMachineName(),
  ]);
  $this->currentUser
    ->save();
}