You are here

function PathautoUnitTestCase::testEntityBundleRenamingDeleting in Pathauto 6

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

File

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

Class

PathautoUnitTestCase
Unit tests for Pathauto functions.

Code

function testEntityBundleRenamingDeleting() {

  // Create a vocabulary type.
  $vocabulary = $this
    ->addVocabulary();
  variable_set('pathauto_taxonomy_pattern', 'base');
  variable_set('pathauto_taxonomy_' . $vocabulary->vid . '_pattern', 'bundle');
  $this
    ->assertEntityPattern('taxonomy', $vocabulary->vid, '', 'bundle');

  // Delete the vocabulary, which should cause its pattern variable to also
  // be deleted.
  taxonomy_del_vocabulary($vocabulary->vid);
  $this
    ->assertEntityPattern('taxonomy', $vocabulary->vid, '', 'base');

  // Create a node type and test that it's pattern variable works.
  $type = $this
    ->addNodeType(array(
    'type' => 'old_name',
  ));
  variable_set('pathauto_node_pattern', 'base');
  variable_set("pathauto_node_old_name_pattern", 'bundle');
  $this
    ->assertEntityPattern('node', 'old_name', '', 'bundle');

  // Rename the node type's machine name, which should cause its pattern
  // variable to also be renamed.
  $type->type = 'new_name';
  $type->old_type = 'old_name';
  node_type_save($type);
  node_types_rebuild();
  $this
    ->assertEntityPattern('node', 'new_name', '', 'bundle');
  $this
    ->assertEntityPattern('node', 'old_name', '', 'base');

  // Delete the node type, which should cause its pattern variable to also
  // be deleted.
  node_type_delete($type->type);
  $this
    ->assertEntityPattern('node', 'new_name', '', 'base');
}