You are here

protected function PathautoSettingsFormWebTest::checkAlias in Pathauto 8

Helper method to check the an aliases.

Parameters

string $title: The node title to build the aliases from.

string $alias: The expected alias.

array $settings: The form values the alias should be generated with.

2 calls to PathautoSettingsFormWebTest::checkAlias()
PathautoSettingsFormWebTest::testPunctuationSettings in tests/src/Functional/PathautoSettingsFormWebTest.php
Test the punctuation setting form items.
PathautoSettingsFormWebTest::testSettingsForm in tests/src/Functional/PathautoSettingsFormWebTest.php
Tests generating aliases with different settings.

File

tests/src/Functional/PathautoSettingsFormWebTest.php, line 220

Class

PathautoSettingsFormWebTest
Tests pathauto settings form.

Namespace

Drupal\Tests\pathauto\Functional

Code

protected function checkAlias($title, $alias, $settings = []) {

  // Submit the settings form.
  $edit = array_merge($this->defaultFormValues + $this->defaultPunctuations, $settings);
  $this
    ->drupalPostForm('/admin/config/search/path/settings', $edit, t('Save configuration'));
  $this
    ->assertText(t('The configuration options have been saved.'));

  // If we do not clear the caches here, AliasCleaner will use its
  // cleanStringCache instance variable. Due to that the creation of aliases
  // with $this->createNode() will only work correctly on the first call.
  \Drupal::service('pathauto.generator')
    ->resetCaches();

  // Create a node and check if the settings applied.
  $node = $this
    ->createNode([
    'title' => $title,
    'type' => 'article',
  ]);
  $this
    ->drupalGet($alias);
  $this
    ->assertResponse(200);
  $this
    ->assertEntityAlias($node, $alias);
}