function SearchNumberMatchingTest::setUp

Same name in other branches
  1. 8.9.x core/modules/search/tests/src/Functional/SearchNumberMatchingTest.php \Drupal\Tests\search\Functional\SearchNumberMatchingTest::setUp()
  2. 10 core/modules/search/tests/src/Functional/SearchNumberMatchingTest.php \Drupal\Tests\search\Functional\SearchNumberMatchingTest::setUp()
  3. 11.x core/modules/search/tests/src/Functional/SearchNumberMatchingTest.php \Drupal\Tests\search\Functional\SearchNumberMatchingTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/search/tests/src/Functional/SearchNumberMatchingTest.php, line 65

Class

SearchNumberMatchingTest
Tests that numbers can be searched with more complex matching.

Namespace

Drupal\Tests\search\Functional

Code

protected function setUp() : void {
    parent::setUp();
    $this->drupalCreateContentType([
        'type' => 'page',
        'name' => 'Basic page',
    ]);
    $this->testUser = $this->drupalCreateUser([
        'search content',
        'access content',
        'administer nodes',
        'access site reports',
    ]);
    $this->drupalLogin($this->testUser);
    foreach ($this->numbers as $num) {
        $info = [
            'body' => [
                [
                    'value' => $num,
                ],
            ],
            'type' => 'page',
            'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
        ];
        $this->nodes[] = $this->drupalCreateNode($info);
    }
    // Run cron to ensure the content is indexed.
    $this->cronRun();
    $this->drupalGet('admin/reports/dblog');
    $this->assertSession()
        ->pageTextContains('Cron run completed');
}

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