public function SearchNumberMatchingTest::testNumberSearching in Drupal 8
Same name and namespace in other branches
- 9 core/modules/search/tests/src/Functional/SearchNumberMatchingTest.php \Drupal\Tests\search\Functional\SearchNumberMatchingTest::testNumberSearching()
- 10 core/modules/search/tests/src/Functional/SearchNumberMatchingTest.php \Drupal\Tests\search\Functional\SearchNumberMatchingTest::testNumberSearching()
Tests that all the numbers can be searched.
File
- core/
modules/ search/ tests/ src/ Functional/ SearchNumberMatchingTest.php, line 94
Class
- SearchNumberMatchingTest
- Tests that numbers can be searched with more complex matching.
Namespace
Drupal\Tests\search\FunctionalCode
public function testNumberSearching() {
for ($i = 0; $i < count($this->numbers); $i++) {
$node = $this->nodes[$i];
// Verify that the node title does not appear on the search page
// with a dummy search.
$this
->drupalPostForm('search/node', [
'keys' => 'foo',
], t('Search'));
$this
->assertNoText($node
->label(), new FormattableMarkup('%number: node title not shown in dummy search', [
'%number' => $i,
]));
// Now verify that we can find node i by searching for any of the
// numbers.
for ($j = 0; $j < count($this->numbers); $j++) {
$number = $this->numbers[$j];
// If the number is negative, remove the - sign, because - indicates
// "not keyword" when searching.
$number = ltrim($number, '-');
$this
->drupalPostForm('search/node', [
'keys' => $number,
], t('Search'));
$this
->assertText($node
->label(), new FormattableMarkup('%i: node title shown (search found the node) in search for number %number', [
'%i' => $i,
'%number' => $number,
]));
}
}
}