function CCKSelectOtherPHPOptionsTest::testPHPOptions in CCK Select Other 7.2
Same name and namespace in other branches
- 7 tests/cck_select_other.test \CCKSelectOtherPHPOptionsTest::testPHPOptions()
File
- tests/
cck_select_other.test, line 333 - CCK Select Other Functional Tests
Class
- CCKSelectOtherPHPOptionsTest
- Assert that PHP options work correctly in select other list.
Code
function testPHPOptions() {
// Login as admin user and change options to use php
$this
->drupalLogin($this->admin_user);
$php_options = '$arr = array();
$blah = \'\';
for ($i = 0; $i < 3; $i++) {
$blah .= \'blah_\';
$arr[$blah] = $blah;
}
return $arr;';
$edit = array(
'instance[widget][settings][select_list_options]' => '',
'instance[widget][settings][select_list_options_fieldset][advanced_options][select_list_options_php]' => $php_options,
);
$bundle_path = 'admin/structure/types/manage/' . $this->contentType->type;
$this
->drupalPost($bundle_path . '/fields/' . $this->test_field['field_name'], $edit, t('Save settings'));
$this->test_field = field_info_field($this->test_field['field_name']);
$this
->drupalLogout();
// Login as web user and make sure that we are selecting a value from
// the php generated list.
$this
->drupalLogin($this->web_user);
$select_field = $this->test_field['field_name'] . '[und][0][select_other_list]';
$edit = array(
$select_field => 'blah_blah_',
);
$this
->drupalPost('node/' . $this->test_node->nid . '/edit', $edit, t('Save'));
$this
->assertText('blah_blah_', t('Select value %value found on node.', array(
'%value' => 'blah_blah_',
)));
$this
->drupalLogout();
}