public function EntityReferenceSelectSynonymsWebTestCase::testWidgetSorting in Synonyms 7
Test sorting options of the widget.
Overrides AbstractSelectSynonymsWebTestCase::testWidgetSorting
File
- ./
synonyms.test, line 1615 - Tests for the Synonyms module.
Class
- EntityReferenceSelectSynonymsWebTestCase
- Test synonyms friendly select widget for entity reference field type.
Code
public function testWidgetSorting() {
$cardinality = array(
1 => 1,
FIELD_CARDINALITY_UNLIMITED => 'unlimited',
);
$required = array(
TRUE => 'required',
FALSE => 'not required',
);
foreach ($cardinality as $cardinality_k => $cardinality_v) {
foreach ($required as $required_k => $required_v) {
$this->reference_field['cardinality'] = $cardinality_k;
field_update_field($this->reference_field);
$this->reference_instance['required'] = $required_k;
field_update_instance($this->reference_instance);
$options = array();
$options[] = array(
'entity' => $this->terms['child_term'],
);
$options[] = array(
'entity' => $this->terms['child_term'],
'synonym' => $this->terms['child_term']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][1]['value'],
);
$options[] = array(
'entity' => $this->terms['child_term'],
'synonym' => $this->terms['child_term']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][0]['value'],
);
$options[] = array(
'entity' => $this->terms['normal_term'],
);
$options[] = array(
'entity' => $this->terms['normal_term'],
'synonym' => $this->terms['normal_term']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][0]['value'],
);
$options[] = array(
'entity' => $this->terms['normal_term'],
'synonym' => $this->terms['normal_term']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][1]['value'],
);
$options[] = array(
'entity' => $this->terms['parent_term'],
);
$options[] = array(
'entity' => $this->terms['parent_term'],
'synonym' => $this->terms['parent_term']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][0]['value'],
);
$options[] = array(
'entity' => $this->terms['parent_term'],
'synonym' => $this->terms['parent_term']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][1]['value'],
);
$this
->drupalGet('node/add/synonyms-test-content');
$this
->assertSynonymsSelect($options, 'Synonyms select sorting by name works for the cardinality of ' . $cardinality_v . ' and ' . $required_v);
}
}
}