Commit 426ea155 authored by andrei.dincu's avatar andrei.dincu
Browse files

Issue #2249723 by andrei.dincu: Remove unused use statements and add some documentation

parent 8413fb53
......@@ -8,7 +8,6 @@
namespace Drupal\xmlsitemap\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Component\Utility\MapArray;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Render\Element;
use Drupal\Core\State\StateInterface;
......
......@@ -7,17 +7,16 @@
namespace Drupal\xmlsitemap\Tests;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Field\FieldDefinition;
use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Language\Language;
use Drupal\Tests\UnitTestCase;
/**
* Tests the generation of a random content entity links.
*/
class XmlSitemapEntityFunctionalTest extends XmlSitemapTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('system', 'xmlsitemap', 'entity_test');
public static function getInfo() {
......@@ -28,6 +27,9 @@ class XmlSitemapEntityFunctionalTest extends XmlSitemapTestBase {
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
......@@ -40,6 +42,9 @@ class XmlSitemapEntityFunctionalTest extends XmlSitemapTestBase {
$user_role->save();
}
/**
* Test the form at admin/config/search/xmlsitemap/entities/settings
*/
public function testEntitiesSettingsForms() {
$this->drupalLogin($this->admin_user);
$this->drupalGet('admin/config/search/xmlsitemap/entities/settings');
......@@ -59,6 +64,9 @@ class XmlSitemapEntityFunctionalTest extends XmlSitemapTestBase {
$this->assertSitemapLinkValues('entity_test', $entity->id(), array('status' => 0, 'priority' => 0.5));
}
/**
* Test the form at admin/config/search/xmlsitemap/settings/{entity_type_id}/{bundle_id}
*/
public function testEntityLinkBundleSettingsForm() {
$this->config->set('xmlsitemap_entity_entity_test', 1);
$this->config->set('xmlsitemap_entity_entity_test_bundle_entity_test', 1);
......
......@@ -12,6 +12,11 @@ namespace Drupal\xmlsitemap\Tests;
*/
class XmlSitemapFunctionalTest extends XmlSitemapTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('xmlsitemap', 'path', 'node', 'system', 'user', 'help');
public static function getInfo() {
......@@ -22,6 +27,9 @@ class XmlSitemapFunctionalTest extends XmlSitemapTestBase {
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
......
......@@ -7,15 +7,18 @@
namespace Drupal\xmlsitemap\Tests;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\Language;
use Drupal\Tests\Core\Entity\EntityListBuilderTest;
/**
* Tests the sitemaps list builder.
*/
class XmlSitemapListBuilderTest extends XmlSitemapTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('language', 'xmlsitemap', 'node', 'locale', 'content_translation', 'system');
public static function getInfo() {
......@@ -26,6 +29,9 @@ class XmlSitemapListBuilderTest extends XmlSitemapTestBase {
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
......@@ -59,6 +65,9 @@ class XmlSitemapListBuilderTest extends XmlSitemapTestBase {
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
}
/**
* Test if the default sitemap exists.
*/
public function testDefaultSitemap() {
$this->drupalLogin($this->admin_user);
$context = array();
......@@ -68,6 +77,9 @@ class XmlSitemapListBuilderTest extends XmlSitemapTestBase {
$this->assertText($id);
}
/**
* Test if multiple sitemaps exist and have consistent information.
*/
public function testMoreSitemaps() {
$this->drupalLogin($this->admin_user);
$edit = array(
......
......@@ -14,8 +14,11 @@ use Drupal\system\Entity\Menu;
*/
class XmlSitemapMenuFunctionalTest extends XmlSitemapTestBase {
protected $normal_user;
protected $menu_items = array();
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('node', 'xmlsitemap', 'menu_link', 'menu_ui');
public static function getInfo() {
......@@ -26,6 +29,9 @@ class XmlSitemapMenuFunctionalTest extends XmlSitemapTestBase {
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
......@@ -61,6 +67,9 @@ class XmlSitemapMenuFunctionalTest extends XmlSitemapTestBase {
$this->normal_user = $this->drupalCreateUser(array('access content'));
}
/**
* Test xmlsitemap settings for menu entity.
*/
public function testMenuSettings() {
$this->drupalLogin($this->admin_user);
......@@ -88,6 +97,9 @@ class XmlSitemapMenuFunctionalTest extends XmlSitemapTestBase {
$this->drupalPostForm(NULL, $edit, 'Save');
}
/**
* {@inheritdoc}
*/
public function tearDown() {
$bundles = $this->entityManager->getAllBundleInfo();
$this->config->delete('xmlsitemap_entity_menu_link');
......
......@@ -7,13 +7,16 @@
namespace Drupal\xmlsitemap\Tests;
use Drupal\Core\Language\LanguageInterface;
/**
* Tests the generation of multilingual nodes.
*/
class XmlSitemapMultilingualNodeTest extends XmlSitemapMultilingualTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('xmlsitemap', 'language', 'content_translation', 'node', 'locale', 'config_translation', 'system');
public static function getInfo() {
......@@ -24,6 +27,9 @@ class XmlSitemapMultilingualNodeTest extends XmlSitemapMultilingualTestBase {
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
......@@ -59,6 +65,9 @@ class XmlSitemapMultilingualNodeTest extends XmlSitemapMultilingualTestBase {
$this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), 'Basic page content type has been updated.');
}
/**
* Test language for sitemap node links.
*/
public function testNodeLanguageData() {
$this->drupalLogin($this->admin_user);
$node = $this->drupalCreateNode(array());
......
......@@ -14,6 +14,11 @@ use Drupal\Core\Language\LanguageInterface;
*/
class XmlSitemapMultilingualTest extends XmlSitemapMultilingualTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('language', 'xmlsitemap', 'node', 'locale', 'content_translation', 'system');
public static function getInfo() {
......@@ -24,6 +29,9 @@ class XmlSitemapMultilingualTest extends XmlSitemapMultilingualTestBase {
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
......@@ -37,6 +45,9 @@ class XmlSitemapMultilingualTest extends XmlSitemapMultilingualTestBase {
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
}
/**
* Test how links are included in a sitemap depending on the i18n_selection_mode config variable
*/
public function testLanguageSelection() {
$this->drupalLogin($this->admin_user);
// Create our three different language nodes.
......
......@@ -7,7 +7,6 @@
namespace Drupal\xmlsitemap\Tests;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\Language;
/**
......@@ -15,6 +14,11 @@ use Drupal\Core\Language\Language;
*/
abstract class XmlSitemapMultilingualTestBase extends XmlSitemapTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('language', 'xmlsitemap', 'node', 'locale', 'content_translation', 'system');
/**
......
......@@ -14,8 +14,18 @@ use Drupal\Core\Language\LanguageInterface;
*/
class XmlSitemapNodeFunctionalTest extends XmlSitemapTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('node', 'xmlsitemap', 'taxonomy');
/**
* Nodes created during the test for testCron() method.
*
* @var array
*/
protected $nodes = array();
public static function getInfo() {
......@@ -26,6 +36,9 @@ class XmlSitemapNodeFunctionalTest extends XmlSitemapTestBase {
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
......@@ -254,4 +267,5 @@ class XmlSitemapNodeFunctionalTest extends XmlSitemapTestBase {
}
}
}
}
......@@ -12,6 +12,11 @@ namespace Drupal\xmlsitemap\Tests;
*/
class XmlSitemapRebuildTest extends XmlSitemapTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('xmlsitemap', 'path', 'node', 'system', 'user', 'help', 'block');
public static function getInfo() {
......@@ -22,6 +27,9 @@ class XmlSitemapRebuildTest extends XmlSitemapTestBase {
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
......@@ -35,6 +43,9 @@ class XmlSitemapRebuildTest extends XmlSitemapTestBase {
$user_role->save();
}
/**
* Test sitemap rebuild process.
*/
public function testSimpleRebuild() {
$this->drupalLogin($this->admin_user);
$this->drupalGet('admin/config/search/xmlsitemap/rebuild');
......@@ -45,6 +56,9 @@ class XmlSitemapRebuildTest extends XmlSitemapTestBase {
$this->assertText('The sitemap links were rebuilt.');
}
/**
* Test if user links are included in sitemap after rebuild.
*/
public function testUserLinksRebuild() {
$this->config->set('xmlsitemap_entity_user', 1);
$this->config->set('xmlsitemap_entity_user_bundle_user', 1);
......
......@@ -12,6 +12,11 @@ namespace Drupal\xmlsitemap\Tests;
*/
class XmlSitemapRobotsTxtIntegrationTest extends XmlSitemapTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('xmlsitemap', 'robotstxt');
public static function getInfo() {
......@@ -23,10 +28,16 @@ class XmlSitemapRobotsTxtIntegrationTest extends XmlSitemapTestBase {
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
}
/**
* Test if sitemap link is included in robots.txt file.
*/
public function testRobotsTxt() {
// Request the un-clean robots.txt path so this will work in case there is
// still the robots.txt file in the root directory.
......
......@@ -7,15 +7,17 @@
namespace Drupal\xmlsitemap\Tests;
use Drupal\Core\Language\LanguageInterface;
/**
* Tests the generation of taxonomy links.
*/
class XmlSitemapTaxonomyFunctionalTest extends XmlSitemapTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('taxonomy', 'xmlsitemap');
protected $nodes = array();
public static function getInfo() {
return array(
......@@ -25,6 +27,9 @@ class XmlSitemapTaxonomyFunctionalTest extends XmlSitemapTestBase {
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
......@@ -41,6 +46,9 @@ class XmlSitemapTaxonomyFunctionalTest extends XmlSitemapTestBase {
$this->normal_user = $this->drupalCreateUser(array('access content'));
}
/**
* Test xmlsitemap settings for taxonomies.
*/
public function testTaxonomySettings() {
$this->drupalLogin($this->admin_user);
......
......@@ -14,6 +14,11 @@ use Drupal\simpletest\WebTestBase;
*/
abstract class XmlSitemapTestBase extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('xmlsitemap');
/**
......@@ -65,6 +70,9 @@ abstract class XmlSitemapTestBase extends WebTestBase {
*/
protected $languageManager;
/**
* {@inheritdoc}
*/
public function setUp() {
array_unshift(self::$modules, 'xmlsitemap');
parent::setUp();
......@@ -75,6 +83,9 @@ abstract class XmlSitemapTestBase extends WebTestBase {
$this->languageManager = \Drupal::languageManager();
}
/**
* {@inheritdoc}
*/
public function tearDown() {
// Capture any (remaining) watchdog errors.
$this->assertNoWatchdogErrors();
......
......@@ -12,6 +12,11 @@ namespace Drupal\xmlsitemap\Tests;
*/
class XmlSitemapUnitTest extends XmlSitemapTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('xmlsitemap', 'node', 'system');
public static function getInfo() {
......@@ -22,12 +27,18 @@ class XmlSitemapUnitTest extends XmlSitemapTestBase {
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->admin_user = $this->drupalCreateUser(array('access content', 'administer site configuration', 'administer xmlsitemap'));
}
/**
* Tests for xmlsitemap flags.
*/
public function testAssertFlag() {
$this->state->set('xmlsitemap_rebuild_needed', TRUE);
$this->assertTrue(xmlsitemap_var('xmlsitemap_rebuild_needed'));
......
......@@ -13,6 +13,12 @@ namespace Drupal\xmlsitemap\Tests;
class XmlSitemapUserFunctionalTest extends XmlSitemapTestBase {
protected $accounts = array();
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('xmlsitemap', 'user', 'node', 'system');
public static function getInfo() {
......@@ -23,6 +29,9 @@ class XmlSitemapUserFunctionalTest extends XmlSitemapTestBase {
);
}
/**
* {@inheritdoc}
*/
public function setUp($modules = array()) {
parent::setUp();
......@@ -47,6 +56,9 @@ class XmlSitemapUserFunctionalTest extends XmlSitemapTestBase {
$account->save();
}
/**
* Test sitemap link for a blocked user
*/
public function testBlockedUser() {
$this->drupalLogin($this->admin_user);
$this->assertSitemapLinkNotVisible('user', $this->normal_user->id());
......
......@@ -7,8 +7,6 @@
namespace Drupal\xmlsitemap;
use Drupal\Core\Language\LanguageInterface;
/**
* Provides an interface defining a XmlSitemapGenerator service.
*/
......
......@@ -13,7 +13,6 @@ use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Language\Language;
/**
* XmlSitemap generator service.
......
......@@ -8,25 +8,18 @@
* @file
* Main file for the xmlsitemap module.
*/
use Symfony\Component\HttpFoundation\Request;
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Session\UserSession;
use Drupal\Core\Language\LanguageInterface;
use Drupal\xmlsitemap\XmlSitemapInterface;
use Drupal\user\Entity\User;
use Drupal\user\UserInterface;
use Drupal\Component\Utility\String;
use Drupal\Core\Render\Element;
use Drupal\Core\Entity\EntityFormBuilderInterface;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Entity;
use Drupal\Core\Session\AnonymousUserSession;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\Core\Entity\Query\QueryInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Drupal\Component\Utility\Bytes;
use Symfony\Component\HttpFoundation\Response;
/**
......
......@@ -10,7 +10,6 @@ namespace Drupal\xmlsitemap_custom\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageManagerInterface;
/**
......@@ -46,6 +45,12 @@ class XmlSitemapCustomListController extends ControllerBase {
);
}
/**
* Renders a list with all custom links.
*
* @return array
* The list to be rendered.
*/
public function render() {
$build['xmlsitemap_add_custom'] = array(
'#type' => 'link',
......
......@@ -7,10 +7,8 @@
namespace Drupal\xmlsitemap_custom\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Session\AnonymousUserSession;
use Drupal\xmlsitemap\XmlSitemapLinkStorage;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
......@@ -20,6 +18,9 @@ use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Path\AliasManagerInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
/**
* Provides a form for adding a custom link.
*/
class XmlSitemapCustomAddForm extends ConfigFormBase {
/**
......
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