function SearchNumbersTest::testNumberSearching
Tests that all the numbers can be searched.
File
- 
              core/
modules/ search/ tests/ src/ Functional/ SearchNumbersTest.php, line 105  
Class
- SearchNumbersTest
 - Tests that numbers can be searched.
 
Namespace
Drupal\Tests\search\FunctionalCode
public function testNumberSearching() : void {
  $types = array_keys($this->numbers);
  foreach ($types as $type) {
    $number = $this->numbers[$type];
    // If the number is negative, remove the - sign, because - indicates
    // "not keyword" when searching.
    $number = ltrim($number, '-');
    $node = $this->nodes[$type];
    // Verify that the node title does not appear on the search page
    // with a dummy search.
    $this->drupalGet('search/node');
    $this->submitForm([
      'keys' => 'foo',
    ], 'Search');
    $this->assertSession()
      ->pageTextNotContains($node->label());
    // Verify that the node title does appear as a link on the search page
    // when searching for the number.
    $this->drupalGet('search/node');
    $this->submitForm([
      'keys' => $number,
    ], 'Search');
    $this->assertSession()
      ->pageTextContains($node->label());
  }
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.