Skip to content
Snippets Groups Projects
Commit e0c2d965 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2714585 by neclimdul: Avoid definition constants in SearchMatchTest

parent a1d3a681
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -5,12 +5,6 @@
use Drupal\Core\Language\LanguageInterface;
use Drupal\KernelTests\KernelTestBase;
// The search index can contain different types of content. Typically the type
// is 'node'. Here we test with _test_ and _test2_ as the type.
const SEARCH_TYPE = '_test_';
const SEARCH_TYPE_2 = '_test2_';
const SEARCH_TYPE_JPN = '_test3_';
/**
* Indexes content and queries it.
*
......@@ -18,6 +12,12 @@
*/
class SearchMatchTest extends KernelTestBase {
// The search index can contain different types of content. Typically the type
// is 'node'. Here we test with _test_ and _test2_ as the type.
const SEARCH_TYPE = '_test_';
const SEARCH_TYPE_2 = '_test2_';
const SEARCH_TYPE_JPN = '_test3_';
/**
* Modules to enable.
*
......@@ -49,10 +49,10 @@ function _setup() {
$this->config('search.settings')->set('index.minimum_word_size', 3)->save();
for ($i = 1; $i <= 7; ++$i) {
search_index(SEARCH_TYPE, $i, LanguageInterface::LANGCODE_NOT_SPECIFIED, $this->getText($i));
search_index(static::SEARCH_TYPE, $i, LanguageInterface::LANGCODE_NOT_SPECIFIED, $this->getText($i));
}
for ($i = 1; $i <= 5; ++$i) {
search_index(SEARCH_TYPE_2, $i + 7, LanguageInterface::LANGCODE_NOT_SPECIFIED, $this->getText2($i));
search_index(static::SEARCH_TYPE_2, $i + 7, LanguageInterface::LANGCODE_NOT_SPECIFIED, $this->getText2($i));
}
// No getText builder function for Japanese text; just a simple array.
foreach (array(
......@@ -60,7 +60,7 @@ function _setup() {
14 => 'ドルーパルが大好きよ!',
15 => 'コーヒーとケーキ',
) as $i => $jpn) {
search_index(SEARCH_TYPE_JPN, $i, LanguageInterface::LANGCODE_NOT_SPECIFIED, $jpn);
search_index(static::SEARCH_TYPE_JPN, $i, LanguageInterface::LANGCODE_NOT_SPECIFIED, $jpn);
}
search_update_totals();
}
......@@ -161,7 +161,7 @@ function _testQueries() {
foreach ($queries as $query => $results) {
$result = db_select('search_index', 'i')
->extend('Drupal\search\SearchQuery')
->searchExpression($query, SEARCH_TYPE)
->searchExpression($query, static::SEARCH_TYPE)
->execute();
$set = $result ? $result->fetchAll() : array();
......@@ -181,7 +181,7 @@ function _testQueries() {
foreach ($queries as $query => $results) {
$result = db_select('search_index', 'i')
->extend('Drupal\search\SearchQuery')
->searchExpression($query, SEARCH_TYPE_2)
->searchExpression($query, static::SEARCH_TYPE_2)
->execute();
$set = $result ? $result->fetchAll() : array();
......@@ -204,7 +204,7 @@ function _testQueries() {
foreach ($queries as $query => $results) {
$result = db_select('search_index', 'i')
->extend('Drupal\search\SearchQuery')
->searchExpression($query, SEARCH_TYPE_JPN)
->searchExpression($query, static::SEARCH_TYPE_JPN)
->execute();
$set = $result ? $result->fetchAll() : array();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment