public function OptimizelyTestAddUpdateCase::testOptimizelyAddUpdateProject in Optimizely 7.3
Same name and namespace in other branches
- 7.2 optimizely.test \OptimizelyTestAddUpdateCase::testOptimizelyAddUpdateProject()
File
- ./
optimizely.test, line 669 - Optimizely Tests
Class
Code
public function testOptimizelyAddUpdateProject() {
// create page
$settings = array(
'type' => 'page',
'title' => $this
->randomName(32),
'body' => array(
LANGUAGE_NONE => array(
array(
$this
->randomName(64),
),
),
),
);
$node1 = $this
->drupalCreateNode($settings);
// Create the url alias
$edit_node1 = array();
$edit_node1['source'] = 'node/' . $node1->nid;
$edit_node1['alias'] = $this
->randomName(10);
$this
->drupalPost('admin/config/search/path/add', $edit_node1, t('Save'));
$edit = array(
'optimizely_project_title' => $this
->randomName(8),
'optimizely_project_code' => rand(0, 10000),
'optimizely_path' => $edit_node1['alias'],
'optimizely_enabled' => rand(0, 1),
);
$this
->drupalPost('admin/config/system/optimizely/add_update', $edit, t('Add'));
$project_title = db_query('SELECT project_title FROM {optimizely} WHERE project_title = :optimizely_project_title', array(
':optimizely_project_title' => $edit['optimizely_project_title'],
))
->fetchField();
$this
->assertEqual($project_title, $edit['optimizely_project_title'], t('The project was added to the database.'));
// create page
$settings = array(
'type' => 'page',
'title' => $this
->randomName(32),
'body' => array(
LANGUAGE_NONE => array(
array(
$this
->randomName(64),
),
),
),
);
$node2 = $this
->drupalCreateNode($settings);
// Create the url alias
$edit_node2 = array();
$edit_node2['source'] = 'node/' . $node2->nid;
$edit_node2['alias'] = $this
->randomName(10);
$this
->drupalPost('admin/config/search/path/add', $edit_node2, t('Save'));
$edit = array(
'optimizely_project_title' => $this
->randomName(8),
'optimizely_project_code' => rand(0, 10000),
'optimizely_path' => $edit_node2['alias'],
'optimizely_enabled' => rand(0, 1),
);
$this
->drupalPost('admin/config/system/optimizely/add_update/2', $edit, t('Update'));
// test if database was updated
$project_title = db_query('SELECT project_title FROM {optimizely} WHERE project_title = :optimizely_project_title', array(
':optimizely_project_title' => $edit['optimizely_project_title'],
))
->fetchField();
$this
->assertEqual($project_title, $edit['optimizely_project_title'], t('The project was updated in the database.'));
}