1. 8.2.x core/modules/search/tests/modules/search_langcode_test/search_langcode_test.module
  2. 8.0.x core/modules/search/tests/modules/search_langcode_test/search_langcode_test.module
  3. 8.1.x core/modules/search/tests/modules/search_langcode_test/search_langcode_test.module
  4. 8.3.x core/modules/search/tests/modules/search_langcode_test/search_langcode_test.module

Test module setting up two tests, one for checking if the entity $langcode is being passed on and another one sets up the alternate verb forms for the stemming test.

File

core/modules/search/tests/modules/search_langcode_test/search_langcode_test.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * Test module setting up two tests, one for checking if the entity $langcode is
  5. * being passed on and another one sets up the alternate verb forms for the
  6. * stemming test.
  7. */
  8. /**
  9. * Implements hook_search_preprocess().
  10. */
  11. function search_langcode_test_search_preprocess($text, $langcode = NULL) {
  12. if (isset($langcode) && $langcode == 'en') {
  13. // Add the alternate verb forms for the word "testing".
  14. if ($text == 'we are testing') {
  15. $text .= ' test tested';
  16. }
  17. // Prints the langcode for testPreprocessLangcode() and adds some
  18. // extra text.
  19. else {
  20. drupal_set_message('Langcode Preprocess Test: ' . $langcode);
  21. $text .= 'Additional text';
  22. }
  23. }
  24. // Prints the langcode for testPreprocessLangcode().
  25. elseif (isset($langcode)) {
  26. drupal_set_message('Langcode Preprocess Test: ' . $langcode);
  27. // Preprocessing for the excerpt test.
  28. if ($langcode == 'ex') {
  29. $text = str_replace('finding', 'find', $text);
  30. $text = str_replace('finds', 'find', $text);
  31. $text = str_replace('dic', ' dependency injection container', $text);
  32. $text = str_replace('hypertext markup language', 'html', $text);
  33. }
  34. }
  35. return $text;
  36. }

Functions