You are here

public function PathautoKernelTest::testNoExistingPathAliases in Pathauto 8

File

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

Class

PathautoKernelTest
Unit tests for Pathauto functions.

Namespace

Drupal\Tests\pathauto\Kernel

Code

public function testNoExistingPathAliases() {
  $this
    ->config('pathauto.settings')
    ->set('punctuation.period', PathautoGeneratorInterface::PUNCTUATION_DO_NOTHING)
    ->save();
  $this->nodePattern
    ->setPattern('[node:title]')
    ->save();

  // Check that Pathauto does not create an alias of '/admin'.
  $node = $this
    ->drupalCreateNode([
    'title' => 'Admin',
    'type' => 'page',
  ]);
  $this
    ->assertEntityAlias($node, '/admin-0');

  // Check that Pathauto does not create an alias of '/modules'.
  $node
    ->setTitle('Modules');
  $node
    ->save();
  $this
    ->assertEntityAlias($node, '/modules-0');

  // Check that Pathauto does not create an alias of '/index.php'.
  $node
    ->setTitle('index.php');
  $node
    ->save();
  $this
    ->assertEntityAlias($node, '/index.php-0');

  // Check that a safe value gets an automatic alias. This is also a control
  // to ensure the above tests work properly.
  $node
    ->setTitle('Safe value');
  $node
    ->save();
  $this
    ->assertEntityAlias($node, '/safe-value');
}