You are here

function TaxonomyMenuOperations::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 modules/taxonomy_menu/src/Tests/TaxonomyMenuOperations.php \Drupal\taxonomy_menu\Tests\TaxonomyMenuOperations::setUp()

Set up for all tests.

Overrides WebTestBase::setUp

File

modules/taxonomy_menu/src/Tests/TaxonomyMenuOperations.php, line 24
Definition of Drupal\taxonomy_menu\Tests\KeyService.

Class

TaxonomyMenuOperations
Tests the operations of Taxonomy Menu.

Namespace

Drupal\taxonomy_menu\Tests

Code

function setUp() {
  parent::setUp();

  // Create user with permission to create policy.
  $user1 = $this
    ->drupalCreateUser(array(
    'administer site configuration',
    'administer taxonomy',
  ));
  $this
    ->drupalLogin($user1);

  // Create a testing taxonomy vocabulary.
  $this
    ->drupalGet('admin/structure/taxonomy/add');
  $edit = [
    'vid' => 'test_tax_vocab',
    'name' => 'Test',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));

  // Create logged in user.
  $perms = [
    'administer site configuration',
    'administer taxonomy',
    'administer menu',
  ];
  $admin_user = $this
    ->drupalCreateUser($perms);
  $this
    ->drupalLogin($admin_user);

  // Add sample terms to the vocabulary.
  $this
    ->drupalGet('admin/structure/taxonomy/manage/test_tax_vocab/add');
  $edit = [
    'name[0][value]' => 'test term 1',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));
  $this
    ->drupalGet('admin/structure/taxonomy/manage/test_tax_vocab/add');
  $edit = [
    'name[0][value]' => 'test term 1-A',
    'parent[]' => '1',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));
  $this
    ->drupalGet('admin/structure/taxonomy/manage/test_tax_vocab/add');
  $edit = [
    'name[0][value]' => 'test term 2',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));

  // Create a testing menu.
  $this
    ->drupalGet('admin/structure/menu/add');
  $edit = [
    'id' => 'test-menu',
    'label' => 'Test',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));

  // Create new taxonomy menu.
  $this
    ->drupalGet('admin/config/system/taxonomy_menu/add');
  $edit = [
    'id' => 'test_tax_menu',
    'label' => 'test tax menu',
    'vocabulary' => 'test_tax_vocab',
    'menu' => 'test-menu',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));
}