You are here

public function PathautoSettingsFormWebTest::testPunctuationSettings in Pathauto 8

Test the punctuation setting form items.

File

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

Class

PathautoSettingsFormWebTest
Tests pathauto settings form.

Namespace

Drupal\Tests\pathauto\Functional

Code

public function testPunctuationSettings() {

  // Test the replacement of punctuations.
  $settings = [];
  foreach ($this->defaultPunctuations as $key => $punctuation) {
    $settings[$key] = PathautoGeneratorInterface::PUNCTUATION_REPLACE;
  }
  $title = 'aa"b`c,d.e-f_g:h;i|j{k[l}m]n+o=p*q%r^s$t#u!v~w(x)y?z>1/2\\3';
  $alias = '/content/aa-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z-1-2-3';
  $this
    ->checkAlias($title, $alias, $settings);

  // Test the removal of punctuations.
  $settings = [];
  foreach ($this->defaultPunctuations as $key => $punctuation) {
    $settings[$key] = PathautoGeneratorInterface::PUNCTUATION_REMOVE;
  }
  $title = 'a"b`c,d.e-f_g:h;i|j{k[l}m]n+o=p*q%r^s$t#u!v~w(x)y?z>1/2\\3';
  $alias = '/content/abcdefghijklmnopqrstuvwxyz123';
  $this
    ->checkAlias($title, $alias, $settings);

  // Keep all punctuations in alias.
  $settings = [];
  foreach ($this->defaultPunctuations as $key => $punctuation) {
    $settings[$key] = PathautoGeneratorInterface::PUNCTUATION_DO_NOTHING;
  }
  $title = 'al"b`c,d.e-f_g:h;i|j{k[l}m]n+o=p*q%r^s$t#u!v~w(x)y?z>1/2\\3';
  $alias = '/content/al"b`c,d.e-f_g:h;i|j{k[l}m]n+o=p*q%r^s$t#u!v~w(x)y?z>1/2\\3';
  $this
    ->checkAlias($title, $alias, $settings);
}