function ContextReactionBlockTest::test in Context 7.3
Same name and namespace in other branches
- 6.3 tests/context.reactions.test \ContextReactionBlockTest::test()
- 6 tests/context.reactions.test \ContextReactionBlockTest::test()
File
- tests/
context.reactions.test, line 23
Class
Code
function test() {
ctools_include('export');
$context = ctools_export_new_object('context');
$context->name = 'testcontext';
$context->conditions = array(
'sitewide' => array(
'values' => array(
1,
),
),
);
$context->reactions = array(
'block' => array(
'blocks' => array(
'user-online' => array(
'module' => 'user',
'delta' => 'online',
'region' => 'sidebar_first',
'weight' => 0,
),
),
),
);
$saved = context_save($context);
$this
->assertTrue($saved, "Context 'testcontext' saved.");
theme_enable(array(
'bartik',
));
variable_set('theme_default', 'bartik');
$this
->refreshVariables();
$this
->drupalGet('node');
$this
->assertText('Who\'s online');
// Test title override of code provided block
$edit = array(
'title' => 'Context Online Block',
);
$this
->drupalPost('admin/structure/block/manage/user/online/configure', $edit, t('Save block'));
$this
->drupalPost('admin/config/development/performance', array(), t('Clear all caches'));
$this
->drupalGet('node');
$this
->assertText('Context Online Block');
// Test title of custom block
$edit = array(
'info' => 'Context Custom Block Info',
'title' => 'Context Custom Block Title',
'body[value]' => $this
->randomName(32),
);
$this
->drupalPost('admin/structure/block/add', $edit, t('Save block'));
$bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(
':info' => $edit['info'],
))
->fetchField();
$context->reactions['block']['blocks']["block-{$bid}"] = array(
'module' => 'block',
'delta' => $bid,
'region' => 'sidebar_first',
'weight' => 2,
);
$saved = context_save($context);
$this
->assertTrue($saved, "Context 'testcontext' saved.");
$this
->drupalGet('node');
$this
->assertText('Context Custom Block Title');
// Cleanup
context_delete($context);
}