function MessageNotifyNotifierTest::setUp in Message Notify 7.2
Sets up a Drupal site for running functional and integration tests.
Generates a random database prefix and installs Drupal with the specified installation profile in DrupalWebTestCase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.
After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.
Parameters
...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.
Overrides DrupalWebTestCase::setUp
See also
DrupalWebTestCase::prepareDatabasePrefix()
DrupalWebTestCase::changeDatabasePrefix()
DrupalWebTestCase::prepareEnvironment()
File
- ./
message_notify.test, line 16
Class
- MessageNotifyNotifierTest
- Test the Message notifier plugins handling.
Code
function setUp() {
parent::setUp('message_notify_test');
// Add another message-text field.
$field = array(
'field_name' => 'message_text_another',
'type' => 'text_long',
'entity_types' => array(
'message_type',
),
'settings' => array(
// Mark that this field can be rendered using Message::getText().
'message_text' => TRUE,
),
);
$field = field_create_field($field);
$instance = array(
'field_name' => 'message_text_another',
'bundle' => 'message_type',
'entity_type' => 'message_type',
'label' => t('Message text'),
'required' => TRUE,
);
field_create_instance($instance);
$message_type = message_type_create('foo');
$wrapper = entity_metadata_wrapper('message_type', $message_type);
$wrapper->{MESSAGE_FIELD_MESSAGE_TEXT}[] = array(
'value' => 'first partial',
'format' => 'plain_text',
);
$wrapper->{MESSAGE_FIELD_MESSAGE_TEXT}[] = array(
'value' => 'second partial',
'format' => 'plain_text',
);
$wrapper->message_text_another = 'another field';
$wrapper
->save();
$this->message_type = $message_type;
// Enable the Full view mode, hide the first partial,
// and display the last partial first.
$settings = field_bundle_settings('message', 'foo');
$settings['view_modes']['full']['custom_settings'] = TRUE;
$settings['extra_fields']['display']['message__message_text__0']['foo'] = array(
'weight' => 0,
'visible' => FALSE,
);
$settings['extra_fields']['display']['message__message_text__1']['foo'] = array(
'weight' => 0,
'visible' => TRUE,
);
$settings['extra_fields']['display']['message__message_text_another__0']['foo'] = array(
'weight' => 0,
'visible' => FALSE,
);
$settings['extra_fields']['display']['message__message_text__0']['bar'] = array(
'weight' => 0,
'visible' => FALSE,
);
$settings['extra_fields']['display']['message__message_text__1']['bar'] = array(
'weight' => 0,
'visible' => FALSE,
);
$settings['extra_fields']['display']['message__message_text_another__0']['bar'] = array(
'weight' => 0,
'visible' => TRUE,
);
field_bundle_settings('message', 'foo', $settings);
}