You are here

public function TagTest::testViewsUiAutocompleteIndividualTags in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views_ui/tests/src/Kernel/TagTest.php \Drupal\Tests\views_ui\Kernel\TagTest::testViewsUiAutocompleteIndividualTags()

Tests that comma delimited tags are treated as individual tags.

@dataProvider providerViewsUiAutocompleteIndividualTags

File

core/modules/views_ui/tests/src/Kernel/TagTest.php, line 76

Class

TagTest
Tests the views ui tagging functionality.

Namespace

Drupal\Tests\views_ui\Kernel

Code

public function testViewsUiAutocompleteIndividualTags($expected_tag, $search_string) {
  $controller = ViewsUIController::create($this->container);
  $request = $this->container
    ->get('request_stack')
    ->getCurrentRequest();
  $tag = 'comma, 你好, Foo bar';
  View::create([
    'tag' => $tag,
    'id' => $this
      ->randomMachineName(),
  ])
    ->save();
  $request->query
    ->set('q', $search_string);
  $result = $controller
    ->autocompleteTag($request);
  $matches = (array) json_decode($result
    ->getContent());
  $this
    ->assertCount(1, $matches);
  $this
    ->assertSame($expected_tag, $matches[0]->value);
}