public function CategoryAutocompleteTest::testAutocompleteSuggestions in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 49 - Contains \Drupal\Tests\block\Unit\CategoryAutocompleteTest.
Class
- CategoryAutocompleteTest
- @coversDefaultClass \Drupal\block\Controller\CategoryAutocompleteController @group block
Namespace
Drupal\Tests\block\UnitCode
public function testAutocompleteSuggestions($string, $suggestions) {
$suggestions = array_map(function ($suggestion) {
return array(
'value' => $suggestion,
'label' => Html::escape($suggestion),
);
}, $suggestions);
$result = $this->autocompleteController
->autocomplete(new Request(array(
'q' => $string,
)));
$this
->assertSame($suggestions, json_decode($result
->getContent(), TRUE));
}