You are here

public function TaxonomyMenuCustomPathFunctionalTest::testTaxonomyMenuCustomPathVocabularyInterface in Taxonomy menu 7.2

Saves, edits and deletes a taxonomy vocabulary using the user interface.

All the required router paths are already in the database, provided by the helper module taxonomy_menu_dummy_paths.

File

taxonomy_menu_custom_paths/tests/taxonomy_menu_custom_paths.test, line 49
Tests for taxonomy_menu_custom_paths.module.

Class

TaxonomyMenuCustomPathFunctionalTest
Tests the taxonomy vocabulary interface.

Code

public function testTaxonomyMenuCustomPathVocabularyInterface() {

  // Submit without a base path.
  $edit = array(
    'taxonomy_menu[vocab_parent]' => 'main-menu:0',
    'taxonomy_menu[path]' => 'taxonomy_menu_path_custom',
    'taxonomy_menu[options_custom_path][custom_path_base]' => '',
  );
  $this
    ->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/edit', $edit, t('Save'));
  $this
    ->assertRaw(t('A base path must be provided when using a custom path.'));

  // Submit with the base path and its respective path being registered.
  $edit['taxonomy_menu[options_custom_path][custom_path_base]'] = 'custom_base_path';
  $this
    ->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/edit', $edit, t('Save'));
  $this
    ->assertRaw(t('The Taxonomy menu has been created.'));

  // Submit with base path, depth and respective path not being registered.
  $edit['taxonomy_menu[options_custom_path][custom_path_depth]'] = '5';
  $this
    ->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/edit', $edit, t('Save'));
  $this
    ->assertRaw(t('The Taxonomy menu has been updated.'));

  // Submit with base path, depth and respective path not being registered.
  db_delete('menu_router')
    ->condition('path', 'custom_base_path/%/%')
    ->execute();
  $this
    ->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/edit', $edit, t('Save'));
  $this
    ->assertRaw(t('The path custom_base_path/%/% is not available in Drupal. This is required to use custom paths.'));

  // Submit with base path, depth and respective path not being registered.
  db_delete('menu_router')
    ->condition('path', 'custom_base_path/%')
    ->execute();
  $this
    ->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/edit', $edit, t('Save'));
  $this
    ->assertRaw(t('The path custom_base_path/%/% is not available in Drupal. This is required to use custom paths.'));
}