public function CommerceProductReferenceSelectSynonymsWebTestCase::testWidgetSorting in Synonyms 7
Test sorting options of the widget.
Overrides AbstractSelectSynonymsWebTestCase::testWidgetSorting
File
- synonyms_commerce/
synonyms_commerce.test, line 310 - Tests for the Synonyms Commerce module.
Class
- CommerceProductReferenceSelectSynonymsWebTestCase
- Test synonyms-friendly select widget for commerce product reference field.
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['product3'],
'synonym' => $this->terms['product3']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][0]['value'],
);
$options[] = array(
'entity' => $this->terms['product3'],
'synonym' => $this->terms['product3']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][1]['value'],
);
$options[] = array(
'entity' => $this->terms['product1'],
);
$options[] = array(
'entity' => $this->terms['product1'],
'synonym' => $this->terms['product1']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][0]['value'],
);
$options[] = array(
'entity' => $this->terms['product1'],
'synonym' => $this->terms['product1']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][1]['value'],
);
$options[] = array(
'entity' => $this->terms['product2'],
);
$options[] = array(
'entity' => $this->terms['product2'],
'synonym' => $this->terms['product2']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][1]['value'],
);
$options[] = array(
'entity' => $this->terms['product2'],
'synonym' => $this->terms['product2']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][0]['value'],
);
$options[] = array(
'entity' => $this->terms['product3'],
);
$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);
}
}
}