You are here

protected function AbstractAutocompleteSynonymsWebTestCase::synonymAutocompleteResult in Synonyms 7

Return expected autocomplete menu path result.

The result is prepared as if the entity was found by the supplied synonym.

Parameters

object $entity: Fully loaded entity for which the result is generated.

string $synonym: Synonym by which the entity was hit in the search

array $behavior_implementation: Behavior implementation array which the $synonym originates from. If omitted, standard $this->behavior_implementation is considered

Return value

string Formatted autocomplete result

3 calls to AbstractAutocompleteSynonymsWebTestCase::synonymAutocompleteResult()
AbstractAutocompleteSynonymsWebTestCase::testAutocompleteMenuPath in ./synonyms.test
Test autocomplete menu path.
AbstractAutocompleteSynonymsWebTestCase::testWidgetSettingsSuggestionSize in ./synonyms.test
Test 'Suggestions Size' setting of synonyms-friendly autocomplete widget.
AbstractAutocompleteSynonymsWebTestCase::testWidgetSettingsSuggestOnlyUnique in ./synonyms.test
Test 'Suggest only one entry per term' setting of autocomplete widget.

File

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

Class

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

Code

protected function synonymAutocompleteResult($entity, $synonym, $behavior_implementation = NULL) {
  if (!$behavior_implementation) {
    $behavior_implementation = $this->behavior_implementation;
  }
  $provider = synonyms_behavior_implementation_info($behavior_implementation['entity_type'], $behavior_implementation['bundle'], $behavior_implementation['behavior']);
  $provider = $provider[$behavior_implementation['provider']];
  $entity_ids = entity_extract_ids($behavior_implementation['entity_type'], $entity);
  $entity_info = entity_get_info($behavior_implementation['entity_type']);
  return format_string($behavior_implementation['settings']['wording'], array(
    '@synonym' => $synonym,
    '@entity' => entity_label($behavior_implementation['entity_type'], $entity),
    '@field_name' => drupal_strtolower($provider['label']),
    '@bundle' => $entity_info['bundles'][$entity_ids[2]]['label'],
  ));
}