Tests the cardinality settings of a field.
We do not test if the number can be submitted with anything else than a numeric value. That is tested already in FormTest::testNumber().
function cardinalitySettings() {
$field_edit_path = 'admin/structure/types/manage/article/fields/node.article.body/field';
// Assert the cardinality other field cannot be empty when cardinality is
// set to 'number'.
$edit = array(
'field[cardinality]' => 'number',
'field[cardinality_number]' => '',
);
$this
->drupalPost($field_edit_path, $edit, t('Save field settings'));
$this
->assertText('Number of values is required.');
// Submit a custom number.
$edit = array(
'field[cardinality]' => 'number',
'field[cardinality_number]' => 6,
);
$this
->drupalPost($field_edit_path, $edit, t('Save field settings'));
$this
->assertText('Updated field Body field settings.');
$this
->drupalGet($field_edit_path);
$this
->assertFieldByXPath("//select[@name='field[cardinality]']", 'number');
$this
->assertFieldByXPath("//input[@name='field[cardinality_number]']", 6);
// Set to unlimited.
$edit = array(
'field[cardinality]' => FIELD_CARDINALITY_UNLIMITED,
);
$this
->drupalPost($field_edit_path, $edit, t('Save field settings'));
$this
->assertText('Updated field Body field settings.');
$this
->drupalGet($field_edit_path);
$this
->assertFieldByXPath("//select[@name='field[cardinality]']", FIELD_CARDINALITY_UNLIMITED);
$this
->assertFieldByXPath("//input[@name='field[cardinality_number]']", 1);
}