function SearchSetLocaleTest::setUp

Same name in other branches
  1. 7.x modules/search/search.test \SearchSetLocaleTest::setUp()
  2. 9 core/modules/search/tests/src/Functional/SearchSetLocaleTest.php \Drupal\Tests\search\Functional\SearchSetLocaleTest::setUp()
  3. 8.9.x core/modules/search/tests/src/Functional/SearchSetLocaleTest.php \Drupal\Tests\search\Functional\SearchSetLocaleTest::setUp()
  4. 11.x core/modules/search/tests/src/Kernel/SearchSetLocaleTest.php \Drupal\Tests\search\Kernel\SearchSetLocaleTest::setUp()

Overrides KernelTestBase::setUp

File

core/modules/search/tests/src/Kernel/SearchSetLocaleTest.php, line 46

Class

SearchSetLocaleTest
Tests that search works with numeric locale settings.

Namespace

Drupal\Tests\search\Kernel

Code

protected function setUp() : void {
    parent::setUp();
    $this->installSchema('node', [
        'node_access',
    ]);
    $this->installSchema('search', [
        'search_index',
        'search_dataset',
        'search_total',
    ]);
    $this->installEntitySchema('node');
    $this->installEntitySchema('user');
    $this->installConfig([
        'filter',
        'node',
        'search',
    ]);
    // Create the anonymous user account and set it as current user.
    $this->setUpCurrentUser([
        'uid' => 0,
    ]);
    // Create a node type.
    $this->createContentType([
        '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->createNode([
        'body' => [
            [
                'value' => 'tapir',
            ],
        ],
        'uid' => 0,
    ]);
    // Create the fallback date format.
    DateFormat::create([
        'id' => 'fallback',
        'label' => 'Fallback date format',
        'pattern' => 'D, m/d/Y - H:i',
        'locked' => TRUE,
    ])->save();
    // Update the search index.
    $this->nodeSearchPlugin
        ->updateIndex();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.