function TermAutocompleteTest::testAutocompleteOrderedResults
Same name in other branches
- 9 core/modules/taxonomy/tests/src/Functional/TermAutocompleteTest.php \Drupal\Tests\taxonomy\Functional\TermAutocompleteTest::testAutocompleteOrderedResults()
- 8.9.x core/modules/taxonomy/tests/src/Functional/TermAutocompleteTest.php \Drupal\Tests\taxonomy\Functional\TermAutocompleteTest::testAutocompleteOrderedResults()
- 10 core/modules/taxonomy/tests/src/Functional/TermAutocompleteTest.php \Drupal\Tests\taxonomy\Functional\TermAutocompleteTest::testAutocompleteOrderedResults()
Tests that the autocomplete method returns properly ordered results.
See also
\Drupal\taxonomy\Controller\TermAutocompleteController::autocomplete()
File
-
core/
modules/ taxonomy/ tests/ src/ Functional/ TermAutocompleteTest.php, line 205
Class
- TermAutocompleteTest
- Tests the autocomplete implementation of the taxonomy class.
Namespace
Drupal\Tests\taxonomy\FunctionalCode
public function testAutocompleteOrderedResults() : void {
$expectedResults = [
'aaa 10 bbb',
'aaa 11 bbb',
'aaa 12 bbb',
'aaa 20 bbb',
'aaa 30 bbb',
'aaa 40 bbb',
'aaa 50 bbb',
'aaa 70 bbb',
'bbb 60 aaa',
];
// Build $expected to match the autocomplete results.
$expected = [];
foreach ($expectedResults as $termName) {
$expected[] = [
'value' => $termName . ' (' . $this->termIds[$termName] . ')',
'label' => $termName,
];
}
$data = $this->drupalGetJson($this->autocompleteUrl, [
'query' => [
'q' => 'bbb',
],
]);
$this->assertSame($expected, $data);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.