protected function AbstractAutocompleteSynonymsWebTestCase::createTerms in Synonyms 7
Method to initiate all necessary terms for testing.
1 call to AbstractAutocompleteSynonymsWebTestCase::createTerms()
- AbstractAutocompleteSynonymsWebTestCase::setUp in ./
synonyms.test - SetUp method.
1 method overrides AbstractAutocompleteSynonymsWebTestCase::createTerms()
- CommerceProductReferenceAutocompleteSynonymsWebTestCase::createTerms in synonyms_commerce/
synonyms_commerce.test - Method to initiate all necessary terms for testing.
File
- ./
synonyms.test, line 682 - Tests for the Synonyms module.
Class
- AbstractAutocompleteSynonymsWebTestCase
- Test "Synonyms friendly autocomplete" widget of Synonyms module.
Code
protected function createTerms() {
$name = $this
->randomName();
$term = (object) array(
'vid' => $this->vocabulary->vid,
'name' => $name,
$this->fields['disabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
array(
'value' => $this
->randomName(),
),
),
),
);
taxonomy_term_save($term);
$this->terms['term1'] = $term;
$name .= $this
->randomName();
$term = (object) array(
'vid' => $this->vocabulary->vid,
'name' => $name,
$this->fields['disabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
array(
'value' => $this
->randomName(),
),
),
),
);
taxonomy_term_save($term);
$this->terms['term1_longer_name'] = $term;
$term = (object) array(
'vid' => $this->vocabulary->vid,
'name' => $this
->randomName(),
$this->fields['disabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
array(
'value' => $this
->randomName(),
),
),
),
);
taxonomy_term_save($term);
$this->terms['no_synonyms'] = $term;
$term = (object) array(
'vid' => $this->vocabulary->vid,
'name' => $this
->randomName(),
$this->fields['enabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
array(
'value' => $this
->randomName(),
),
),
),
$this->fields['disabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
array(
'value' => $this
->randomName(),
),
),
),
);
taxonomy_term_save($term);
$this->terms['one_synonym'] = $term;
$term = (object) array(
'vid' => $this->vocabulary->vid,
'name' => $this
->randomName(),
$this->fields['enabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
array(
'value' => $this
->randomName(),
),
array(
'value' => $this
->randomName(),
),
),
),
$this->fields['disabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
array(
'value' => $this
->randomName(),
),
),
),
);
taxonomy_term_save($term);
$this->terms['two_synonyms'] = $term;
$name = $this
->randomName();
$term = (object) array(
'vid' => $this->vocabulary->vid,
'name' => $name,
$this->fields['enabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
array(
'value' => $name . $this
->randomName(),
),
),
),
$this->fields['disabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
array(
'value' => $this
->randomName(),
),
),
),
);
taxonomy_term_save($term);
$this->terms['name_similar_synonym'] = $term;
$name = 'similar_synonyms_';
$term = (object) array(
'vid' => $this->vocabulary->vid,
'name' => $this
->randomName(),
$this->fields['enabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
array(
'value' => $name . $this
->randomName(),
),
array(
'value' => $name . $this
->randomName(),
),
),
),
$this->fields['disabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
array(
'value' => $this
->randomName(),
),
),
),
);
taxonomy_term_save($term);
$this->terms['similar_synonyms'] = $term;
$name = 'one_term_name_another_synonym_';
$term = (object) array(
'vid' => $this->vocabulary->vid,
'name' => $name . $this
->randomName(),
$this->fields['disabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
array(
'value' => $this
->randomName(),
),
),
),
);
taxonomy_term_save($term);
$this->terms['name_another_synonym'] = $term;
$term = (object) array(
'vid' => $this->vocabulary->vid,
'name' => $this
->randomName(),
$this->fields['enabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
array(
'value' => $name . $this
->randomName(),
),
),
),
$this->fields['disabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
array(
'value' => $this
->randomName(),
),
),
),
);
taxonomy_term_save($term);
$this->terms['synonym_another_name'] = $term;
$another_vocabulary = (object) array(
'name' => $this
->randomName(),
'machine_name' => 'another_vocabulary',
);
taxonomy_vocabulary_save($another_vocabulary);
$term_similar_term = (object) array(
'name' => $this->terms['no_synonyms']->name,
'vid' => $another_vocabulary->vid,
);
taxonomy_term_save($term_similar_term);
$term_similar_synonym = (object) array(
'name' => $this->terms['one_synonym']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][0]['value'],
'vid' => $another_vocabulary->vid,
);
taxonomy_term_save($term_similar_synonym);
$synonym_similar_term = (object) array(
'name' => $this
->randomName(),
'vid' => $another_vocabulary->vid,
$this->fields['enabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
$this->terms['no_synonyms']->name,
),
),
);
taxonomy_term_save($synonym_similar_term);
$synonym_similar_synonym = (object) array(
'name' => $this
->randomName(),
'vid' => $another_vocabulary->vid,
$this->fields['enabled']['field']['field_name'] => array(
LANGUAGE_NONE => array(
$this->terms['one_synonym']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][0]['value'],
),
),
);
taxonomy_term_save($synonym_similar_synonym);
}