public function OptimizelyTestEnableDisableCase::testOptimizelyUpdateEnableDisable in Optimizely 7.3
Same name and namespace in other branches
- 7.2 optimizely.test \OptimizelyTestEnableDisableCase::testOptimizelyUpdateEnableDisable()
File
- ./
optimizely.test, line 841 - Optimizely Tests
Class
- OptimizelyTestEnableDisableCase
- Test enabling / disabling non-default project from update page
Code
public function testOptimizelyUpdateEnableDisable() {
// create page
$settings = array(
'type' => 'page',
'title' => $this
->randomName(32),
'body' => array(
LANGUAGE_NONE => array(
array(
$this
->randomName(64),
),
),
),
);
$node = $this
->drupalCreateNode($settings);
// Create the url alias
$edit_node = array();
$edit_node['source'] = 'node/' . $node->nid;
$edit_node['alias'] = $this
->randomName(10);
$this
->drupalPost('admin/config/search/path/add', $edit_node, t('Save'));
// create a disabled project
$edit = array(
'optimizely_project_title' => $this
->randomName(8),
'optimizely_project_code' => rand(0, 10000),
'optimizely_path' => $edit_node['alias'],
'optimizely_enabled' => 0,
);
$this
->drupalPost('admin/config/system/optimizely/add_update', $edit, t('Add'));
$edit = array(
'optimizely_enabled' => 1,
);
$this
->drupalPost('admin/config/system/optimizely/add_update/2', $edit, t('Update'));
// test if project was enabled
$enabled = db_query('SELECT enabled FROM {optimizely} WHERE oid = 2')
->fetchField();
$this
->assertEqual($enabled, $edit['optimizely_enabled'], t('The project was enabled from update page.'));
$edit = array(
'optimizely_enabled' => 0,
);
$this
->drupalPost('admin/config/system/optimizely/add_update/2', $edit, t('Update'));
// test if project was disabled
$enabled = db_query('SELECT enabled FROM {optimizely} WHERE oid = 2')
->fetchField();
$this
->assertEqual($enabled, $edit['optimizely_enabled'], t('The project was disabled from update page.'));
}