1 path_pattern.test PathPatternUnitTestCase::testEntityBundleRenamingDeleting()

File

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

Class

PathPatternUnitTestCase
Unit tests for Path pattern functions.

Code

function testEntityBundleRenamingDeleting() {
  $config = config('path.settings');
  // Create a vocabulary and test that it's pattern variable works.
  $vocab = $this->addVocabulary(array('machine_name' => 'old_name'));
  $config->set('taxonomy_term_pattern', 'base');
  $config->set('taxonomy_term_old_name_pattern', 'bundle');
  $config->save();
  $this->assertEntityPattern('taxonomy_term', 'old_name', LANGUAGE_NONE, 'bundle');

  // Rename the vocabulary's machine name, which should cause its pattern
  // variable to also be renamed.
  // @todo: Renaming vocabularies in Backdrop is not supported. Remove?
  //$vocab->machine_name = 'new_name';
  //taxonomy_vocabulary_save($vocab);
  //$this->assertEntityPattern('taxonomy_term', 'new_name', LANGUAGE_NONE, 'bundle');
  //$this->assertEntityPattern('taxonomy_term', 'old_name', LANGUAGE_NONE, 'base');

  // Delete the vocabulary, which should cause its pattern variable to also
  // be deleted.
  taxonomy_vocabulary_delete($vocab->machine_name);
  $this->assertEntityPattern('taxonomy_term', 'new_name', LANGUAGE_NONE, 'base');
}