function CategoryAutocompleteTest::testAutocompleteSuggestions
Same name in other branches
- 9 core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php \Drupal\Tests\block\Unit\CategoryAutocompleteTest::testAutocompleteSuggestions()
- 8.9.x core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php \Drupal\Tests\block\Unit\CategoryAutocompleteTest::testAutocompleteSuggestions()
- 11.x core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php \Drupal\Tests\block\Unit\CategoryAutocompleteTest::testAutocompleteSuggestions()
Tests the autocomplete method.
@dataProvider providerTestAutocompleteSuggestions
Parameters
string $string: The string entered into the autocomplete.
array $suggestions: The array of expected suggestions.
See also
\Drupal\block\Controller\CategoryAutocompleteController::autocomplete()
File
-
core/
modules/ block/ tests/ src/ Unit/ CategoryAutocompleteTest.php, line 51
Class
- CategoryAutocompleteTest
- @coversDefaultClass \Drupal\block\Controller\CategoryAutocompleteController @group block
Namespace
Drupal\Tests\block\UnitCode
public function testAutocompleteSuggestions($string, $suggestions) : void {
$suggestions = array_map(function ($suggestion) {
return [
'value' => $suggestion,
'label' => Html::escape($suggestion),
];
}, $suggestions);
$result = $this->autocompleteController
->autocomplete(new Request([
'q' => $string,
]));
$this->assertSame($suggestions, json_decode($result->getContent(), TRUE));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.