function NotificationsTestCase::contentCreateSubscription in Notifications 6.4
Same name and namespace in other branches
- 7 tests/notifications_test_case.inc \NotificationsTestCase::contentCreateSubscription()
Helper function to create a subscription
2 calls to NotificationsTestCase::contentCreateSubscription()
- NotificationsAnonymousTests::anonymousCreateSubscription in tests/
notifications_anonymous.test - NotificationsContentTests::testNotificationsContent in tests/
notifications_content.test - Play with creating, retrieving, deleting a pair subscriptions
File
- tests/
notifications_test_case.inc, line 28 - Base class for Notifications Tests
Class
- NotificationsTestCase
- @file Base class for Notifications Tests
Code
function contentCreateSubscription($user, $type, $fields, $confirm_texts = array(), $post = array()) {
// Create a link for the subscription confirmation page
$link = notifications_get_link('subscribe', array(
'uid' => $user->uid,
'type' => $type,
'fields' => $fields,
));
$this
->drupalGet($link['href'], $link['options']);
$this
->assertText(t('Confirm your subscription'), 'Subscriptions confirmation page is shown');
foreach ($confirm_texts as $text) {
$this
->assertRaw($text);
}
// Submit the form and check confirmation page
$this
->drupalPost(NULL, $post, t('Subscribe'));
$this
->assertText(t('Your subscription has been created.'));
$subs = notifications_get_subscriptions(array(
'uid' => $user->uid,
'type' => $type,
), $fields);
$subscription = array_shift($subs);
$this
->assertTrue($subscription, "The subscription object can be retrieved from the db.");
return $subscription;
}