You are here

function PathautoUnitTestCase::testNoExistingPathAliases in Pathauto 7

Same name and namespace in other branches
  1. 6.2 pathauto.test \PathautoUnitTestCase::testNoExistingPathAliases()
  2. 6 pathauto.test \PathautoUnitTestCase::testNoExistingPathAliases()

File

./pathauto.test, line 367
Functionality tests for Pathauto.

Class

PathautoUnitTestCase
Unit tests for Pathauto functions.

Code

function testNoExistingPathAliases() {
  variable_set('pathauto_node_page_pattern', '[node:title]');
  variable_set('pathauto_punctuation_period', PATHAUTO_PUNCTUATION_DO_NOTHING);

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

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

  // Check that Pathauto does not create an alias of '/index.php'.
  $node->title = 'index.php';
  node_save($node);
  $this
    ->assertEntityAlias('node', $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->title = 'Safe value';
  node_save($node);
  $this
    ->assertEntityAlias('node', $node, 'safe-value');
}