/** * Set up an administrative user account and testing keys. */ public function setUp() { // Call parent::setUp() allowing test cases to pass further modules. parent::setUp(); $this->admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'administer site configuration', 'administer xmlsitemap', 'access content')); $this->drupalLogin($this->admin_user); if (!$this->languageManager->getLanguage('fr')) { // Add a new language. $language = new Language(array('id' => 'fr', 'name' => 'French')); language_save($language); } if (!$this->languageManager->getLanguage('en')) { // Add a new language. $language = new Language(array('id' => 'en', 'name' => 'English')); language_save($language); } // Create the two different language-context sitemaps. $previous_sitemaps = entity_load_multiple('xmlsitemap'); foreach ($previous_sitemaps as $previous_sitemap) { $previous_sitemap->delete(); } $sitemap = $this->entityManager->getStorage('xmlsitemap')->create(array()); $sitemap->context = array('language' => 'en'); xmlsitemap_sitemap_save($sitemap); $sitemap = $this->entityManager->getStorage('xmlsitemap')->create(array()); $sitemap->context = array('language' => 'fr'); xmlsitemap_sitemap_save($sitemap); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); if ($this->profile != 'standard') { $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page', 'settings' => array('node' => array('options' => array('promote' => FALSE), 'submitted' => FALSE)))); $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); } $this->admin_user = $this->drupalCreateUser(array('administer nodes', 'bypass node access', 'administer content types', 'administer xmlsitemap', 'administer taxonomy')); $this->normal_user = $this->drupalCreateUser(array('create page content', 'edit any page content', 'access content', 'view own unpublished content')); // allow anonymous user to view user profiles $user_role = entity_load('user_role', DRUPAL_ANONYMOUS_RID); $user_role->grantPermission('access content'); $user_role->save(); xmlsitemap_link_bundle_enable('node', 'article'); xmlsitemap_link_bundle_enable('node', 'page'); $this->config->set('xmlsitemap_entity_taxonomy_vocabulary', 1); $this->config->set('xmlsitemap_entity_taxonomy_term', 1); $this->config->save(); xmlsitemap_link_bundle_settings_save('node', 'page', array('status' => 1, 'priority' => 0.6, 'changefreq' => XMLSITEMAP_FREQUENCY_WEEKLY)); // Add a vocabulary so we can test different view modes. $vocabulary = entity_create('taxonomy_vocabulary', array('name' => 'Tags', 'description' => $this->randomMachineName(), 'vid' => 'tags', 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'help' => '')); $vocabulary->save(); xmlsitemap_link_bundle_enable('taxonomy_term', 'tags'); // Set up a field and instance. $field_name = 'tags'; entity_create('field_storage_config', array('name' => $field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', 'settings' => array('allowed_values' => array(array('vocabulary' => $vocabulary->vid, 'parent' => '0'))), 'cardinality' => '-1'))->save(); entity_create('field_instance_config', array('field_name' => $field_name, 'entity_type' => 'node', 'bundle' => 'page'))->save(); entity_get_form_display('node', 'page', 'default')->setComponent($field_name, array('type' => 'taxonomy_autocomplete'))->save(); // Show on default display and teaser. entity_get_display('node', 'page', 'default')->setComponent($field_name, array('type' => 'taxonomy_term_reference_link'))->save(); entity_get_display('node', 'page', 'teaser')->setComponent($field_name, array('type' => 'taxonomy_term_reference_link'))->save(); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->aliasStorage = \Drupal::service('path.alias_storage'); $this->linkStorage = \Drupal::service('xmlsitemap.link_storage'); $this->admin_user = $this->drupalCreateUser(array('access content', 'administer xmlsitemap')); $this->drupalLogin($this->admin_user); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->admin_user = $this->drupalCreateUser(array('access content', 'administer xmlsitemap')); $this->drupalLogin($this->admin_user); // @todo For some reason the test client does not have clean URLs while // the test runner does, so it causes mismatches in watchdog assertions // later. $this->submit_url = Url::fromUri('base://ping', array('absolute' => TRUE, 'query' => array('sitemap' => ''))) . '[sitemap]'; }
/** * {@inheritdoc} */ public function tearDown() { $bundles = $this->entityManager->getAllBundleInfo(); foreach ($bundles['menu_link_content'] as $bundle_id => $bundle) { xmlsitemap_link_bundle_delete('menu_link_content', $bundle_id); } foreach ($bundles['menu'] as $bundle_id => $bundle) { xmlsitemap_link_bundle_delete('menu', $bundle_id); } parent::tearDown(); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); xmlsitemap_link_bundle_enable('taxonomy_vocabulary', 'taxonomy_vocabulary'); // allow anonymous user to view user profiles $user_role = entity_load('user_role', DRUPAL_ANONYMOUS_RID); $user_role->grantPermission('administer taxonomy'); $user_role->save(); $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'administer xmlsitemap')); $this->normal_user = $this->drupalCreateUser(array('access content')); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'administer site configuration', 'administer xmlsitemap', 'access content')); $this->drupalLogin($this->admin_user); $this->languageManager = \Drupal::languageManager(); if (!$this->languageManager->getLanguage('fr')) { // Add a new language. $language = new Language(array('id' => 'fr', 'name' => 'French')); language_save($language); } if (!$this->languageManager->getLanguage('en')) { // Add a new language. $language = new Language(array('id' => 'en', 'name' => 'English')); language_save($language); } $edit = array('site_default_language' => 'en'); $this->drupalPostForm('admin/config/regional/settings', $edit, t('Save configuration')); // Enable URL language detection and selection. $edit = array('language_interface[enabled][language-url]' => '1'); $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings')); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); }