1 path_pattern.test PathPatternUnitTestCase::testNoTokensNoAlias()

Test that path_save_automatic_alias() will not create a URL alias for a pattern that does not get any tokens replaced.

File

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

Class

PathPatternUnitTestCase
Unit tests for Path pattern functions.

Code

function testNoTokensNoAlias() {
  $node = $this->backdropCreateNode(array('title' => ''));
  $this->assertNoEntityAliasExists('node', $node);

  // On subsequent saves, the $node->path property is now populated indicating
  // this node does not have an automatic alias, so re-saving the node should
  // not give it one.
  $node->title = 'hello';
  $node->save();
  $this->assertNoEntityAliasExists('node', $node);

  // Manually setting the auto flag and saving should create an alias.
  $node->path['auto'] = TRUE;
  $node->save();
  $this->assertEntityAlias('node', $node, 'hello');
}