Issue #2254777 by m1r1k: Block category autocomplete does not work.

8.0.x
Nathaniel Catchpole 2014-05-09 11:23:10 +01:00
parent 938ac1f5b7
commit 6c8d082611
2 changed files with 3 additions and 3 deletions

View File

@ -59,7 +59,7 @@ class CategoryAutocompleteController implements ContainerInjectionInterface {
$matches = array();
foreach ($this->blockManager->getCategories() as $category) {
if (stripos($category, $typed_category) === 0) {
$matches[$category] = String::checkPlain($category);
$matches[] = array('value' => $category, 'label' => String::checkPlain($category));
}
}
return new JsonResponse($matches);

View File

@ -59,8 +59,8 @@ class CategoryAutocompleteTest extends UnitTestCase {
*/
public function testAutocompleteSuggestions($string, $suggestions) {
$suggestions = array_map(function ($suggestion) {
return String::checkPlain($suggestion);
}, array_combine($suggestions, $suggestions));
return array('value' => $suggestion, 'label' => String::checkPlain($suggestion));
}, $suggestions);
$result = $this->autocompleteController->autocomplete(new Request(array('q' => $string)));
$this->assertSame($suggestions, json_decode($result->getContent(), TRUE));
}