function SimplenewsTestCase::setupSubscriptionBlock in Simplenews 7
Same name and namespace in other branches
- 6.2 tests/simplenews.test \SimplenewsTestCase::setupSubscriptionBlock()
- 7.2 tests/simplenews.test \SimplenewsTestCase::setupSubscriptionBlock()
Enable newsletter subscription block.
Parameters
integer $tid: newsletter term id
array $settings: ['message'] = Block message ['form'] = '1': Subscription form; '0': Link to form ['link to previous'] = {1, 0} Display link to previous issues ['previous issues'] = {1, 0} Display previous issues ['issue count'] = {1, 2, 3, ...}Number of issues to display ['rss feed'] = {1, 0} Display RSS-feed icon
4 calls to SimplenewsTestCase::setupSubscriptionBlock()
- SimpleNewsAdministrationTestCase::testCategorySettings in tests/
simplenews.test - Test various combinations of newsletter category settings.
- SimplenewsSubscribeTestCase::testSubscribeAnonymous in tests/
simplenews.test - testSubscribeAnonymous
- SimplenewsSubscribeTestCase::testSubscribeAnonymousSingle in tests/
simplenews.test - Test anonymous subscription with single opt in.
- SimplenewsSubscribeTestCase::testSubscribeAuthenticated in tests/
simplenews.test - testSubscribeAuthenticated
File
- tests/
simplenews.test, line 111 - Simplenews test functions.
Class
- SimplenewsTestCase
- @file Simplenews test functions.
Code
function setupSubscriptionBlock($tid, $settings = array()) {
$bid = db_select('block')
->fields('block', array(
'bid',
))
->condition('module', 'simplenews')
->condition('delta', $tid)
->execute();
// Check to see if the box was created by checking that it's in the database..
$this
->assertNotNull($bid, t('Block found in database'));
// Set block parameters
$edit = array();
$edit['regions[bartik]'] = 'sidebar_first';
if (isset($settings['message'])) {
$edit['simplenews_block_m_' . $tid] = $settings['message'];
}
if (isset($settings['form'])) {
$edit['simplenews_block_f_' . $tid] = $settings['form'];
}
if (isset($settings['link to previous'])) {
$edit['simplenews_block_l_' . $tid] = $settings['link to previous'];
}
if (isset($settings['previous issues'])) {
$edit['simplenews_block_i_status_' . $tid] = $settings['previous issues'];
}
if (isset($settings['issue count'])) {
$edit['simplenews_block_i_' . $tid] = $settings['issue count'];
// @todo check the count
}
if (isset($settings['rss feed'])) {
$edit['simplenews_block_r_' . $tid] = $settings['rss feed'];
}
// Simplify confirmation form submission by hiding the subscribe block on
// that page. Same for the newsletter/subscriptions page.
$edit['pages'] = "newsletter/confirm/*\nnewsletter/subscriptions";
$this
->drupalPost('admin/structure/block/manage/simplenews/' . $tid . '/configure', $edit, t('Save block'));
$this
->assertText('The block configuration has been saved.', 'The newsletter block configuration has been saved.');
}