You are here

public function SearchSimplifyTest::testSearchSimplifyPunctuation in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/search/tests/src/Kernel/SearchSimplifyTest.php \Drupal\Tests\search\Kernel\SearchSimplifyTest::testSearchSimplifyPunctuation()

Tests that search_simplify() does the right thing with punctuation.

File

core/modules/search/tests/src/Kernel/SearchSimplifyTest.php, line 74

Class

SearchSimplifyTest
Tests that the search_simply() function works as intended.

Namespace

Drupal\Tests\search\Kernel

Code

public function testSearchSimplifyPunctuation() {
  $cases = [
    [
      '20.03/94-28,876',
      '20039428876',
      'Punctuation removed from numbers',
    ],
    [
      'great...drupal--module',
      'great drupal module',
      'Multiple dot and dashes are word boundaries',
    ],
    [
      'very_great-drupal.module',
      'verygreatdrupalmodule',
      'Single dot, dash, underscore are removed',
    ],
    [
      'regular,punctuation;word',
      'regular punctuation word',
      'Punctuation is a word boundary',
    ],
  ];
  foreach ($cases as $case) {
    $out = trim(search_simplify($case[0]));
    $this
      ->assertEqual($out, $case[1], $case[2]);
  }
}