class SearchSetLocaleTest
Same name and namespace in other branches
- 11.x core/modules/search/tests/src/Kernel/SearchSetLocaleTest.php \Drupal\Tests\search\Kernel\SearchSetLocaleTest
- 7.x modules/search/search.test \SearchSetLocaleTest
- 10 core/modules/search/tests/src/Kernel/SearchSetLocaleTest.php \Drupal\Tests\search\Kernel\SearchSetLocaleTest
- 8.9.x core/modules/search/tests/src/Functional/SearchSetLocaleTest.php \Drupal\Tests\search\Functional\SearchSetLocaleTest
Tests that search works with numeric locale settings.
@group search
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\search\Functional\SearchSetLocaleTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of SearchSetLocaleTest
File
-
core/
modules/ search/ tests/ src/ Functional/ SearchSetLocaleTest.php, line 12
Namespace
Drupal\Tests\search\FunctionalView source
class SearchSetLocaleTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'comment',
'node',
'search',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* A node search plugin instance.
*
* @var \Drupal\search\Plugin\SearchInterface
*/
protected $nodeSearchPlugin;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
]);
// Create a plugin instance.
$this->nodeSearchPlugin = $this->container
->get('plugin.manager.search')
->createInstance('node_search');
// Create a node with a very simple body.
$this->drupalCreateNode([
'body' => [
[
'value' => 'tapir',
],
],
]);
// Update the search index.
$this->nodeSearchPlugin
->updateIndex();
}
/**
* Verify that search works with a numeric locale set.
*/
public function testSearchWithNumericLocale() {
// French decimal point is comma.
setlocale(LC_NUMERIC, 'fr_FR');
$this->nodeSearchPlugin
->setSearch('tapir', [], []);
// The call to execute will throw an exception if a float in the wrong
// format is passed in the query to the database, so an assertion is not
// necessary here.
$this->nodeSearchPlugin
->execute();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.