Unverified Commit 24192468 authored by alexpott's avatar alexpott

Issue #2980107 by eliclaggett, vaplas, Lendude, borisson_, xjm: Replace...

Issue #2980107 by eliclaggett, vaplas, Lendude, borisson_, xjm: Replace Functional\SearchTestBase on BrowserTestBase?
parent 92e2f1a3
......@@ -2,12 +2,19 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Indexes content and tests the advanced search form.
*
* @group search
*/
class SearchAdvancedSearchFormTest extends SearchTestBase {
class SearchAdvancedSearchFormTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['node', 'search', 'dblog'];
/**
* A node to use for testing.
......@@ -18,6 +25,10 @@ class SearchAdvancedSearchFormTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
// Create and log in user.
$test_user = $this->drupalCreateUser(['access content', 'search content', 'use advanced search', 'administer nodes']);
$this->drupalLogin($test_user);
......
......@@ -2,19 +2,19 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Tests if the search form block is available.
*
* @group search
*/
class SearchBlockTest extends SearchTestBase {
class SearchBlockTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = ['block'];
protected static $modules = ['block', 'node', 'search', 'dblog'];
protected function setUp() {
parent::setUp();
......
......@@ -4,6 +4,7 @@
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Tests\BrowserTestBase;
/**
* Tests that comment count display toggles properly on comment status of node.
......@@ -17,16 +18,14 @@
*
* @group search
*/
class SearchCommentCountToggleTest extends SearchTestBase {
class SearchCommentCountToggleTest extends BrowserTestBase {
use CommentTestTrait;
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = ['node', 'comment'];
protected static $modules = ['node', 'comment', 'search', 'dblog'];
/**
* A user with permission to search and post comments.
......@@ -45,6 +44,8 @@ class SearchCommentCountToggleTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
// Create searching user.
$this->searchingUser = $this->drupalCreateUser(['search content', 'access content', 'access comments', 'post comments', 'skip comment approval']);
......
......@@ -6,6 +6,7 @@
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\field\Entity\FieldConfig;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\Traits\Core\CronRunTrait;
use Drupal\user\RoleInterface;
use Drupal\filter\Entity\FilterFormat;
......@@ -15,17 +16,15 @@
*
* @group search
*/
class SearchCommentTest extends SearchTestBase {
class SearchCommentTest extends BrowserTestBase {
use CommentTestTrait;
use CronRunTrait;
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = ['filter', 'node', 'comment'];
protected static $modules = ['filter', 'node', 'comment', 'search'];
/**
* Test subject for comments.
......@@ -58,6 +57,9 @@ class SearchCommentTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
$full_html_format = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
......
......@@ -4,20 +4,19 @@
use Drupal\Core\Url;
use Drupal\search\Entity\SearchPage;
use Drupal\Tests\BrowserTestBase;
/**
* Verify the search config settings form.
*
* @group search
*/
class SearchConfigSettingsFormTest extends SearchTestBase {
class SearchConfigSettingsFormTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = ['block', 'search_extra_type', 'test_page_test'];
protected static $modules = ['block', 'dblog', 'node', 'search', 'search_extra_type', 'test_page_test'];
/**
* User who can search and administer search.
......@@ -36,6 +35,8 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Log in as a user that can create and search content.
$this->searchUser = $this->drupalCreateUser(['search content', 'administer search', 'administer nodes', 'bypass node access', 'access user profiles', 'administer users', 'administer blocks', 'access site reports']);
$this->drupalLogin($this->searchUser);
......
......@@ -3,24 +3,25 @@
namespace Drupal\Tests\search\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\BrowserTestBase;
/**
* Tests searching with date filters that exclude some translations.
*
* @group search
*/
class SearchDateIntervalTest extends SearchTestBase {
class SearchDateIntervalTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var string[]
* {@inheritdoc}
*/
public static $modules = ['language', 'search_date_query_alter'];
protected static $modules = ['language', 'search_date_query_alter', 'node', 'search'];
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Create and log in user.
$test_user = $this->drupalCreateUser(['access content', 'search content', 'use advanced search', 'administer nodes', 'administer languages', 'access administration pages', 'administer site configuration']);
$this->drupalLogin($test_user);
......
......@@ -2,19 +2,19 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Verifies that a form embedded in search results works.
*
* @group search
*/
class SearchEmbedFormTest extends SearchTestBase {
class SearchEmbedFormTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = ['search_embedded_form'];
protected static $modules = ['node', 'search', 'search_embedded_form'];
/**
* Node used for testing.
......@@ -33,6 +33,8 @@ class SearchEmbedFormTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Create a user and a node, and update the search index.
$test_user = $this->drupalCreateUser(['access content', 'search content', 'administer nodes']);
$this->drupalLogin($test_user);
......
......@@ -2,17 +2,26 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Tests that searching for a phrase gets the correct page count.
*
* @group search
*/
class SearchExactTest extends SearchTestBase {
class SearchExactTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['node', 'search'];
/**
* Tests that the correct number of pager links are found for both keywords and phrases.
*/
public function testExactQuery() {
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Log in with sufficient privileges.
$user = $this->drupalCreateUser(['create page content', 'search content']);
$this->drupalLogin($user);
......
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Component\Utility\Html;
use Drupal\Tests\BrowserTestBase;
/**
* Verify the search without keywords set and extra conditions.
......@@ -13,14 +14,12 @@
*
* @group search
*/
class SearchKeywordsConditionsTest extends SearchTestBase {
class SearchKeywordsConditionsTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = ['comment', 'search_extra_type', 'test_page_test'];
protected static $modules = ['comment', 'search', 'search_extra_type', 'test_page_test'];
/**
* A user with permission to search and post comments.
......
......@@ -4,20 +4,19 @@
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\BrowserTestBase;
/**
* Tests advanced search with different languages added.
*
* @group search
*/
class SearchLanguageTest extends SearchTestBase {
class SearchLanguageTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = ['language'];
protected static $modules = ['language', 'node', 'search'];
/**
* Array of nodes available to search.
......@@ -29,6 +28,8 @@ class SearchLanguageTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Create and log in user.
$test_user = $this->drupalCreateUser(['access content', 'search content', 'use advanced search', 'administer nodes', 'administer languages', 'access administration pages', 'administer site configuration']);
$this->drupalLogin($test_user);
......
......@@ -4,13 +4,14 @@
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\BrowserTestBase;
/**
* Tests entities with multilingual fields.
*
* @group search
*/
class SearchMultilingualEntityTest extends SearchTestBase {
class SearchMultilingualEntityTest extends BrowserTestBase {
/**
* List of searchable nodes.
......@@ -26,11 +27,16 @@ class SearchMultilingualEntityTest extends SearchTestBase {
*/
protected $plugin;
public static $modules = ['language', 'locale', 'comment'];
/**
* {@inheritdoc}
*/
protected static $modules = ['language', 'locale', 'comment', 'node', 'search'];
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Create a user who can administer search, do searches, see the status
// report, and administer cron. Log in.
$user = $this->drupalCreateUser(['administer search', 'search content', 'use advanced search', 'access content', 'access site reports', 'administer site configuration']);
......
......@@ -2,12 +2,19 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Tests search functionality with diacritics.
*
* @group search
*/
class SearchNodeDiacriticsTest extends SearchTestBase {
class SearchNodeDiacriticsTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['node', 'search'];
/**
* A user with permission to use advanced search.
......@@ -18,6 +25,9 @@ class SearchNodeDiacriticsTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
node_access_rebuild();
// Create a test user and log in.
......
......@@ -2,12 +2,19 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Tests search functionality with punctuation and HTML entities.
*
* @group search
*/
class SearchNodePunctuationTest extends SearchTestBase {
class SearchNodePunctuationTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['node', 'search'];
/**
* A user with permission to use advanced search.
......@@ -18,8 +25,10 @@ class SearchNodePunctuationTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
node_access_rebuild();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
node_access_rebuild();
// Create a test user and log in.
$this->testUser = $this->drupalCreateUser(['access content', 'search content', 'use advanced search', 'access user profiles']);
$this->drupalLogin($this->testUser);
......
......@@ -2,19 +2,19 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Tests search index is updated properly when nodes are removed or updated.
*
* @group search
*/
class SearchNodeUpdateAndDeletionTest extends SearchTestBase {
class SearchNodeUpdateAndDeletionTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = [];
protected static $modules = ['node', 'search'];
/**
* A user with permission to access and search content.
......@@ -26,6 +26,8 @@ class SearchNodeUpdateAndDeletionTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Create a test user and log in.
$this->testUser = $this->drupalCreateUser(['access content', 'search content']);
$this->drupalLogin($this->testUser);
......
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\Traits\Core\CronRunTrait;
/**
......@@ -10,10 +11,15 @@
*
* @group search
*/
class SearchNumberMatchingTest extends SearchTestBase {
class SearchNumberMatchingTest extends BrowserTestBase {
use CronRunTrait;
/**
* {@inheritdoc}
*/
protected static $modules = ['dblog', 'node', 'search'];
/**
* A user with permission to administer nodes.
*
......@@ -51,6 +57,8 @@ class SearchNumberMatchingTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
$this->testUser = $this->drupalCreateUser(['search content', 'access content', 'administer nodes', 'access site reports']);
$this->drupalLogin($this->testUser);
......
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\Traits\Core\CronRunTrait;
/**
......@@ -10,10 +11,15 @@
*
* @group search
*/
class SearchNumbersTest extends SearchTestBase {
class SearchNumbersTest extends BrowserTestBase {
use CronRunTrait;
/**
* {@inheritdoc}
*/
protected static $modules = ['dblog', 'node', 'search'];
/**
* A user with permission to administer nodes.
*
......@@ -57,6 +63,8 @@ class SearchNumbersTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
$this->testUser = $this->drupalCreateUser(['search content', 'access content', 'administer nodes', 'access site reports']);
$this->drupalLogin($this->testUser);
......
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Core\Cache\Cache;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
/**
......@@ -10,10 +11,15 @@
*
* @group search
*/
class SearchPageCacheTagsTest extends SearchTestBase {
class SearchPageCacheTagsTest extends BrowserTestBase {
use AssertPageCacheContextsAndTagsTrait;
/**
* {@inheritdoc}
*/
protected static $modules = ['node', 'search'];
/**
* {@inheritdoc}
*/
......@@ -39,6 +45,8 @@ class SearchPageCacheTagsTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Create user.
$this->searchingUser = $this->drupalCreateUser(['search content', 'access user profiles']);
......
......@@ -2,6 +2,8 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Tests if the result page can be overridden.
*
......@@ -10,14 +12,12 @@
*
* @group search
*/
class SearchPageOverrideTest extends SearchTestBase {
class SearchPageOverrideTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = ['search_extra_type'];
protected static $modules = ['search', 'search_extra_type'];
/**
* A user with permission to administer search.
......
......@@ -4,26 +4,26 @@
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Unicode;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the search help text and search page text.
*
* @group search
*/
class SearchPageTextTest extends SearchTestBase {
class SearchPageTextTest extends BrowserTestBase {
/**
* A user with permission to use advanced search.
*
* @var \Drupal\user\UserInterface
* {@inheritdoc}
*/
protected $searchingUser;
protected static $modules = ['block', 'node', 'search'];
/**
* Modules to enable.
* A user with permission to use advanced search.
*
* @var string[]
* @var \Drupal\user\UserInterface
*/
public static $modules = ['block'];
protected $searchingUser;
/**
* {@inheritdoc}
......@@ -31,6 +31,8 @@ class SearchPageTextTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
// Create user.
$this->searchingUser = $this->drupalCreateUser(['search content', 'access user profiles', 'use advanced search']);
$this->drupalPlaceBlock('local_tasks_block');
......
......@@ -2,19 +2,19 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Tests that the search preprocessing uses the correct language code.
*
* @group search
*/
class SearchPreprocessLangcodeTest extends SearchTestBase {
class SearchPreprocessLangcodeTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = ['search_langcode_test'];
protected static $modules = ['node', 'search', 'search_langcode_test'];
/**
* Test node for searching.
......@@ -26,6 +26,8 @@ class SearchPreprocessLangcodeTest extends SearchTestBase {
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
$web_user = $this->drupalCreateUser([
'create page content',
'edit own page content',
......
......@@ -2,23 +2,27 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Tests that the node search query can be altered via the query alter hook.
*
* @group search
*/
class SearchQueryAlterTest extends SearchTestBase {
class SearchQueryAlterTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = ['search_query_alter'];
protected static $modules = ['node', 'search', 'search_query_alter'];
/**
* Tests that the query alter works.
*/
public function testQueryAlter() {
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
// Log in with sufficient privileges.
$this->drupalLogin($this->drupalCreateUser(['create page content', 'search content']));
......
......@@ -7,6 +7,7 @@
use Drupal\Core\Url;
use Drupal\filter\Entity\FilterFormat;
use Drupal\search\Entity\SearchPage;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\Traits\Core\CronRunTrait;