You are here

protected function AbstractSynonymsProviderFieldWebTestCase::assertMergeEntityAsSynonym in Synonyms 7

Test mergeEntityAsSynonym method.

Parameters

array $items: Items array to place into the field on which synonyms provider is based

object $synonym_entity: Parameter will be passed directly to the behavior implementation object

string $synonym_entity_type: Parameter will be passed directly to the behavior implementation object

array $standard: Array that is expected to be returned by the tested method

string $message: Any custom message to be added to the standard one and passed to SimpleTest assertion method

4 calls to AbstractSynonymsProviderFieldWebTestCase::assertMergeEntityAsSynonym()
CommerceProductReferenceSynonymsBehaviorWebTestCase::testCommerceProductReference in synonyms_commerce/synonyms_commerce.test
Test synonyms extraction for 'commerce_product_reference' field type.
EntityReferenceSynonymsBehaviorWebTestCase::testEntityReference in synonyms_provider_field/synonyms_provider_field.test
Test synonyms extraction for 'entityreference' field type.
TaxonomySynonymsBehaviorWebTestCase::testTaxonomyTermReference in synonyms_provider_field/synonyms_provider_field.test
Test synonyms extraction for 'taxonomy_term_reference' field type.
TextSynonymsBehaviorWebTestCase::testText in synonyms_provider_field/synonyms_provider_field.test
Test synonyms extraction for 'text' field type.

File

synonyms_provider_field/synonyms_provider_field.test, line 62
Tests for the Synonyms field provider module.

Class

AbstractSynonymsProviderFieldWebTestCase
Base class for all tests that test field-based Synonyms providers.

Code

protected function assertMergeEntityAsSynonym($items, $synonym_entity, $synonym_entity_type, $standard, $message = '') {
  $message = $this->behavior_implementation['class'] . '::mergeEntityAsSynonym() passed: ' . $message;
  $term = (object) array(
    'name' => $this
      ->randomName(),
    'vid' => $this->vocabulary->vid,
  );
  $term->{$this->fields['enabled']['field']['field_name']} = $items;
  taxonomy_term_save($term);
  $this->behavior_implementation['object']
    ->mergeEntityAsSynonym($term, $synonym_entity, $synonym_entity_type);
  $merged_items = $term->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE];
  foreach ($standard as $k => $v) {
    if (count(array_intersect($standard[$k], $merged_items[$k])) != count($standard[$k])) {
      $this
        ->fail($message);
      return;
    }
  }
  $this
    ->pass($message);
  taxonomy_term_delete($term->tid);
}