Commit 8413fb53 authored by andrei.dincu's avatar andrei.dincu
Browse files

Issue #2249723 by andrei.dincu: Remove duplicate variables from tests and add some documentation

parent 2eb800bd
......@@ -129,6 +129,9 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state) {
$bundles = $this->entityManager->getAllBundleInfo();
$entity_values = $form_state['values']['entity_types'];
......
......@@ -19,8 +19,6 @@ use Drupal\Tests\UnitTestCase;
class XmlSitemapEntityFunctionalTest extends XmlSitemapTestBase {
public static $modules = array('system', 'xmlsitemap', 'entity_test');
protected $normal_user;
protected $config;
public static function getInfo() {
return array(
......@@ -33,8 +31,6 @@ class XmlSitemapEntityFunctionalTest extends XmlSitemapTestBase {
public function setUp() {
parent::setUp();
$this->config = \Drupal::configFactory()->get('xmlsitemap.settings');
$this->admin_user = $this->drupalCreateUser(array('administer entity_test content', 'administer xmlsitemap'));
// allow anonymous user to view user profiles
......
......@@ -13,8 +13,6 @@ namespace Drupal\xmlsitemap\Tests;
class XmlSitemapFunctionalTest extends XmlSitemapTestBase {
public static $modules = array('xmlsitemap', 'path', 'node', 'system', 'user', 'help');
protected $state;
protected $config;
public static function getInfo() {
return array(
......@@ -28,8 +26,6 @@ class XmlSitemapFunctionalTest extends XmlSitemapTestBase {
parent::setUp();
$this->admin_user = $this->drupalCreateUser(array('access content', 'administer site configuration', 'administer xmlsitemap', 'access administration pages', 'access site reports', 'administer permissions', 'view the administration theme'));
$this->state = \Drupal::state();
$this->config = \Drupal::configFactory()->get('xmlsitemap.settings');
}
/**
......
......@@ -17,7 +17,6 @@ use Drupal\Tests\Core\Entity\EntityListBuilderTest;
class XmlSitemapListBuilderTest extends XmlSitemapTestBase {
public static $modules = array('language', 'xmlsitemap', 'node', 'locale', 'content_translation', 'system');
protected $languageManager;
public static function getInfo() {
return array(
......
......@@ -17,9 +17,6 @@ class XmlSitemapMenuFunctionalTest extends XmlSitemapTestBase {
protected $normal_user;
protected $menu_items = array();
public static $modules = array('node', 'xmlsitemap', 'menu_link', 'menu_ui');
protected $state;
protected $config;
protected $entityManager;
public static function getInfo() {
return array(
......@@ -32,9 +29,6 @@ class XmlSitemapMenuFunctionalTest extends XmlSitemapTestBase {
public function setUp() {
parent::setUp();
$this->state = \Drupal::state();
$this->entityManager = \Drupal::entityManager();
$this->config = \Drupal::configFactory()->get('xmlsitemap.settings');
if ($this->profile != 'standard') {
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page', 'settings' => array(
// Set proper default options for the page content type.
......
......@@ -15,7 +15,6 @@ use Drupal\Core\Language\LanguageInterface;
class XmlSitemapMultilingualNodeTest extends XmlSitemapMultilingualTestBase {
public static $modules = array('xmlsitemap', 'language', 'content_translation', 'node', 'locale', 'config_translation', 'system');
protected $config;
public static function getInfo() {
return array(
......@@ -39,7 +38,6 @@ class XmlSitemapMultilingualNodeTest extends XmlSitemapMultilingualTestBase {
$this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
}
$this->config = \Drupal::configFactory()->get('xmlsitemap.settings');
$this->admin_user = $this->drupalCreateUser(array('administer nodes', 'administer languages', 'administer content types', 'access administration pages', 'create page content', 'edit own page content'));
$this->drupalLogin($this->admin_user);
......
......@@ -15,7 +15,6 @@ use Drupal\Core\Language\LanguageInterface;
class XmlSitemapMultilingualTest extends XmlSitemapMultilingualTestBase {
public static $modules = array('language', 'xmlsitemap', 'node', 'locale', 'content_translation', 'system');
protected $config;
public static function getInfo() {
return array(
......@@ -28,7 +27,6 @@ class XmlSitemapMultilingualTest extends XmlSitemapMultilingualTestBase {
public function setUp() {
parent::setUp();
$this->config = \Drupal::configFactory()->get('xmlsitemap.settings');
$this->drupalLogin($this->admin_user);
$edit = array(
'site_default_language' => 'en',
......
......@@ -15,10 +15,7 @@ use Drupal\Core\Language\Language;
*/
abstract class XmlSitemapMultilingualTestBase extends XmlSitemapTestBase {
protected $admin_user;
public static $modules = array('language', 'xmlsitemap', 'node', 'locale', 'content_translation', 'system');
protected $languageManager;
protected $entityManager;
/**
* Set up an administrative user account and testing keys.
......@@ -27,8 +24,6 @@ abstract class XmlSitemapMultilingualTestBase extends XmlSitemapTestBase {
// Call parent::setUp() allowing test cases to pass further modules.
parent::setUp();
$this->languageManager = \Drupal::languageManager();
$this->entityManager = \Drupal::entityManager();
$this->admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'administer site configuration', 'administer xmlsitemap', 'access content'));
$this->drupalLogin($this->admin_user);
......
......@@ -15,9 +15,8 @@ use Drupal\Core\Language\LanguageInterface;
class XmlSitemapNodeFunctionalTest extends XmlSitemapTestBase {
public static $modules = array('node', 'xmlsitemap', 'taxonomy');
protected $normal_user;
protected $nodes = array();
protected $config;
public static function getInfo() {
return array(
......@@ -49,7 +48,6 @@ class XmlSitemapNodeFunctionalTest extends XmlSitemapTestBase {
$user_role->grantPermission('access content');
$user_role->save();
$this->config = \Drupal::configFactory()->get('xmlsitemap.settings');
$this->config->set('xmlsitemap_entity_node', 1);
$this->config->set('xmlsitemap_entity_node_bundle_article', 1);
$this->config->set('xmlsitemap_entity_node_bundle_page', 1);
......
......@@ -13,7 +13,6 @@ namespace Drupal\xmlsitemap\Tests;
class XmlSitemapRebuildTest extends XmlSitemapTestBase {
public static $modules = array('xmlsitemap', 'path', 'node', 'system', 'user', 'help', 'block');
protected $config;
public static function getInfo() {
return array(
......@@ -26,7 +25,6 @@ class XmlSitemapRebuildTest extends XmlSitemapTestBase {
public function setUp() {
parent::setUp();
$this->config = \Drupal::configFactory()->get('xmlsitemap.settings');
$this->admin_user = $this->drupalCreateUser(array('administer xmlsitemap', 'access administration pages', 'access site reports', 'administer users', 'administer permissions'));
$this->drupalPlaceBlock('system_help_block', array('region' => 'help'));
......
......@@ -15,9 +15,7 @@ use Drupal\Core\Language\LanguageInterface;
class XmlSitemapTaxonomyFunctionalTest extends XmlSitemapTestBase {
public static $modules = array('taxonomy', 'xmlsitemap');
protected $normal_user;
protected $nodes = array();
protected $config;
public static function getInfo() {
return array(
......@@ -30,7 +28,6 @@ class XmlSitemapTaxonomyFunctionalTest extends XmlSitemapTestBase {
public function setUp() {
parent::setUp();
$this->config = \Drupal::configFactory()->get('xmlsitemap.settings');
$this->config->set('xmlsitemap_entity_taxonomy_vocabulary', TRUE);
$this->config->set('xmlsitemap_entity_taxonomy_vocabulary_bundle_taxonomy_vocabulary', TRUE);
$this->config->save();
......
......@@ -23,6 +23,13 @@ abstract class XmlSitemapTestBase extends WebTestBase {
*/
protected $admin_user;
/**
* The normal user account.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $normal_user;
/**
* The state store.
*
......@@ -51,6 +58,13 @@ abstract class XmlSitemapTestBase extends WebTestBase {
*/
protected $entityManager;
/**
* The language manager object.
*
* @var \Drupal\Core\Language\LanguageManagerInterface
*/
protected $languageManager;
public function setUp() {
array_unshift(self::$modules, 'xmlsitemap');
parent::setUp();
......@@ -58,6 +72,7 @@ abstract class XmlSitemapTestBase extends WebTestBase {
$this->config = \Drupal::configFactory()->get('xmlsitemap.settings');
$this->moduleHandler = \Drupal::moduleHandler();
$this->entityManager = \Drupal::entityManager();
$this->languageManager = \Drupal::languageManager();
}
public function tearDown() {
......
......@@ -13,8 +13,6 @@ namespace Drupal\xmlsitemap\Tests;
class XmlSitemapUnitTest extends XmlSitemapTestBase {
public static $modules = array('xmlsitemap', 'node', 'system');
protected $state;
protected $config;
public static function getInfo() {
return array(
......@@ -28,8 +26,6 @@ class XmlSitemapUnitTest extends XmlSitemapTestBase {
parent::setUp();
$this->admin_user = $this->drupalCreateUser(array('access content', 'administer site configuration', 'administer xmlsitemap'));
$this->state = \Drupal::state();
$this->config = \Drupal::configFactory()->get('xmlsitemap.settings');
}
public function testAssertFlag() {
......
......@@ -12,10 +12,8 @@ namespace Drupal\xmlsitemap\Tests;
*/
class XmlSitemapUserFunctionalTest extends XmlSitemapTestBase {
protected $normal_user;
protected $accounts = array();
public static $modules = array('xmlsitemap', 'user', 'node', 'system');
protected $config;
public static function getInfo() {
return array(
......@@ -27,7 +25,6 @@ class XmlSitemapUserFunctionalTest extends XmlSitemapTestBase {
public function setUp($modules = array()) {
parent::setUp();
$this->config = \Drupal::configFactory()->get('xmlsitemap.settings');
// allow anonymous user to view user profiles
$user_role = entity_load('user_role', DRUPAL_ANONYMOUS_RID);
......
......@@ -27,13 +27,23 @@ class XmlSitemapWriter extends \XMLWriter {
* @param $page
* The current page of the sitemap being generated.
*/
function __construct(XmlSitemapInterface $sitemap, $page) {
public function __construct(XmlSitemapInterface $sitemap, $page) {
$this->sitemap = $sitemap;
$this->sitemap_page = $page;
$this->uri = xmlsitemap_sitemap_get_file($sitemap, $page);
$this->openUri($this->uri);
}
/**
* Opens and uri.
*
* @param string $uri
* Uri to be opened.
*
* @throws XmlSitemapGenerationException
*
* @return bool
*/
public function openUri($uri) {
$return = parent::openUri($uri);
if (!$return) {
......
......@@ -16,8 +16,6 @@ class XmlSitemapCustomFunctionalTest extends XmlSitemapTestBase {
public static $modules = array('xmlsitemap_custom', 'path', 'node');
protected $languageManager;
protected $aliasStorage;
public static function getInfo() {
......@@ -32,7 +30,6 @@ class XmlSitemapCustomFunctionalTest extends XmlSitemapTestBase {
public function setUp() {
parent::setUp();
$this->languageManager = \Drupal::languageManager();
$this->aliasStorage = \Drupal::service('path.alias_storage');
$this->admin_user = $this->drupalCreateUser(array('access content', 'administer xmlsitemap'));
$this->drupalLogin($this->admin_user);
......
......@@ -40,8 +40,8 @@ class XmlSitemapEnginesSettingsForm extends ConfigFormBase {
* The factory for configuration objects.
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
* The form builder service.
* @param \Drupal\Core\Language\LanguageManagerInterface $state
* The language manager service.
* @param \Drupal\Core\State\StateInterface $state
* The state store service.
*/
public function __construct(ConfigFactoryInterface $config_factory, FormBuilderInterface $form_builder, StateInterface $state) {
parent::__construct($config_factory);
......
......@@ -17,9 +17,6 @@ class XmlSitemapEnginesFunctionalTest extends XmlSitemapTestBase {
protected $submit_url;
public static $modules = array('system', 'path', 'node', 'dblog', 'xmlsitemap', 'xmlsitemap_engines', 'xmlsitemap_engines_test');
protected $entityManager;
protected $state;
/**
* {@inheritdoc}
*/
......@@ -36,8 +33,6 @@ class XmlSitemapEnginesFunctionalTest extends XmlSitemapTestBase {
*/
public function setUp() {
parent::setUp();
$this->entityManager = \Drupal::entityManager();
$this->state = \Drupal::state();
$this->admin_user = $this->drupalCreateUser(array('access content', 'administer xmlsitemap'));
$this->drupalLogin($this->admin_user);
......
......@@ -12,6 +12,9 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Drupal\Component\Utility\UrlHelper;
/**
* Returns responses for xmlsitemap_engines_test.ping route.
*/
class XmlSitemapEnginesTestController extends ControllerBase {
public function render() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment