1 path_pattern.test PathPatternUnitTestCase::testNoExistingPathAliases()

File

core/modules/path/tests/path_pattern.test, line 383
Functionality tests for automatic path generation.

Class

PathPatternUnitTestCase
Unit tests for Path pattern functions.

Code

function testNoExistingPathAliases() {
  $config = config('path.settings');
  $config->set('node_page_pattern', '[node:title]');
  $config->set('punctuation_period', PATH_PUNCTUATION_DO_NOTHING);
  $config->save();

  // Check that Path does not create a URL alias of '/admin'.
  $node = $this->backdropCreateNode(array('title' => 'Admin', 'type' => 'page'));
  $this->assertEntityAlias('node', $node, 'admin-1');

  // Check that Path does not create a URL alias of '/modules'.
  $node->title = 'Modules';
  node_save($node);
  $this->assertEntityAlias('node', $node, 'modules-1');

  // Check that Path does not create a URL alias of '/index.php'.
  $node->title = 'index.php';
  node_save($node);
  $this->assertEntityAlias('node', $node, 'index.php-1');

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