1 path_pattern.test PathPatternFunctionalTestCase::testProgrammaticEntityCreation()

Test programmatic entity creation for aliases.

File

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

Class

PathPatternFunctionalTestCase
Test basic Path automatic URL alias functionality.

Code

function testProgrammaticEntityCreation() {
  $node = $this->backdropCreateNode(array('title' => 'Test node', 'path' => array('auto' => TRUE)));
  $this->assertEntityAlias('node', $node, 'content/test-node');

  $vocabulary = $this->addVocabulary(array('name' => 'Tags'));
  $term = $this->addTerm($vocabulary, array('name' => 'Test term', 'path' => array('auto' => TRUE)));
  $this->assertEntityAlias('taxonomy_term', $term, 'tags/test-term');

  $edit['name'] = 'Test user';
  $edit['mail'] = 'test-user@example.com';
  $edit['pass'] = user_password();
  $edit['path'] = array('auto' => TRUE);
  $edit['status'] = 1;
  $account = new User($edit);
  $account->save();
  $this->assertEntityAlias('user', $account, 'accounts/test-user');
}