You are here

function NotificationsCustomTests::createCustomSubscription in Notifications 6.4

Same name and namespace in other branches
  1. 7 tests/notifications_custom.test \NotificationsCustomTests::createCustomSubscription()

Create custom subscription through admin form

1 call to NotificationsCustomTests::createCustomSubscription()
NotificationsCustomTests::testCustomSubscriptions in tests/notifications_custom.test

File

tests/notifications_custom.test, line 76

Class

NotificationsCustomTests

Code

function createCustomSubscription($data, $fields = array()) {
  $data += array(
    'newtype' => 'custom_' . $this
      ->randomName(10),
    'title' => $this
      ->randomName(20),
    'name' => $this
      ->randomName(40),
    'description' => $this
      ->randomName(80),
  );
  foreach ($data as $field => $value) {
    $edit["subscription[{$field}]"] = $value;
  }
  $this
    ->drupalPost('admin/messaging/customsubs/new', $edit, t('Save'));
  $this
    ->assertText('The subscription type has been created.');
  $subscription = notifications_custom_load($data['newtype']);
  $this
    ->assertTrue($subscription, 'A new custom subscription type has been created');
  if ($fields) {
    $subscription = $this
      ->createCustomFields($subscription, $fields);
  }
  return $subscription;
}