You are here

public function AbstractAutocompleteSynonymsWebTestCase::testWidgetSettingsSuggestionSize in Synonyms 7

Test 'Suggestions Size' setting of synonyms-friendly autocomplete widget.

File

./synonyms.test, line 557
Tests for the Synonyms module.

Class

AbstractAutocompleteSynonymsWebTestCase
Test "Synonyms friendly autocomplete" widget of Synonyms module.

Code

public function testWidgetSettingsSuggestionSize() {
  $suggestion_size = 1;
  $this->reference_instance['widget']['settings']['suggestion_size'] = $suggestion_size;
  field_update_instance($this->reference_instance);

  // If size was bigger than 1, we'd get suggested 2 terms: 'term1' and
  // 'term1_longer_name'.
  $this
    ->assertAutocompleteMenuPath($this
    ->entityLabel($this->terms['term1']), array(
    $this
      ->entityLabel($this->terms['term1']) => $this
      ->entityLabel($this->terms['term1']),
  ), 'Suggestions Size option is respected in autocomplete widget for entity suggestion entries.');
  $this
    ->assertAutocompleteMenuPath($this
    ->entityLabel($this->terms['name_similar_synonym']), array(
    $this
      ->entityLabel($this->terms['name_similar_synonym']) => $this
      ->entityLabel($this->terms['name_similar_synonym']),
  ), 'Suggestions Size option is respected in autocomplete widget for entity and synonym suggestion entries.');
  $this
    ->assertAutocompleteMenuPath(drupal_substr($this->terms['similar_synonyms']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][0]['value'], 0, 8), array(
    $this
      ->entityLabel($this->terms['similar_synonyms']) => $this
      ->synonymAutocompleteResult($this->terms['similar_synonyms'], $this->terms['similar_synonyms']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][0]['value']),
  ), 'Suggestions Size option is respected in autocomplete widget for synonyms suggestion entries.');
  $this
    ->assertAutocompleteMenuPath('one_term_name_another_synonym_', array(
    $this
      ->entityLabel($this->terms['name_another_synonym']) => $this
      ->entityLabel($this->terms['name_another_synonym']),
  ), 'Suggestions Size option is respected in autocomplete widget for the case when there is match by entity name and by synonyms; and preference is given to the match by entity name.');
}