function UserpointsFieldsTestCase::testSingleField in User Points 7.2
File
- ./
userpoints.test, line 678 - Contains test classes for userpoints module.
Class
- UserpointsFieldsTestCase
- Tests for fields integration.
Code
function testSingleField() {
// Create an administrator account.
$admin = $this
->drupalCreateUser(array(
'administer userpoints',
));
$this
->drupalLogin($admin);
// Create a new field.
$edit = array(
'fields[_add_new_field][label]' => $this
->randomName(),
'fields[_add_new_field][field_name]' => $name = strtolower($this
->randomName()),
'fields[_add_new_field][type]' => 'text',
'fields[_add_new_field][widget_type]' => 'text_textfield',
);
$this
->drupalPost('admin/config/people/userpoints/types/userpoints/fields', $edit, t('Save'));
$this
->drupalPost(NULL, array(), t('Save field settings'));
$this
->drupalPost(NULL, array(), t('Save settings'));
// Create transaction.
$message = array(
'txn_user' => $admin->name,
'points' => 10,
'field_' . $name . '[' . LANGUAGE_NONE . '][0][value]' => $this
->randomName(50),
);
$this
->drupalPost('admin/config/people/userpoints/add', $message, t('Save'));
// Check message.
$this
->drupalGet('myuserpoints');
$this
->clickLink(t('view'));
$this
->assertText($message['field_' . $name . '[' . LANGUAGE_NONE . '][0][value]'], t('Content of new field is displayed.'));
}