comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
1 <?php
2
3 namespace Drupal\Tests\search\Functional;
4
5 /**
6 * Tests that search works with numeric locale settings.
7 *
8 * @group search
9 */
10 class SearchSetLocaleTest extends SearchTestBase {
11
12 /**
13 * Modules to enable.
14 *
15 * @var array
16 */
17 public static $modules = ['comment'];
18
19 /**
20 * A node search plugin instance.
21 *
22 * @var \Drupal\search\Plugin\SearchInterface
23 */
24 protected $nodeSearchPlugin;
25
26 protected function setUp() {
27 parent::setUp();
28
29 // Create a plugin instance.
30 $this->nodeSearchPlugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
31 // Create a node with a very simple body.
32 $this->drupalCreateNode(['body' => [['value' => 'tapir']]]);
33 // Update the search index.
34 $this->nodeSearchPlugin->updateIndex();
35 search_update_totals();
36 }
37
38 /**
39 * Verify that search works with a numeric locale set.
40 */
41 public function testSearchWithNumericLocale() {
42 // French decimal point is comma.
43 setlocale(LC_NUMERIC, 'fr_FR');
44 $this->nodeSearchPlugin->setSearch('tapir', [], []);
45 // The call to execute will throw an exception if a float in the wrong
46 // format is passed in the query to the database, so an assertion is not
47 // necessary here.
48 $this->nodeSearchPlugin->execute();
49 }
50
51 }