You are here

protected function XmlSitemapMenuFunctionalTest::setUp in XML sitemap 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/XmlSitemapMenuFunctionalTest.php \Drupal\Tests\xmlsitemap\Functional\XmlSitemapMenuFunctionalTest::setUp()

Overrides XmlSitemapTestBase::setUp

File

tests/src/Functional/XmlSitemapMenuFunctionalTest.php, line 30

Class

XmlSitemapMenuFunctionalTest
Tests the generation of menu links.

Namespace

Drupal\Tests\xmlsitemap\Functional

Code

protected function setUp() {
  parent::setUp();
  $this->entityTypeBundleInfo = $this->container
    ->get('entity_type.bundle.info');

  // Allow anonymous user to administer menu links.
  $user_role = Role::load(AccountInterface::ANONYMOUS_ROLE);
  $user_role
    ->grantPermission('administer menu');
  $user_role
    ->grantPermission('access content');
  $user_role
    ->save();
  $bundles = $this->entityTypeBundleInfo
    ->getAllBundleInfo();
  foreach ($bundles['menu_link_content'] as $bundle_id => $bundle) {
    xmlsitemap_link_bundle_enable('menu_link_content', $bundle_id);
  }
  foreach ($bundles['menu'] as $bundle_id => $bundle) {
    xmlsitemap_link_bundle_enable('menu', $bundle_id);
  }
  $this->admin_user = $this
    ->drupalCreateUser([
    'administer menu',
    'administer xmlsitemap',
    'access administration pages',
  ]);
  $this->normal_user = $this
    ->drupalCreateUser([
    'access content',
  ]);
}