You are here

public function PathautoKernelTest::testSettingChangeInvalidatesCache in Pathauto 8

Tests that enabled entity types generates the necessary fields and plugins.

File

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

Class

PathautoKernelTest
Unit tests for Pathauto functions.

Namespace

Drupal\Tests\pathauto\Kernel

Code

public function testSettingChangeInvalidatesCache() {
  $this
    ->installConfig([
    'pathauto',
  ]);
  $this
    ->enableModules([
    'entity_test',
  ]);
  $definitions = \Drupal::service('plugin.manager.alias_type')
    ->getDefinitions();
  $this
    ->assertFalse(isset($definitions['canonical_entities:entity_test']));
  $fields = \Drupal::service('entity_field.manager')
    ->getBaseFieldDefinitions('entity_test');
  $this
    ->assertFalse(isset($fields['path']));
  $this
    ->config('pathauto.settings')
    ->set('enabled_entity_types', [
    'user',
    'entity_test',
  ])
    ->save();
  $definitions = \Drupal::service('plugin.manager.alias_type')
    ->getDefinitions();
  $this
    ->assertTrue(isset($definitions['canonical_entities:entity_test']));
  $fields = \Drupal::service('entity_field.manager')
    ->getBaseFieldDefinitions('entity_test');
  $this
    ->assertTrue(isset($fields['path']));
}