public function CCKSelectOtherTest::setUp in CCK Select Other 7.2
Same name and namespace in other branches
- 6 tests/cck_select_other.test \CCKSelectOtherTest::setUp()
- 7 tests/cck_select_other.test \CCKSelectOtherTest::setUp()
Implementation of setUp() method
Overrides DrupalWebTestCase::setUp
2 calls to CCKSelectOtherTest::setUp()
- CCKSelectOtherMultipleValueListTest::setUp in tests/
cck_select_other.test - Implementation of setUp() method
- CCKSelectOtherNotRequiredTest::setUp in tests/
cck_select_other.test - Implementation of setUp() method
2 methods override CCKSelectOtherTest::setUp()
- CCKSelectOtherMultipleValueListTest::setUp in tests/
cck_select_other.test - Implementation of setUp() method
- CCKSelectOtherNotRequiredTest::setUp in tests/
cck_select_other.test - Implementation of setUp() method
File
- tests/
cck_select_other.test, line 23 - CCK Select Other Functional Tests
Class
- CCKSelectOtherTest
- This is a base class that other tests will rely on for standardized setUp(), and tearDown() methods.
Code
public function setUp() {
parent::setUp(array(
'cck_select_other',
'php',
));
$this
->assertTrue(module_exists('cck_select_other'), t('CCK Select Other module is enabled.'));
$content_type = strtolower($this
->randomName(5));
/* Setup an admin user */
$this->admin_user = $this
->drupalCreateUser(array(
'administer content types',
'administer site configuration',
'use PHP for settings',
));
$this
->drupalLogin($this->admin_user);
/* Create a new content type */
$settings = array(
'type' => $content_type,
);
$this->contentType = $this
->drupalCreateContentType($settings);
/* Create some options for our select other list */
$this->options = '';
for ($i = 0; $i < 4; $i++) {
$this->options .= $this
->randomName(5);
if ($i < 3) {
$this->options .= "\n";
}
}
/* Create a new field on our content type */
$field_label = $this
->randomName(5);
$field_name = strtolower($this
->randomName(5));
$bundle_path = 'admin/structure/types/manage/' . $this->contentType->type;
$edit = array(
'fields[_add_new_field][label]' => $field_label,
'fields[_add_new_field][field_name]' => $field_name,
'fields[_add_new_field][type]' => 'list_text',
'fields[_add_new_field][widget_type]' => 'cck_select_other',
);
$this
->drupalPost($bundle_path . '/fields', $edit, 'Save');
$edit = array(
'instance[required]' => TRUE,
'instance[widget][settings][select_list_options]' => $this->options,
'instance[widget][settings][select_list_options_fieldset][advanced_options][select_list_options_php]' => '',
'field_' . $field_name . '[und][0][select_other_list]' => 'other',
);
$this
->drupalPost($bundle_path . '/fields/field_' . $field_name, $edit, 'Save settings');
$this
->drupalGet($bundle_path . '/fields/field_' . $field_name);
$this->test_field = field_info_field('field_' . $field_name);
$this->test_instance = field_info_instance('node', 'field_' . $field_name, $this->contentType->type);
/* Setup a web user that can create content */
// @todo bypass node access seems to be the only thing that does not return 403
$this->web_user = $this
->drupalCreateUser(array(
'access content',
'create ' . $this->contentType->type . ' content',
'delete any ' . $this->contentType->type . ' content',
'bypass node access',
'use PHP for settings',
));
$this
->drupalLogout();
$this
->drupalLogin($this->web_user);
$settings = array(
'type' => $this->contentType->type,
);
$this->test_node = $this
->drupalCreateNode($settings);
$this
->drupalLogout();
$options_arr = cck_select_other_options($this->test_instance);
$this
->assertEqual(6, count($options_arr), t('There are 6 = %count options set on the field.', array(
'%count' => count($options_arr),
)));
}