Mercurial > hg > cmmr2012-drupal-site
diff core/modules/search/tests/src/Functional/SearchSetLocaleTest.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | a9cd425dd02b |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/search/tests/src/Functional/SearchSetLocaleTest.php Thu Jul 05 14:24:15 2018 +0000 @@ -0,0 +1,51 @@ +<?php + +namespace Drupal\Tests\search\Functional; + +/** + * Tests that search works with numeric locale settings. + * + * @group search + */ +class SearchSetLocaleTest extends SearchTestBase { + + /** + * Modules to enable. + * + * @var array + */ + public static $modules = ['comment']; + + /** + * A node search plugin instance. + * + * @var \Drupal\search\Plugin\SearchInterface + */ + protected $nodeSearchPlugin; + + protected function setUp() { + parent::setUp(); + + // 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(); + search_update_totals(); + } + + /** + * 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(); + } + +}