summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2018-06-14 16:09:11 (GMT)
committerAlex Pott2018-06-14 16:09:11 (GMT)
commitad9016461990bbe165dc0c156d952b94fb65db65 (patch)
tree3ab921657f53ffaf078c64919890c9632ca600cf
parent845da7492b09c4fd7daf5954df3da6c64d4777cb (diff)
Issue #2863842 by GoZ, Lendude, vaplas, dawehner, alexpott, borisson_, larowlan: Convert web tests to browser tests for search module
-rw-r--r--core/modules/search/tests/src/Functional/SearchAdvancedSearchFormTest.php (renamed from core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php)18
-rw-r--r--core/modules/search/tests/src/Functional/SearchBlockTest.php (renamed from core/modules/search/src/Tests/SearchBlockTest.php)4
-rw-r--r--core/modules/search/tests/src/Functional/SearchCommentTest.php (renamed from core/modules/search/src/Tests/SearchCommentTest.php)22
-rw-r--r--core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php (renamed from core/modules/search/src/Tests/SearchConfigSettingsFormTest.php)16
-rw-r--r--core/modules/search/tests/src/Functional/SearchEmbedFormTest.php (renamed from core/modules/search/src/Tests/SearchEmbedFormTest.php)2
-rw-r--r--core/modules/search/tests/src/Functional/SearchLanguageTest.php (renamed from core/modules/search/src/Tests/SearchLanguageTest.php)8
-rw-r--r--core/modules/search/tests/src/Functional/SearchNodeUpdateAndDeletionTest.php (renamed from core/modules/search/src/Tests/SearchNodeUpdateAndDeletionTest.php)2
-rw-r--r--core/modules/search/tests/src/Functional/SearchNumberMatchingTest.php (renamed from core/modules/search/src/Tests/SearchNumberMatchingTest.php)6
-rw-r--r--core/modules/search/tests/src/Functional/SearchNumbersTest.php (renamed from core/modules/search/src/Tests/SearchNumbersTest.php)6
-rw-r--r--core/modules/search/tests/src/Functional/SearchPageCacheTagsTest.php (renamed from core/modules/search/src/Tests/SearchPageCacheTagsTest.php)13
-rw-r--r--core/modules/search/tests/src/Functional/SearchPageTextTest.php (renamed from core/modules/search/src/Tests/SearchPageTextTest.php)8
-rw-r--r--core/modules/search/tests/src/Functional/SearchPreprocessLangcodeTest.php (renamed from core/modules/search/src/Tests/SearchPreprocessLangcodeTest.php)8
-rw-r--r--core/modules/search/tests/src/Functional/SearchQueryAlterTest.php (renamed from core/modules/search/src/Tests/SearchQueryAlterTest.php)2
-rw-r--r--core/modules/search/tests/src/Functional/SearchRankingTest.php (renamed from core/modules/search/src/Tests/SearchRankingTest.php)4
-rw-r--r--core/modules/search/tests/src/Functional/SearchTestBase.php56
15 files changed, 84 insertions, 91 deletions
diff --git a/core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php b/core/modules/search/tests/src/Functional/SearchAdvancedSearchFormTest.php
index ad00b52..29c3817 100644
--- a/core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php
+++ b/core/modules/search/tests/src/Functional/SearchAdvancedSearchFormTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\search\Tests;
+namespace Drupal\Tests\search\Functional;
/**
* Indexes content and tests the advanced search form.
@@ -53,14 +53,14 @@ class SearchAdvancedSearchFormTest extends SearchTestBase {
// Search for the title of the node with a POST query.
$edit = ['or' => $this->node->label()];
- $this->drupalPostForm('search/node', $edit, t('Advanced search'));
+ $this->drupalPostForm('search/node', $edit, 'edit-submit--2');
$this->assertText($this->node->label(), 'Basic page node is found with POST query.');
// Search by node type.
- $this->drupalPostForm('search/node', array_merge($edit, ['type[page]' => 'page']), t('Advanced search'));
+ $this->drupalPostForm('search/node', array_merge($edit, ['type[page]' => 'page']), 'edit-submit--2');
$this->assertText($this->node->label(), 'Basic page node is found with POST query and type:page.');
- $this->drupalPostForm('search/node', array_merge($edit, ['type[article]' => 'article']), t('Advanced search'));
+ $this->drupalPostForm('search/node', array_merge($edit, ['type[article]' => 'article']), 'edit-submit--2');
$this->assertText('search yielded no results', 'Article node is not found with POST query and type:article.');
}
@@ -75,7 +75,7 @@ class SearchAdvancedSearchFormTest extends SearchTestBase {
'negative' => 'fish snake',
'type[page]' => 'page',
];
- $this->drupalPostForm('search/node', $edit, t('Advanced search'));
+ $this->drupalPostForm('search/node', $edit, 'edit-submit--2');
// Test that the encoded query appears in the page title. Only test the
// part not including the quote, because assertText() cannot seem to find
@@ -86,11 +86,11 @@ class SearchAdvancedSearchFormTest extends SearchTestBase {
foreach ($edit as $key => $value) {
if ($key != 'type[page]') {
$elements = $this->xpath('//input[@name=:name]', [':name' => $key]);
- $this->assertTrue(isset($elements[0]) && $elements[0]['value'] == $value, "Field $key is set to $value");
+ $this->assertTrue(isset($elements[0]) && $elements[0]->getValue() == $value, "Field $key is set to $value");
}
else {
$elements = $this->xpath('//input[@name=:name]', [':name' => $key]);
- $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), "Field $key is checked");
+ $this->assertTrue(isset($elements[0]) && !empty($elements[0]->getAttribute('checked')), "Field $key is checked");
}
}
@@ -98,12 +98,12 @@ class SearchAdvancedSearchFormTest extends SearchTestBase {
// search box, and verify that the advanced form is not filled out.
// (It shouldn't be filled out unless you submit values in those fields.)
$edit2 = ['keys' => 'cat dog OR gerbil -fish -snake'];
- $this->drupalPostForm('search/node', $edit2, t('Advanced search'));
+ $this->drupalPostForm('search/node', $edit2, 'edit-submit--2');
$this->assertText('Search for cat dog OR gerbil -fish -snake');
foreach ($edit as $key => $value) {
if ($key != 'type[page]') {
$elements = $this->xpath('//input[@name=:name]', [':name' => $key]);
- $this->assertFalse(isset($elements[0]) && $elements[0]['value'] == $value, "Field $key is not set to $value");
+ $this->assertFalse(isset($elements[0]) && $elements[0]->getValue() == $value, "Field $key is not set to $value");
}
}
}
diff --git a/core/modules/search/src/Tests/SearchBlockTest.php b/core/modules/search/tests/src/Functional/SearchBlockTest.php
index 21afda7..3c6b746 100644
--- a/core/modules/search/src/Tests/SearchBlockTest.php
+++ b/core/modules/search/tests/src/Functional/SearchBlockTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\search\Tests;
+namespace Drupal\Tests\search\Functional;
/**
* Tests if the search form block is available.
@@ -31,7 +31,7 @@ class SearchBlockTest extends SearchTestBase {
// Test availability of the search block in the admin "Place blocks" list.
$this->drupalGet('admin/structure/block');
- $this->clickLinkPartialName('Place block');
+ $this->getSession()->getPage()->findLink('Place block')->click();
$this->assertLinkByHref('/admin/structure/block/add/search_form_block/classy', 0,
'Did not find the search block in block candidate list.');
diff --git a/core/modules/search/src/Tests/SearchCommentTest.php b/core/modules/search/tests/src/Functional/SearchCommentTest.php
index 7047429..23167ed 100644
--- a/core/modules/search/src/Tests/SearchCommentTest.php
+++ b/core/modules/search/tests/src/Functional/SearchCommentTest.php
@@ -1,10 +1,12 @@
<?php
-namespace Drupal\search\Tests;
+namespace Drupal\Tests\search\Functional;
+use Behat\Mink\Exception\ResponseTextException;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\field\Entity\FieldConfig;
+use Drupal\Tests\Traits\Core\CronRunTrait;
use Drupal\user\RoleInterface;
use Drupal\filter\Entity\FilterFormat;
@@ -16,6 +18,7 @@ use Drupal\filter\Entity\FilterFormat;
class SearchCommentTest extends SearchTestBase {
use CommentTestTrait;
+ use CronRunTrait;
/**
* Modules to enable.
@@ -298,15 +301,18 @@ class SearchCommentTest extends SearchTestBase {
];
$this->drupalPostForm('search/node', $edit, t('Search'));
- if ($assume_access) {
- $expected_node_result = $this->assertText($this->node->label());
- $expected_comment_result = $this->assertText($this->commentSubject);
+ try {
+ if ($assume_access) {
+ $this->assertSession()->pageTextContains($this->node->label());
+ $this->assertSession()->pageTextContains($this->commentSubject);
+ }
+ else {
+ $this->assertSession()->pageTextContains(t('Your search yielded no results.'));
+ }
}
- else {
- $expected_node_result = $this->assertText(t('Your search yielded no results.'));
- $expected_comment_result = $this->assertText(t('Your search yielded no results.'));
+ catch (ResponseTextException $exception) {
+ $this->fail($message);
}
- $this->assertTrue($expected_node_result && $expected_comment_result, $message);
}
/**
diff --git a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php
index b081b85..f404f8f 100644
--- a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php
+++ b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\search\Tests;
+namespace Drupal\Tests\search\Functional;
use Drupal\Core\Url;
use Drupal\search\Entity\SearchPage;
@@ -217,9 +217,9 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
public function testDefaultSearchPageOrdering() {
$this->drupalGet('search');
$elements = $this->xpath('//*[contains(@class, :class)]//a', [':class' => 'tabs primary']);
- $this->assertIdentical((string) $elements[0]['href'], \Drupal::url('search.view_node_search'));
- $this->assertIdentical((string) $elements[1]['href'], \Drupal::url('search.view_dummy_search_type'));
- $this->assertIdentical((string) $elements[2]['href'], \Drupal::url('search.view_user_search'));
+ $this->assertIdentical($elements[0]->getAttribute('href'), \Drupal::url('search.view_node_search'));
+ $this->assertIdentical($elements[1]->getAttribute('href'), \Drupal::url('search.view_dummy_search_type'));
+ $this->assertIdentical($elements[2]->getAttribute('href'), \Drupal::url('search.view_user_search'));
}
/**
@@ -272,8 +272,8 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
// Ensure both search pages have their tabs displayed.
$this->drupalGet('search');
$elements = $this->xpath('//*[contains(@class, :class)]//a', [':class' => 'tabs primary']);
- $this->assertIdentical((string) $elements[0]['href'], Url::fromRoute('search.view_' . $first_id)->toString());
- $this->assertIdentical((string) $elements[1]['href'], Url::fromRoute('search.view_' . $second_id)->toString());
+ $this->assertIdentical($elements[0]->getAttribute('href'), Url::fromRoute('search.view_' . $first_id)->toString());
+ $this->assertIdentical($elements[1]->getAttribute('href'), Url::fromRoute('search.view_' . $second_id)->toString());
// Switch the weight of the search pages and check the order of the tabs.
$edit = [
@@ -283,8 +283,8 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
$this->drupalPostForm('admin/config/search/pages', $edit, t('Save configuration'));
$this->drupalGet('search');
$elements = $this->xpath('//*[contains(@class, :class)]//a', [':class' => 'tabs primary']);
- $this->assertIdentical((string) $elements[0]['href'], Url::fromRoute('search.view_' . $second_id)->toString());
- $this->assertIdentical((string) $elements[1]['href'], Url::fromRoute('search.view_' . $first_id)->toString());
+ $this->assertIdentical($elements[0]->getAttribute('href'), Url::fromRoute('search.view_' . $second_id)->toString());
+ $this->assertIdentical($elements[1]->getAttribute('href'), Url::fromRoute('search.view_' . $first_id)->toString());
// Check the initial state of the search pages.
$this->drupalGet('admin/config/search/pages');
diff --git a/core/modules/search/src/Tests/SearchEmbedFormTest.php b/core/modules/search/tests/src/Functional/SearchEmbedFormTest.php
index 5f3fbea..89f0d0d 100644
--- a/core/modules/search/src/Tests/SearchEmbedFormTest.php
+++ b/core/modules/search/tests/src/Functional/SearchEmbedFormTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\search\Tests;
+namespace Drupal\Tests\search\Functional;
/**
* Verifies that a form embedded in search results works.
diff --git a/core/modules/search/src/Tests/SearchLanguageTest.php b/core/modules/search/tests/src/Functional/SearchLanguageTest.php
index ec15085..d6e6307 100644
--- a/core/modules/search/src/Tests/SearchLanguageTest.php
+++ b/core/modules/search/tests/src/Functional/SearchLanguageTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\search\Tests;
+namespace Drupal\Tests\search\Functional;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\language\Entity\ConfigurableLanguage;
@@ -99,12 +99,12 @@ class SearchLanguageTest extends SearchTestBase {
$this->assertText(t('French'), 'French is a possible choice.');
// Ensure selecting no language does not make the query different.
- $this->drupalPostForm('search/node', [], t('Advanced search'));
+ $this->drupalPostForm('search/node', [], 'edit-submit--2');
$this->assertUrl(\Drupal::url('search.view_node_search', [], ['query' => ['keys' => ''], 'absolute' => TRUE]), [], 'Correct page redirection, no language filtering.');
// Pick French and ensure it is selected.
$edit = ['language[fr]' => TRUE];
- $this->drupalPostForm('search/node', $edit, t('Advanced search'));
+ $this->drupalPostForm('search/node', $edit, 'edit-submit--2');
// Get the redirected URL.
$url = $this->getUrl();
$parts = parse_url($url);
@@ -113,7 +113,7 @@ class SearchLanguageTest extends SearchTestBase {
// Search for keyword node and language filter as Spanish.
$edit = ['keys' => 'node', 'language[es]' => TRUE];
- $this->drupalPostForm('search/node', $edit, t('Advanced search'));
+ $this->drupalPostForm('search/node', $edit, 'edit-submit--2');
// Check for Spanish results.
$this->assertLink('Second node this is the Spanish title', 0, 'Second node Spanish title found in search results');
$this->assertLink('Third node es', 0, 'Third node Spanish found in search results');
diff --git a/core/modules/search/src/Tests/SearchNodeUpdateAndDeletionTest.php b/core/modules/search/tests/src/Functional/SearchNodeUpdateAndDeletionTest.php
index c19814e..0e9d358 100644
--- a/core/modules/search/src/Tests/SearchNodeUpdateAndDeletionTest.php
+++ b/core/modules/search/tests/src/Functional/SearchNodeUpdateAndDeletionTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\search\Tests;
+namespace Drupal\Tests\search\Functional;
/**
* Tests search index is updated properly when nodes are removed or updated.
diff --git a/core/modules/search/src/Tests/SearchNumberMatchingTest.php b/core/modules/search/tests/src/Functional/SearchNumberMatchingTest.php
index 7671c7b..0de0c53 100644
--- a/core/modules/search/src/Tests/SearchNumberMatchingTest.php
+++ b/core/modules/search/tests/src/Functional/SearchNumberMatchingTest.php
@@ -1,8 +1,9 @@
<?php
-namespace Drupal\search\Tests;
+namespace Drupal\Tests\search\Functional;
use Drupal\Core\Language\LanguageInterface;
+use Drupal\Tests\Traits\Core\CronRunTrait;
/**
* Tests that numbers can be searched with more complex matching.
@@ -10,6 +11,9 @@ use Drupal\Core\Language\LanguageInterface;
* @group search
*/
class SearchNumberMatchingTest extends SearchTestBase {
+
+ use CronRunTrait;
+
/**
* A user with permission to administer nodes.
*
diff --git a/core/modules/search/src/Tests/SearchNumbersTest.php b/core/modules/search/tests/src/Functional/SearchNumbersTest.php
index dbb5039..f182810 100644
--- a/core/modules/search/src/Tests/SearchNumbersTest.php
+++ b/core/modules/search/tests/src/Functional/SearchNumbersTest.php
@@ -1,8 +1,9 @@
<?php
-namespace Drupal\search\Tests;
+namespace Drupal\Tests\search\Functional;
use Drupal\Core\Language\LanguageInterface;
+use Drupal\Tests\Traits\Core\CronRunTrait;
/**
* Tests that numbers can be searched.
@@ -10,6 +11,9 @@ use Drupal\Core\Language\LanguageInterface;
* @group search
*/
class SearchNumbersTest extends SearchTestBase {
+
+ use CronRunTrait;
+
/**
* A user with permission to administer nodes.
*
diff --git a/core/modules/search/src/Tests/SearchPageCacheTagsTest.php b/core/modules/search/tests/src/Functional/SearchPageCacheTagsTest.php
index 0ea0e94..799add6 100644
--- a/core/modules/search/src/Tests/SearchPageCacheTagsTest.php
+++ b/core/modules/search/tests/src/Functional/SearchPageCacheTagsTest.php
@@ -1,8 +1,9 @@
<?php
-namespace Drupal\search\Tests;
+namespace Drupal\Tests\search\Functional;
use Drupal\Core\Cache\Cache;
+use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
/**
* Tests the search_page entity cache tags on the search results pages.
@@ -11,6 +12,8 @@ use Drupal\Core\Cache\Cache;
*/
class SearchPageCacheTagsTest extends SearchTestBase {
+ use AssertPageCacheContextsAndTagsTrait;
+
/**
* {@inheritdoc}
*/
@@ -100,8 +103,8 @@ class SearchPageCacheTagsTest extends SearchTestBase {
$this->drupalGet('search/user');
$this->assertCacheTag('config:search.page.user_search');
$this->assertCacheTag('user_list');
- $this->assertNoCacheTag('search_index');
- $this->assertNoCacheTag('search_index:user_search');
+ $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'search_index');
+ $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'search_index:user_search');
// User search results.
$edit['keys'] = $this->searchingUser->getUsername();
@@ -109,8 +112,8 @@ class SearchPageCacheTagsTest extends SearchTestBase {
$this->assertCacheTag('config:search.page.user_search');
$this->assertCacheTag('user_list');
$this->assertCacheTag('user:2');
- $this->assertNoCacheTag('search_index');
- $this->assertNoCacheTag('search_index:user_search');
+ $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'search_index');
+ $this->assertSession()->responseHeaderNotContains('X-Drupal-Cache-Tags', 'search_index:user_search');
}
/**
diff --git a/core/modules/search/src/Tests/SearchPageTextTest.php b/core/modules/search/tests/src/Functional/SearchPageTextTest.php
index 95d097d..184742e 100644
--- a/core/modules/search/src/Tests/SearchPageTextTest.php
+++ b/core/modules/search/tests/src/Functional/SearchPageTextTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\search\Tests;
+namespace Drupal\Tests\search\Functional;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Unicode;
@@ -90,7 +90,7 @@ class SearchPageTextTest extends SearchTestBase {
$search_terms = 'Hear nothing > "see nothing" `feel' . " '1982.";
$edit['keys'] = $search_terms;
$this->drupalPostForm('search/node', $edit, t('Search'));
- $actual_title = (string) current($this->xpath('//title'));
+ $actual_title = $this->xpath('//title')[0]->getText();
$this->assertEqual($actual_title, Html::decodeEntities(t($title_source, ['@keywords' => Unicode::truncate($search_terms, 60, TRUE, TRUE)])), 'Search page title is correct');
$edit['keys'] = $this->searchingUser->getUsername();
@@ -133,9 +133,9 @@ class SearchPageTextTest extends SearchTestBase {
// Make sure the "Please enter some keywords" message is NOT displayed if
// you use "or" words or phrases in Advanced Search.
- $this->drupalPostForm('search/node', ['or' => $this->randomMachineName() . ' ' . $this->randomMachineName()], t('Advanced search'));
+ $this->drupalPostForm('search/node', ['or' => $this->randomMachineName() . ' ' . $this->randomMachineName()], 'edit-submit--2');
$this->assertNoText(t('Please enter some keywords'), 'With advanced OR keywords entered, no keywords message is not displayed on node page');
- $this->drupalPostForm('search/node', ['phrase' => '"' . $this->randomMachineName() . '" "' . $this->randomMachineName() . '"'], t('Advanced search'));
+ $this->drupalPostForm('search/node', ['phrase' => '"' . $this->randomMachineName() . '" "' . $this->randomMachineName() . '"'], 'edit-submit--2');
$this->assertNoText(t('Please enter some keywords'), 'With advanced phrase entered, no keywords message is not displayed on node page');
// Verify that if you search for a too-short keyword, you get the right
diff --git a/core/modules/search/src/Tests/SearchPreprocessLangcodeTest.php b/core/modules/search/tests/src/Functional/SearchPreprocessLangcodeTest.php
index ab264a1..54779d3 100644
--- a/core/modules/search/src/Tests/SearchPreprocessLangcodeTest.php
+++ b/core/modules/search/tests/src/Functional/SearchPreprocessLangcodeTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\search\Tests;
+namespace Drupal\Tests\search\Functional;
/**
* Tests that the search preprocessing uses the correct language code.
@@ -54,7 +54,7 @@ class SearchPreprocessLangcodeTest extends SearchTestBase {
// function. If you search for text that is in the node, preprocess is
// not invoked on the node during the search excerpt generation.
$edit = ['or' => 'Additional text'];
- $this->drupalPostForm('search/node', $edit, t('Advanced search'));
+ $this->drupalPostForm('search/node', $edit, 'edit-submit--2');
// Checks if the langcode message has been set by hook_search_preprocess().
$this->assertText('Langcode Preprocess Test: en');
@@ -81,7 +81,7 @@ class SearchPreprocessLangcodeTest extends SearchTestBase {
// Search for the title of the node with a POST query.
$edit = ['or' => 'testing'];
- $this->drupalPostForm('search/node', $edit, t('Advanced search'));
+ $this->drupalPostForm('search/node', $edit, 'edit-submit--2');
// Check if the node has been found.
$this->assertText('Search results');
@@ -89,7 +89,7 @@ class SearchPreprocessLangcodeTest extends SearchTestBase {
// Search for the same node using a different query.
$edit = ['or' => 'test'];
- $this->drupalPostForm('search/node', $edit, t('Advanced search'));
+ $this->drupalPostForm('search/node', $edit, 'edit-submit--2');
// Check if the node has been found.
$this->assertText('Search results');
diff --git a/core/modules/search/src/Tests/SearchQueryAlterTest.php b/core/modules/search/tests/src/Functional/SearchQueryAlterTest.php
index 66269dd..1fcf22e 100644
--- a/core/modules/search/src/Tests/SearchQueryAlterTest.php
+++ b/core/modules/search/tests/src/Functional/SearchQueryAlterTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\search\Tests;
+namespace Drupal\Tests\search\Functional;
/**
* Tests that the node search query can be altered via the query alter hook.
diff --git a/core/modules/search/src/Tests/SearchRankingTest.php b/core/modules/search/tests/src/Functional/SearchRankingTest.php
index 55da9ac..f7e17c4 100644
--- a/core/modules/search/src/Tests/SearchRankingTest.php
+++ b/core/modules/search/tests/src/Functional/SearchRankingTest.php
@@ -1,12 +1,13 @@
<?php
-namespace Drupal\search\Tests;
+namespace Drupal\Tests\search\Functional;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Core\Url;
use Drupal\filter\Entity\FilterFormat;
use Drupal\search\Entity\SearchPage;
+use Drupal\Tests\Traits\Core\CronRunTrait;
/**
* Indexes content and tests ranking factors.
@@ -16,6 +17,7 @@ use Drupal\search\Entity\SearchPage;
class SearchRankingTest extends SearchTestBase {
use CommentTestTrait;
+ use CronRunTrait;
/**
* The node search page.
diff --git a/core/modules/search/tests/src/Functional/SearchTestBase.php b/core/modules/search/tests/src/Functional/SearchTestBase.php
index c0557d4..570658d 100644
--- a/core/modules/search/tests/src/Functional/SearchTestBase.php
+++ b/core/modules/search/tests/src/Functional/SearchTestBase.php
@@ -3,7 +3,6 @@
namespace Drupal\Tests\search\Functional;
use Drupal\Tests\BrowserTestBase;
-use Drupal\Component\Render\FormattableMarkup;
/**
* Defines the common search test code.
@@ -28,17 +27,7 @@ abstract class SearchTestBase extends BrowserTestBase {
}
/**
- * Simulates submission of a form using GET instead of POST.
- *
- * Forms that use the GET method cannot be submitted with
- * WebTestBase::drupalPostForm(), which explicitly uses POST to submit the
- * form. So this method finds the form, verifies that it has input fields and
- * a submit button matching the inputs to this method, and then calls
- * WebTestBase::drupalGet() to simulate the form submission to the 'action'
- * URL of the form (if set, or the current URL if not).
- *
- * See WebTestBase::drupalPostForm() for more detailed documentation of the
- * function parameters.
+ * Submission of a form via press submit button.
*
* @param string $path
* Location of the form to be submitted: either a Drupal path, absolute
@@ -51,42 +40,27 @@ abstract class SearchTestBase extends BrowserTestBase {
* this does not support AJAX.
* @param string $form_html_id
* (optional) HTML ID of the form, to disambiguate.
+ *
+ * @throws \Behat\Mink\Exception\ElementNotFoundException
+ *
+ * @todo: Replace after https://www.drupal.org/project/drupal/issues/2887411
*/
protected function submitGetForm($path, $edit, $submit, $form_html_id = NULL) {
if (isset($path)) {
$this->drupalGet($path);
}
- if ($this->parse()) {
- // Iterate over forms to find one that matches $edit and $submit.
- $edit_save = $edit;
- $xpath = '//form';
- if (!empty($form_html_id)) {
- $xpath .= "[@id='" . $form_html_id . "']";
- }
- $forms = $this->xpath($xpath);
- foreach ($forms as $form) {
- // Try to set the fields of this form as specified in $edit.
- $edit = $edit_save;
- $post = [];
- $upload = [];
- $submit_matches = $this->handleForm($post, $edit, $upload, $submit, $form);
- if (!$edit && $submit_matches) {
- // Everything matched, so "submit" the form.
- $action = isset($form['action']) ? $this->getAbsoluteUrl((string) $form['action']) : NULL;
- $this->drupalGet($action, ['query' => $post]);
- return;
- }
- }
-
- // We have not found a form which contained all fields of $edit and
- // the submit button.
- foreach ($edit as $name => $value) {
- $this->fail(new FormattableMarkup('Failed to set field @name to @value', ['@name' => $name, '@value' => $value]));
- }
- $this->assertTrue($submit_matches, format_string('Found the @submit button', ['@submit' => $submit]));
- $this->fail(format_string('Found the requested form fields at @path', ['@path' => $path]));
+ $page = $this->getSession()->getPage();
+ $wrapper = $page;
+ if ($form_html_id) {
+ $wrapper = $page->find('css', '#' . $form_html_id);
+ }
+ $button = $wrapper->findButton($submit);
+ $form = $this->assertSession()->elementExists('xpath', './ancestor::form', $button);
+ foreach ($edit as $selector => $value) {
+ $form->fillField($selector, $value);
}
+ $button->press();
}
}