public function SearchNumbersTest::testNumberSearching in Drupal 8
Same name and namespace in other branches
- 9 core/modules/search/tests/src/Functional/SearchNumbersTest.php \Drupal\Tests\search\Functional\SearchNumbersTest::testNumberSearching()
- 10 core/modules/search/tests/src/Functional/SearchNumbersTest.php \Drupal\Tests\search\Functional\SearchNumbersTest::testNumberSearching()
Tests that all the numbers can be searched.
File
- core/
modules/ search/ tests/ src/ Functional/ SearchNumbersTest.php, line 101
Class
- SearchNumbersTest
- Tests that numbers can be searched.
Namespace
Drupal\Tests\search\FunctionalCode
public function testNumberSearching() {
$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
->drupalPostForm('search/node', [
'keys' => 'foo',
], t('Search'));
$this
->assertNoText($node
->label(), $type . ': node title not shown in dummy search');
// Verify that the node title does appear as a link on the search page
// when searching for the number.
$this
->drupalPostForm('search/node', [
'keys' => $number,
], t('Search'));
$this
->assertText($node
->label(), new FormattableMarkup('%type: node title shown (search found the node) in search for number %number.', [
'%type' => $type,
'%number' => $number,
]));
}
}